Sheldon Posted December 8, 2004 Posted December 8, 2004 I loaded the thumnail generator and got the following error messages. I rechecked and everything is in its right place. (files i mean) Can anyone help? I Checked the DIR_FS_CATALOGDIR_WS_IMAGES line and it is written as: opendir(DIR_FS_CATALOG . DIR_WS_IMAGES). I am posting both the error messages and the code in hopes that it will be helpful. --------------error messages---------------- Warning: opendir(DIR_FS_CATALOGDIR_WS_IMAGES): failed to open dir: No such file or directory in /var/www/html/catalog/admin/thumbs.php on line 56 Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/html/catalog/admin/thumbs.php on line 58 Warning: closedir(): supplied argument is not a valid Directory resource in /var/www/html/catalog/admin/thumbs.php on line 67 Warning: opendir(DIR_FS_CATALOGDIR_WS_IMAGES): failed to open dir: No such file or directory in /var/www/html/catalog/admin/thumbs.php on line 70 Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/html/catalog/admin/thumbs.php on line 72 Warning: closedir(): supplied argument is not a valid Directory resource in /var/www/html/catalog/admin/thumbs.php on line 91 ---end error messages------- ----------begin thumbs.php file----------- <?php /***************************************************************** This contribution was made by Chris Sullivan and is used to auto- matically generate thumbnails for your shop. This will allow for faster loading times on the index.php page. *****************************************************************/ function createthumb($IMAGE_SOURCE,$THUMB_X,$THUMB_Y,$OUTPUT_FILE){ $BACKUP_FILE = $OUTPUT_FILE . "_backup.jpg"; copy($IMAGE_SOURCE,$BACKUP_FILE); $IMAGE_PROPERTIES = GetImageSize($BACKUP_FILE); if (!$IMAGE_PROPERTIES[2] == 2) { return(0); } else { $SRC_IMAGE = ImageCreateFromJPEG($BACKUP_FILE); $SRC_X = ImageSX($SRC_IMAGE); $SRC_Y = ImageSY($SRC_IMAGE); if (($THUMB_Y == "0") && ($THUMB_X == "0")) { return(0); } elseif ($THUMB_Y == "0") { $SCALEX = $THUMB_X/($SRC_X-1); $THUMB_Y = $SRC_Y*$SCALEX; } elseif ($THUMB_X == "0") { $SCALEY = $THUMB_Y/($SRC_Y-1); $THUMB_X = $SRC_X*$SCALEY; } $THUMB_X = (int)($THUMB_X); $THUMB_Y = (int)($THUMB_Y); $DEST_IMAGE = imagecreatetruecolor($THUMB_X, $THUMB_Y); unlink($BACKUP_FILE); if (!imagecopyresized($DEST_IMAGE, $SRC_IMAGE, 0, 0, 0, 0, $THUMB_X, $THUMB_Y, $SRC_X, $SRC_Y)) { imagedestroy($SRC_IMAGE); imagedestroy($DEST_IMAGE); return(0); } else { imagedestroy($SRC_IMAGE); if (ImageJPEG($DEST_IMAGE,$OUTPUT_FILE)) { imagedestroy($DEST_IMAGE); $im = imagecreatefromjpeg($OUTPUT_FILE); return(1); } imagedestroy($DEST_IMAGE); } return(0); } } //You can change this to a different folder if you want to upload all your files to a temp folder //such as images/temp and than create an images/temp/thumbnails folder. You can always move the //images back to the main folder when you are done. define('RESIZE_ORIGINAL_PATH', DIR_FS_CATALOG . DIR_WS_IMAGES);//'c:/pics/'); define('RESIZE_NEW_PATH', DIR_FS_CATALOG . DIR_WS_IMAGES);//'c:/pics/thumbnails/'); define('PIC_FOLDER', ''); $rep2 = RESIZE_NEW_PATH; $small_dir = opendir(DIR_FS_CATALOG . DIR_WS_IMAGES); $small_list = ""; while ($s = readdir($small_dir)) { if(is_file($rep2.$s)) { if ($small_list == '') { $small_list .= $s; } else { $small_list .= ', ' . $s; } } } closedir($small_dir); $rep = RESIZE_ORIGINAL_PATH; $big_dir = opendir($rep); while ($f = readdir($big_dir)) { if((is_file($rep.$f)) && ((substr($rep.$f, -4) == ".jpg") || (substr($rep.$f, -5) == ".jpeg"))) { $wo_ext = eregi_replace('.jpg', '_thumb', $f); $wo_ext = eregi_replace('.jpeg', '_thumb', $wo_ext); $pos = strpos($small_list, $wo_ext); if ($pos === false) { $image_big = RESIZE_ORIGINAL_PATH . $f; $image_small_name = eregi_replace('.jpg', '_thumb.jpg', $f); $image_small_name = eregi_replace('.jpeg', '_thumb.jpeg', $image_small_name); $image_small = RESIZE_NEW_PATH . $image_small_name; $image_size = getimagesize($image_big); if ($image_size['0'] > $image_size['1']) { createthumb($image_big, '0', SMALL_IMAGE_HEIGHT, $image_small); } else { createthumb($image_big, SMALL_IMAGE_WIDTH, '0', $image_small); } } } } closedir($big_dir); ?> ------------end php code--------------------
Recommended Posts
Archived
This topic is now archived and is closed to further replies.