0 ) { $imagecount = 0; $images[0] = NULL; $totalwidth = 0; $urls[0] = NULL; $titles[0] = NULL; while( 1 ) { /* * find a random directory */ $cnt = (int) $entries- 1; $index = randNum( 0, $cnt ); $a = $szKeywords[$index]; $dir = $a[DIRECTORY]; $url = $a[URL]; $title = $a[TITLE]; $path = sprintf( "%s/images", $dir ); $urls[$imagecount] = $url . $dir; $titles[$imagecount] = $title; /* * get a random file from that directory */ $files = GetDirContents( $path ); $numfiles = count( $files ); $numfiles = $numfiles-1; $file_index = randNum( 0,$numfiles ); $url .= $files[$file_index]; /* * get a thumbnail of that random file file */ $images[$imagecount] = makeThumbnail($url, $height ); /* * once we have enough pixels to make a full image, quit */ $totalwidth += imagesx( $images[$imagecount] ); $imagecount++; if( $totalwidth >= $width ) { break; } if( $imagecount > 99 ) // bug trapper { break; } } /* while */ /* * create the base image */ $image = imagecreatetruecolor($width, $height+$extra_height); $bg_color = imagecolorallocate( $image, $bg_r, $bg_g, $bg_b); imagefill($image, 0, 0, $bg_color); /* * 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; /* * map script for this file */ $mapfile = "map".$count.".js"; $mf = fopen( $mapfile, "w" ); $tmp = "map = getMap(document.images.item(\"logoimage\"));\r\n"; fwrite( $mf, $tmp ); /* * now paste them all together */ $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, $image_start, $trim_left, 0, $im_width-$trim, $height ); imageDestroy( $im ); $tmp = sprintf( "addArea( map, \"%d,%d,%d,%d\",\"%s\", \"%s\" );\r\n", $x, $image_start, $x+($im_width-$trim), $image_start+$height, $urls[$i], $titles[$i] ); fwrite( $mf, $tmp ); $x = $x + $im_width - $trim; } /* for */ $tmp = sprintf( "addArea( map, \"%d,%d,%d,%d\",\"http://www.blah.com\",\"Home\" );\r\n", 0, $image_start+$height, $totalwidth-1, $height+$extra_height-1 ); fwrite( $mf, $tmp ); fclose( $mf ); /* * 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[7]); // distance from top to bottom $text_x = floor( ($width - $text_width) / 2 ); if( $align == "top" ) { $text_y = $text_height; } else if( $align == "bottom" ) { $text_y = $extra_height+$height-2; } else { $text_y = floor( ($height - $text_height) / 2 + $text_height); } $text_y += $align_adjust; imagettftext( $image, $fontsize, 0, $text_x, $text_y, $text_color, $font, $text ); /* * write the image */ if( $nonumber ) { $filen = $filename . ".jpg"; imagejpeg( $image, "", $quality ); } else { $filen = $filename . $count . ".jpg"; } imagejpeg( $image, $filen, $quality ); imageDestroy( $image ); $count = $count-1; } echo "DONE - count = $count;"; ?>