Alright guys, I am in a little bit of a bind. I need to combine 5 images into one, but I can't just make them together, because one of them is dynamic, but in the end they need to be one image. I decided that the GD Library is what I need for this, but I don't know how to call multiple images into the script for it. Here is my current code, which currently only loads 1 of the 5 images, and it is the one that needs to be dynamic: PHP: <?php header("Content-type: image/png"); $im=imagecreatefrompng("http://miniprofile.xfire.com/bg/bg/type/1/blackburnperson.png"); imagepng($im); imagedestroy($im); ?> I want the end result to be one image that looks like this: TOP TOP TOP TOP TOP TOP TOP TOP LEFT CENTER CENTER RIGHT RIGHT BOTTOM BOTTOM BOTTOM BOTTOM In other words, very much like: This
Look at the imagecopy function for merging multiple images, i use it to dynamically add copyright to my images when hotlinked
Yeah, the imagecopy function is what you need, though I had some difficulty using only that - for some reason. The imagecopyresampled function seemed to work better - also try looking at imagecopymerge. I used them functions to create http://www.sweeto.org/site/vs.php - the code looks fairly simple, though took me a while from what i remember edit: thats 3 images merged into one by the way - 2 pictures have their transparency altered and two are .png's and one is a gif iirc.
Mind posting your code Bogomip so I can get an idea of how it is done? EDIT:I have offically gotten it to work, below is my code PHP: <? header ("Content-type: image/png"); $src = array ("http://img164.imageshack.us/img164/5175/toprb3.jpg","http://img123.imageshack.us/img123/9056/leftij4.jpg","http://miniprofile.xfire.com/bg/bg/type/1/blackburnperson.png", "http://img67.imageshack.us/img67/4786/rightnt1.jpg","http://img123.imageshack.us/img123/4891/bottomtp5.jpg"); $imgBuf = array (); foreach ($src as $link) { switch(substr ($link,strrpos ($link,".")+1)) { case 'png': $iTmp = imagecreatefrompng($link); break; case 'gif': $iTmp = imagecreatefromgif($link); break; case 'jpeg': case 'jpg': $iTmp = imagecreatefromjpeg($link); break; } array_push ($imgBuf,$iTmp); } $iOut = imagecreatetruecolor ("450","131") ; imagecopy ($iOut,$imgBuf[0],0,0,0,0,imagesx($imgBuf[0]),imagesy($imgBuf[0])); imagedestroy ($imgBuf[0]); imagecopy ($iOut,$imgBuf[1],0,54,0,0,imagesx($imgBuf[1]),imagesy($imgBuf[1])); imagedestroy ($imgBuf[1]); imagecopy ($iOut,$imgBuf[2],15,54,0,0,imagesx($imgBuf[2]),imagesy($imgBuf[2])); imagedestroy ($imgBuf[2]); imagecopy ($iOut,$imgBuf[3],292,54,0,0,imagesx($imgBuf[3]),imagesy($imgBuf[3])); imagedestroy ($imgBuf[3]); imagecopy ($iOut,$imgBuf[4],0,117,0,0,imagesx($imgBuf[4]),imagesy($imgBuf[4])); imagedestroy ($imgBuf[4]); imagepng($iOut); ?>