Reputation: 93
Please help to combine three jpg images using php image processing functions imagecopy, imagecopymerge
image 1- b.jpg
image 2- l.jpg
image3: r.jpg
output look like
I tried some example codes of the PHP functions imagecopy() or imagecopymerge() but not working with my images.
Upvotes: 3
Views: 6709
Reputation: 138
Could you give more information about: "not working"
I would suggest you to take a look at: imagecopyresampled
For the code, you have to load the images as image ressources, so you can use something like:
$im1 = imagecreatefrompng($path.'image1.png');
$im2 = imagecreatefrompng($path.'image2.png');
imagecopyresampled($im1,$im2,250,150,0,0,100,150,100,150);
unset($im2);
$im3 = imagecreatefrompng($path.'image3.png');
imagecopyresampled($im1,$im3,550,150,0,0,100,150,100,150);
unset($im3);
So $im1 now have the 3 images.
Just make sure to unset the image ressources, because you will run out of memory really fast.
Edit: I used imagecopyresampled because image 2-3 seem smaller on the last image, I don't know how more resource intensive it is, I guess imagecopymerge could work too.
Upvotes: 4