我需要合并两个.png图像并调整输出大小,我有以下代码:
public function image($bg = null, $img = null)
{
define("WIDTH", 1200);
define("HEIGHT", 1200);
$dest_image = imagecreatetruecolor(WIDTH, HEIGHT);
imagesavealpha($dest_image, true);
$trans_background = imagecolorallocatealpha($dest_image, 0, 0, 0, 127);
imagefill($dest_image, 0, 0, $trans_background);
$a = imagecreatefrompng('./test/'.$bg);
$b = imagecreatefrompng('./test/'.$img);
imagecopy($dest_image, $a, 0, 0, 0, 0, WIDTH, HEIGHT);
imagecopy($dest_image, $b, 0, 0, 0, 0, WIDTH, HEIGHT);
header('Content-Type: image/png');
imagepng($dest_image);
imagedestroy($a);
imagedestroy($b);
imagedestroy($dest_image);
}
此代码返回原始大小的PNG图像,如何使此函数返回其他大小的图像,例如(200 * 200px)
http://www.codeigniter.com/user_guide/libraries/image_lib.html#two-types-of-watermarking
或者使用ImageMagik,很好的扩展。但是需要在服务器上