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:
http://www.vbforums.com/attachment.p...postid=1636043
Printable View
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:
http://www.vbforums.com/attachment.p...postid=1636043
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....Quote:
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..
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.
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.
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.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);
//open the dump images
$img1 = imageCreateFromPNG("img1.png");
$img2 = imageCreateFromPNG("img2.png");
$img3 = imageCreateFromPNG("img3.png");
//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));
//imagecopy(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h);
//display the image
imagePNG($base);
imageDestroy($base);
?>
Here's a working example of the script:
http://david.gamersepitome.net/files...y/img_copy.php
And the original images that I made for this:
http://david.gamersepitome.net/files..._copy/img1.png http://david.gamersepitome.net/files..._copy/img2.png http://david.gamersepitome.net/files..._copy/img3.png
Anyway.. Hope that helps you, and if you have any questions about my code, feel free to ask.
Thanx mate, just what I was after :D.