Image + Image = Image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Image + Image = Image

Post by Dale »

Could someone please explain to me (in a demonstration) how I would go about this. Say I have a body (Head, Body, Legs) now how would I (in PHP) get it so the head.png, body.png and legs.png images go together and come out as just 1 .PNG image?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

First make sure that the gd library is installed and working. Then take the 3 images and get the size of each - getimagesize(). Then create a new image that is as wide as the widest image, and as tall as all three added together - imagecreatetruecolor().

Then copy the three images to the new one, aranging them so that they fit in order - imagecopyresized().

Save or display the image - imagejpeg()..
Post Reply