Hi folks,
I'm having a hell of a time generating multiple dynamic thumbnail images on an html page - I can create a single thumbnail fine with a php script ... but when I call that script multiple times within an html page it bombs our on one or more of the images.
Essentially I'm building the HTML page in JSP to have lets say 20 or more thumbnail images ... each <img> tag looks like this:
<img src="php-bin/thumbnail_generator.php?dimensions=150&image=xyz111.jpg"/>
My php script (thumbnail_generator.php) looks like this:
<?
dl('gd.so');
header("Content-type: image/jpeg");
$src_img = imagecreatefromjpeg($image);
$new_w = $dimensions;
$new_h = $dimensions;
$dst_img = imagecreate($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img);
imagedestroy($dst_img);
?>
The problem is that when I go to the HTML page with all these <img> tags ... the php script sporadically creates thumbnails for only some of them! Sometimes all I get is broken image icons ... and each time I refresh the page it is different! I'm thinking it has something to do with calling the same script 20x within the <img> tag ... maybe a threading issue. But since I'm a newbie ... I'm not sure ... and I'm not sure how to resolve this.
Any ideas?
Thanks - Wayde