用gd的imagecopy来实现,代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <? php header(”Content-type: image/jpeg”); $source1=imagecreatefromjpeg(”s.jpg”); $dest1=imagecreatefromjpeg(”d.jpg”); imagecopy($dest1,$source1,50,50,0,0,100,100); imagejpeg($dest1); imagedestroy($dest1); imagedestroy($source1); ?> |
在 图片 上 添加 文字,代码如下:
1 2 3 4 5 6 7 8 9 10 | <?php header(”Content-type: image/jpeg”); $string = “hello”; $im = imagecreatefromjpeg(”images/s.jpg”); $orange = imagecolorallocate($im, 220, 210, 60); $px = (imagesx($im) - 7.5 * strlen($string)) / 2; imagestring($im, 3, $px, 9, $string, $orange); imagejpeg($im); imagedestroy($im); ?> |
我突然想,那个super-image-plugin插件,不应该也是用了这个方法吧?
转载自:http://cngump.javaeye.com/blog/44736
会员登录关闭
注册会员关闭