= $width ) { break; } if( $imagecount > 99 ) // bug trapper { break; } } /* while */ /* * compute what we need to trim from each image */ $tmp = $totalwidth-$width; $trim = floor( $tmp/$imagecount ); $trim_left = floor( $trim/2 ); $trim_right = $trim-$trim_left; /* * now paste them all together */ $image = imagecreatetruecolor($width, $height); $x = 0; for( $i=0; $i<$imagecount; $i++ ) { $im = $images[$i]; $im_width = imagesx( $im ); //bool imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h ) imagecopy( $image, $im, $x, 0, $trim_left, 0, $im_width-$trim, $height ); imageDestroy( $im ); $x = $x + $im_width - $trim; } /* for */ /* * add the text */ $text = "ANGUS AND DUNCAN'S EXCELLENT ADVENTURE"; $text_color = imagecolorallocate( $image, $r, $g, $b); $bbox = imageftbbox( $fontsize, 0, $font, $text, array("linespacing" => 1) ); $text_width = abs($bbox[0]) + abs($bbox[2]); // distance from left to right $text_height = abs($bbox[1]) + abs($bbox[5]); // distance from top to bottom $text_x = floor( ($width - $text_width) / 2 ); $text_y = floor( ($height - $text_height) / 2 + $text_height); imagettftext( $image, $fontsize, 0, $text_x, $text_y, $text_color, $font, $text ); /* * write the image */ imagejpeg( $image, $filename, $quality ); imagejpeg( $image, "", $quality ); imageDestroy( $image ); ?>