0

I have a site where the customer makes multiple selections of clothing and these are shown together at the end of the selection.
So they may select a dress, top and skirt, accessory etc.

All the images are in png format with a transparent background.

At the end of the selection, the preview page shows these individual images layered using z-index.
However, I want to send a thumbnail of a merged image of all these individual png files to a shopping cart.

I have been trying to merge multiple images using php and send the merged file to a folder but so far I have only been able to merge two images and only get it to work with a jpeg output. When I try and output a png, it doesn't seem to work. the jpeg of course doesn't give the transparent background I need. This is the code I have so far....

$photo = imagecreatefrompng("images/animals/cat-left.png");
$w = imagesx($photo);
$h = imagesy($photo);
imagealphablending($photo,true);

$frame = imagecreatefrompng("images/girls-dresses/1.png");
imagecopy($photo,$frame,0,0,0,0,$w,$h);

imagepng($photo,"output.png",100);
echo '<img src="output.png" />';

Can anyone tell me where I am going wrong please?

2
Contributors
1
Reply
14
Views
3 Years
Discussion Span
Last Post by gustavo.pinent
0

I'm beguinning to work with images too. I found this about using alpha channel in php images:

$imgPng = imageCreateFromPng($strImagePath);
imageAlphaBlending($imgPng, true);
imageSaveAlpha($imgPng, true);

It seams without this, alpha will be ignored and the background will be black. I think will be usefull if you post a image of the wrong result and a simulation of what should be.

Good luck!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.