I'm trying to tile multiple images, i.e. put one directly underneath another. They all have the same width (120px) and differing heights.
This is what I have:
$finalbg = null;
for($i=0; $i<7; $i++) {
$addbg = imagecreatefromjpeg('images/left/'.$url[$drawn]);
$addsize = imagesy($addbg);
if($finalbg != null) $basesize = imagesy($finalbg); else $basesize = 0;
$newsize = $addsize+$basesize;
$newbg = imagecreatetruecolor(120, $newsize);
if($finalbg != null) imagecopy($newbg, $finalbg, 0, 0, 0, 0, 120, $basesize);
imagecopy($newbg, $addbg, 0, $basesize, 0, 0, 120, $addsize);
$finalbg = $newbg;
}
header( "Content-type: image/jpeg" );
imagejpeg($finalbg);
The sizes are outputting correctly, but it keeps telling the image contains errors, and I have no idea why :( Same thing if I try to output addbg or newbg.
Thanks.