Page 1 of 1

Creating a composite image server-side

Posted: Fri Dec 05, 2003 2:28 pm
by Jean-Yves
Hi,

Not been around for a while - feel like I've missed loads of good stuff!

On to my question:

Is it possible to create an image using PHP that is a composite/amalgam of other smaller images?

One absolute MUST criterion is that it must support the smaller images' transparency layer (only one, they are GIF's). I don't mind what format the composite image is in, although the image types include lots of blocks of single colours, so I guess that GIF or PNG would be best.

Thanks in advance.

Posted: Fri Dec 05, 2003 9:50 pm
by DuFF
From http://www.php.net/image:
gif:
Only supported in GD versions older than gd-1.6. Read-only GIF support is available with PHP 4.3.0 and the bundled GD-library.

png:
library: http://www.libpng.org/pub/png/libpng.html
Only supported in GD versions greater than gd-1.6.
GIF support was stopped because of Unisys LZW patent that doesn't expire until July 7th, 2004. You may want to go with PNG if you want the most current version of GD.

imagecopymerge() may be the function you are looking for. Look at the last comment, it seems to have a function that you may be able to put to use if you add some of the alpha blending code shown in the first comment.

Also, if you can install a library onto the server you are using, you should look into Image Majick. One of the features listed on the site is "Create a composite image by combining several separate images."
If you decided to use Image Majick this link maybe helpful too: http://pecl.php.net/package/imagick

Posted: Wed Dec 10, 2003 5:24 pm
by Jean-Yves
Thanks Duff, the info is very useful.

And apologies that it's taken so long to thank you! It's much appreciated :)