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);

$frame = imagecreatefrompng("images/girls-dresses/1.png");

echo '<img src="output.png" />';

Can anyone tell me where I am going wrong please?

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.