Thumbs are 0 bytes

From: Date: Tue, 29 Apr 2003 07:11:14 +0000
Subject: Thumbs are 0 bytes
Groups: php.general 
Request: Send a blank email to php-general+get-145592@lists.php.net to get a copy of this message
Greetings learned PHP(eople), Objective : Loop directory and create thumbnail for each image found. Code : ------------------------------------------------ <?php //Location of images directory $image_dir = 'images/'; //Location wherer thumbnails will be stored $thumb_dir = "images/thumbs/"; //Open the image dir and loop through it $dir = opendir($image_dir); while ($file = readdir($dir)) { $filepath = ($image_dir . $file) ; if (is_file($filepath)) { // Check if the file extension is .jpg $ext = explode('.', $file); $ext = $ext[count($ext)-1]; if (strtolower($ext) != "jpg") { die ("Error: File must be JPEG"); } // Read the source image $src_img = ImageCreateFromJPEG($image_dir.$file); // Get image width and height $org_h = imagesy($src_img); $org_w = imagesx($src_img); // Calculate thumbnail height $tn_h = floor($tn_w * $org_h / $org_w); // Initialize destination image $dst_img = ImageCreate($tn_w,$tn_h); // Do it! ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $tn_w, $tn_h, $org_w, $org_h); // Save it! ImageJPEG($dst_img, ($thumb_dir . $file)); } } closedir($dir); ?> ---------------------------------------------------------- Problem : The process runs through without reporting errors but all the thumbnails created are 0 byte files and inacessible. Any ideas ? Thanks -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Computers are a lot like air-conditioners. Once you open windows, they stop working properly.

« previous php.general (#145592) next »