Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Create one image from images

Tags:

php

image

i have n-images and want to create one with php code. I use imagecopymerge(), but can't make it. Some example please?

like image 729
kruksmail Avatar asked May 01 '12 12:05

kruksmail


1 Answers

Code:

$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);
like image 112
kruksmail Avatar answered Oct 01 '22 14:10

kruksmail