Hello guys,
I have these two PHP scripts; gen.php and thumbs.php.
This is for an images gallary where gen.php produces the thumbnails and thumbs.php displays them.
I am trying to get this to work but the images keep getting broken.
http://sig11.zemos.net/test/thumbs.php
here is the source for gen.php
Code:
<?php
$t_width = 100; // Thumbnail width
// get and display jpeg images
if(stristr($QUERY_STRING,".jpg")){
header("Content-type: image/jpeg");
$srcimage = imagecreatefromjpeg($QUERY_STRING);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
$newh1= $height / $width;
$newh2= $newh1 * $t_width;
$destimage = imagecreate($t_width,$newh2);
imagecopyresized($destimage,$srcimage,0,0,0,0,$t_width,$newh2,$width,$height);
ImageJPEG($destimage);
ImageDestroy($destimage);
}
// on a problem geneterate an image with ERROR in it
/*else {
$im = imagecreate(100,100);
$blue = imagecolorallocate($im,0,0,200);
$red = imagecolorallocate($im,255,0,0);
imagestring($im,2,2,5,"ERROR",$red);
imageGIF($im);
imagedestroy($im);
} */
?>
Here is thumbs.php
Code:
<?php
// Set variables
$default_dir = "./images"; // Relative to current location
// Directory Scan
if(!($dp = opendir($default_dir))) die("Cannot open $dir");
// Place images into image tag
while($file = readdir($dp)){
if($file != '.' && $file != '..' && stristr($file,"jpg")) echo "<a
href=\"$default_dir/$file\"><img
src=\"./gen.php?$default_dir/$file\"></a>\r\n";
}
closedir($dp);
?>
Any ideas?
Thank you
Ilya