I'm new to playing round with images in PHP so I was wondering if anyone could show me how I would have serveral images in the one generated image:
Last edited by Electroman; Feb 28th, 2004 at 08:29 AM.
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Originally posted by kows do you want to open images and then send them out to a browser in one file? you can do that..
do you want to create the images in PHP and then return them in one file? you can do that too..
First one....
Say I have 7 image files named: Pic1.png, Pic2.png, Pic3.png, .....
Then I want to create a image to be returned to the browser which contains the 7 images as shown in the attachment. The script will be actually be deciding which images go where but I don't need to worrie about that at the moment as I think I have that covered.
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
I'll try to make something for you then.. I'll just make an example of 3 images, just so you'll get the general idea.. it might take me a while because my internet is pretty slow right now.
ok, finished. I actually got it working on my first try, with minor bugs to fix, but it works perfectly now.. thought this would be a huge challenge, though.
This is just for 3 images, so you get the general idea, and I'm not doing all of your work.
PHP Code:
<?
//image merge script
// author: David Miles
// contact: [email][email protected][/email]
//create an empty image to dump the images into
$base = imageCreate(300, 40);
//make a few temporary colors for debugging
$black = imageColorAllocate($base, 0, 0, 0); //black
$white = imageColorAllocate($base, 255, 255, 255); //white
//fill the image with black for easy debug in early stages
imageRectangle($base, 0, 0, 300, 40, $black);
//copy the first image and place it in the 0,0 position
imageCopy($base, $img1, 0, 0, 0, 0, imagesX($img1), imagesY($img1));
//copy the second image and get the x coordinate by calculating first images width
imageCopy($base, $img2, imagesX($img1), 0, 0, 0, imagesX($img2), imagesY($img2));
//copy the third image and get the x coordinate by adding the first and second images' width
imageCopy($base, $img3, imagesX($img1) + imagesX($img2), 0, 0, 0, imagesX($img3), imagesY($img3));
//display the image
imagePNG($base);
imageDestroy($base);
?>
I left in all of my debugging stuff I made to make sure I had it all working before I actually started adding images.. and anything else I added in to do things. I removed some irrelevant stuff that I was using to make sure I was actually making an image and it was showing up correctly.
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.