sodascape Posted July 22, 2006 Share Posted July 22, 2006 I dont know where else to turn.... this script is supposed to read all of the images in a directory, determine if the directory has a thumbnail folder, if not, it is supposed to create one and create thumbs for all of those images and then display the images in a table until there are no more left. THe script is short, but I keep getting error messages.Warning: imagecreatetruecolor(): Invalid image dimensions in /home/christop/public_html/illustrations/read_dir.php on line 22Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/christop/public_html/illustrations/read_dir.php on line 23Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/christop/public_html/illustrations/read_dir.php on line 24./bub.jpgPlease help.---------------------------- The Script I have so far...................................................<?php// //////////////////////////////////////////////////////////////////////////////////////////////////////////function add_folder_to_directory_path($path,$foldertoadd) { $base_dir = substr($path,0,strrpos($path,"/")).$foldertoadd; //take path apart, add new folder to it. // OLD $base_dir = substr($path,0,strrpos($path,"/")).'/'.$foldertoadd; //take path apart, add new folder to it. $newpath = $base_dir . strrchr($path,"/"); // add the file name back on. return $newpath;}// //////////////////////////////////////////////////////////////////////////////////////////////////////////function createThumbnail($image){$thumbnail_path = add_folder_to_directory_path($item,"thumbs");copy($image,$thumbnail_path);$srcImg = imagecreatefromjpeg("$image");$origWidth = imagesx($srcImg);$origHeight = imagesy($srcImg);$ratio = $thumbWidth / $origWidth;$thumbHeight = $origHeight * $ratio;$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $origWidth, $origHeight);imagejpeg($thumbImg, "$thumbDirectory/$imageName");}// //////////////////////////////////////////////////////////////////////////////////////////////////////////?><?php// READ DIRECTORY, CHECK JPG EXTENTION, PUT IMAGES INTO ARRAY$path = './';if ($handle = opendir($path)) { // get all the images in there and make a pic order. while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && eregi(".jpg",$file)) { // $allpics[] = $file; // simply list all the pics in an array (without extension) for later saving $allpics[] = $path.$file; } } closedir($handle);} foreach ($allpics as $item) { $thumbnail_path = add_folder_to_directory_path($item,"thumbs"); if (!is_file($thumbnail_path)) { // if there is no file in the thumbs directory createThumbnail($item); // CREATE FUNCTION // ADD TABLE COUNTER } echo $item;} // ADDING NEW THUMBS FOLDER TO DIRECTORY$newfolder = add_folder_to_directory_path($oldfolder, "thumbs");?> Link to comment https://forums.phpfreaks.com/topic/15321-i-give-up-please-help/ Share on other sites More sharing options...
shocker-z Posted July 22, 2006 Share Posted July 22, 2006 You havn't defined $thumbWidthRegardsLiam Link to comment https://forums.phpfreaks.com/topic/15321-i-give-up-please-help/#findComment-62042 Share on other sites More sharing options...
sodascape Posted July 22, 2006 Author Share Posted July 22, 2006 I figured that would be determined by each file that is in the directory when the script reads them. Link to comment https://forums.phpfreaks.com/topic/15321-i-give-up-please-help/#findComment-62120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.