我有n个图像,并想用php代码创建一个。我使用imagecopymerge(),但不能成功。请举个例子吗?

最佳答案

代码:

$numberOfImages = 3;
$x = 940;
$y = 420;
$background = imagecreatetruecolor($x, $y*3);


$firstUrl = '/images/upload/photoalbum/photo/1.jpg';

$secondUrl = '/images/upload/photoalbum/photo/2.jpg';

$thirdUrl = '/images/upload/photoalbum/photo/3.jpg';

$outputImage = $background;

$first = imagecreatefromjpeg($firstUrl);
$second = imagecreatefromjpeg($secondUrl);
$third = imagecreatefromjpeg($thirdUrl);



imagecopymerge($outputImage,$first,0,0,0,0, $x, $y,100);
imagecopymerge($outputImage,$second,0,$y,0,0, $x, $y,100);
imagecopymerge($outputImage,$third,0,$y*2,0,0, $x, $y,100);

imagejpeg($outputImage, APPLICATION_PATH .'/images/upload/photoalbum/photo/test.jpg');

imagedestroy($outputImage);

关于PHP-从图像创建一个图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10397842/

10-09 18:59