2012-05-30 44 views
0

我花了整整一天的時間,無法弄清楚我要出錯的地方。phpThumb圖像調整大小錯誤

我正在嘗試調整一些圖像的大小,然後將它們寫入文件夾,以便它們可以被壓縮和下載。

當使用phpThumb Demo - > phpThumb.demo.object.php時,我可以調整圖像大小,重命名並保存到另一個目錄。這是因爲源圖像,phpThumb類和最終圖像目標目錄都在同一個文件夾中。

但是,我現在已經改變了目錄結構,所以phpThumb.class.php文件被從管理子域中調用,圖像需要從圖像子域中抓取,然後保存到圖像中的目錄或管理域名,以便稍後可以讓他們寫入ZIP文件。

我只是一直在收到錯誤,無法確定從哪裏出發。誰能幫忙?

這裏是PHP:

require_once('../phpThumb/phpthumb.class.php'); 

// create phpThumb object 
$phpThumb = new phpThumb(); 

// create 3 sizes of thumbnail 
$thumbnail_widths = array(160, 320, 1000); 
$capture_raw_data = false; // set to true to insert to database rather than render to screen or file (see below) 
foreach ($thumbnail_widths as $thumbnail_width) { 

    // this is very important when using a single object to process multiple images 
    $phpThumb->resetObject(); 

    // set data source -- do this first, any settings must be made AFTER this call 
    $phpThumb->setSourceFilename('/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg'); 

    // PLEASE NOTE: 
    // You must set any relevant config settings here. The phpThumb 
    // object mode does NOT pull any settings from phpThumb.config.php 
    $phpThumb->setParameter('config_document_root', '/home/server/domains/images.testdomain.co.uk/public_html/'); 
    $phpThumb->setParameter('config_cache_directory', '/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache/');  

    $phpThumb->setParameter('w', $thumbnail_width); 

    // set options (see phpThumb.config.php) 
    // here you must preface each option with "config_" 
    $phpThumb->setParameter('config_output_format', 'jpg'); 
    $phpThumb->setParameter('config_imagemagick_path', '/usr/local/bin/convert'); 

    // generate & output thumbnail 
    $output_filename = 'zip_temp/_'.$thumbnail_width.'.'.$phpThumb->config_output_format; 
    echo $output_filename; 
    if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! 
     $output_size_x = ImageSX($phpThumb->gdimg_output); 
     $output_size_y = ImageSY($phpThumb->gdimg_output); 
     if ($output_filename || $capture_raw_data) { 
      if ($capture_raw_data && $phpThumb->RenderOutput()) { 
       // RenderOutput renders the thumbnail data to $phpThumb->outputImageData, not to a file or the browser 
       //mysql_query("INSERT INTO `table` (`thumbnail`) VALUES ('".mysql_escape_string($phpThumb->outputImageData)."') WHERE (`id` = '".$id."')"); 
      } elseif ($phpThumb->RenderToFile($output_filename)) { 
       // do something on success 
       echo 'Successfully rendered:<br><img src="http://images.testdomain.co.uk/zip_temp/'.$output_filename.'">'; 
      } else { 
       // do something with debug/error messages 
       echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; 
      } 
      $phpThumb->purgeTempFiles(); 
     } else { 
      $phpThumb->OutputThumbnail(); 
     } 
    } else { 
     // do something with debug/error messages 
     echo 'Failed (size='.$thumbnail_width.').<br>'; 
     echo '<div style="background-color:#FFEEDD; font-weight: bold; padding: 10px;">'.$phpThumb->fatalerror.'</div>'; 
     echo '<form><textarea rows="10" cols="60" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>'; 
    } 

} 

和這裏的錯誤:

phpThumb() v1.7.11-201108081537 in file "phpthumb.class.php" on line 216 
* phpThumb() v1.7.11-201108081537 in file "phpthumb.class.php" on line 216 
* setSourceFilename(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) set $this->sourceFilename to "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" in file "phpthumb.class.php" on line 262 
* Leaving $this->config_imagemagick_path as (/usr/local/bin/convert) because !is_execuatable(realpath($this->config_imagemagick_path))() in file "phpthumb.class.php" on line 1162 
*     file_exists(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1165 
* file_exists_ignoreopenbasedir(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1166 
*      is_file(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1167 
*     is_executable(/usr/local/bin/convert) = 0 in file "phpthumb.class.php" on line 1168 
* ImageMagickThumbnailToGD() aborting because cannot find convert in $this->config_imagemagick_path (/usr/local/bin/convert), and `which convert` returned (which: no convert in (/bin:/usr/bin)) in file "phpthumb.class.php" on line 1198 
* $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;png;jpeg) in file "phpthumb.class.php" on line 923 
* $this->thumbnailFormat set to $this->config_output_format "jpeg" in file "phpthumb.class.php" on line 934 
* $this->thumbnailQuality set to "75" in file "phpthumb.class.php" on line 951 
* ResolveFilenameToAbsolute() NOT prepending $this->config_document_root (/home/server/domains/images.testdomain.co.uk/public_html/) to $filename (/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) resulting in ($AbsoluteFilename = "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg") in file "phpthumb.class.php" on line 1060 
* $this->sourceFilename set to "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" in file "phpthumb.class.php" on line 852 
* phpThumb() v1.7.11-201108081537 
http://phpthumb.sourceforge.net 

Error messages disabled in file "phpthumb.class.php" on line 3847 
* setCacheDirectory() starting with config_cache_directory = "/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache/" in file "phpthumb.class.php" on line 958 
* setting config_cache_directory to realpath(/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache) = "/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache" in file "phpthumb.class.php" on line 986 
* $this->config_cache_directory is not writable (/home/server/domains/images.testdomain.co.uk/public_html/phpThumb/cache) in file "phpthumb.class.php" on line 997 
* SetCacheFilename() _src set from md5($this->sourceFilename) "/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg" = "688d3d8dc707794f27b6ef6db51ee9a2" in file "phpthumb.class.php" on line 3240 
* SetCacheFilename() _par set from md5(_w160_dpi150_q75) in file "phpthumb.class.php" on line 3273 
* starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 3035 
* GetImageSize(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) says image is x in file "phpthumb.class.php" on line 3045 
* GetImageSize("/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg") failed in file "phpthumb.class.php" on line 3078 
* $this->useRawIMoutput=true after checking $UnAllowedParameters in file "phpthumb.class.php" on line 1315 
* ImageMagickThumbnailToGD() aborting because ImageMagickCommandlineBase() failed in file "phpthumb.class.php" on line 2006 
* ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3085 
* SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 3014 
* SetOrientationDependantWidthHeight() setting w="160", h="0" in file "phpthumb.class.php" on line 3030 
* EXIF thumbnail extraction: (size=0; type=""; 0x0) in file "phpthumb.class.php" on line 3142 
* starting SourceImageToGD() in file "phpthumb.class.php" on line 3400 
* starting ImageCreateFromFilename(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) in file "phpthumb.class.php" on line 3315 
* empty $filename or GetImageSize(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) failed in file "phpthumb.class.php" on line 3364 
* Populating $rawimagedata in file "phpthumb.class.php" on line 3372 
* cannot fopen(/home/server/domains/images.testdomain.co.uk/public_html/high-res/CM015585.jpg) in file "phpthumb.class.php" on line 3383 
* Not using EXIF thumbnail data because $this->exif_thumbnail_data is empty in file "phpthumb.class.php" on line 3471 
* $this->gdimg_source is still empty in file "phpthumb.class.php" on line 3523 
* ImageMagickThumbnailToGD() failed in file "phpthumb.class.php" on line 3525 
* phpThumb() v1.7.11-201108081537 
http://phpthumb.sourceforge.net 

Error messages disabled in file "phpthumb.class.php" on line 3847 
* SourceImageToGD() failed in file "phpthumb.class.php" on line 342 

回答

0

打開文件phpthumb/phpthumb.class.php和變線141:

var $config_disable_debug = true; 

var $config_disable_debug = false; 

重新訪問原始頁面,這次應該出現實際的錯誤信息