2013-05-11 27 views
0

試圖讓phpthumb工作,但目前有點問題。 得到了簡單的演示工作,所以我可能會丟失在我的功能什麼的,只是不能老是找什麼:(PhpThumb錯誤

在這個函數的變量具有以下值:

MYBB_ROOT=E:\wamp\www\mybb/ source_url= http://www.theblaze.com/wp-content/uploads/2013/04/Screen-Shot-2013-04-29-at-7.41.26-AM.png target_file=E:\wamp\www\mybb/images/topposts/thumbnails/thumb_13863.jpg thumb_file_name=thumb_13863.jpg

function tp_createThumb($source_url,$target_file, $thumb_file_name){ 
    require_once MYBB_ROOT.'inc/plugins/topposts/phpthumb.class.php'; 
    require_once MYBB_ROOT.'inc/plugins/topposts/phpThumb.config.php'; 
    // create phpThumb object 
    $phpThumb = new phpthumb(); 
    //download file 
    echo ("URL:".$source_url); 
    downloadFile($source_url, MYBB_ROOT.'inc\\plugins\\topposts\temp\\'.$thumb_file_name);  
    // set data source -- do this first, any settings must be made AFTER this call  
    $phpThumb->setSourceData(MYBB_ROOT.'inc\\plugins\\topposts\temp\\'.$thumb_file_name); 
    echo (' source:'.MYBB_ROOT.'inc\\plugins\\topposts\temp\\'.$thumb_file_name); 
    // PLEASE NOTE: 
    // You must set any relevant config settings here. The phpThumb 
    // object mode does NOT pull any settings from phpThumb.config.php 
    // set parameters (see URL Parameters in phpthumb.readme.txt) 
    $thumbnail_width = 100; 
    $phpThumb->setParameter('w', $thumbnail_width); 
    $phpThumb->setParameter('nohotlink_enabled', 'false'); 
    $phpThumb->setParameter('config_output_format', 'jpeg'); 
    $phpThumb->setParameter('zc', "C"); 
    $phpThumb->setParameter('config_allow_src_above_docroot', true); 
    $phpThumb->setParameter('w', 200); 
    $phpThumb->setParameter('h', 100); 
    $phpThumb->setParameter('config_cache_disable_warning', true); 
    $phpThumb->setParameter('config_imagemagick_path', null); 
    $phpThumb->setParameter('config_prefer_imagemagick', false); 
    // generate & output thumbnail 
    if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! 
     if ($phpThumb->RenderToFile($output_filename)) { 
      // do something on success 
      echo 'Successfully rendered to "'.$output_filename.'"'; 
     } else { 
      // do something with debug/error messages 
      echo 'Failed bla:<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; 
     } 
     $phpThumb->purgeTempFiles(); 
    } else { 
     // do something with debug/error messages 
     echo '<form><textarea rows="25" cols="100" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>'; 
    } 
} 

這裏是輸出錯誤:。

phpThumb() v1.7.11-201108081537 in file "phpthumb.class.php" on line 216 * setSourceData() setting $this->rawImageData (58 bytes; magic="E:\w" (0x45 0x3a 0x5c 0x77)) in file "phpthumb.class.php" on line 271 * file_exists() = 0 in file "phpthumb.class.php" on line 1165 * file_exists_ignoreopenbasedir() = 0 in file "phpthumb.class.php" on line 1166 * is_file() = 0 in file "phpthumb.class.php" on line 1167 * is_executable() = 0 in file "phpthumb.class.php" on line 1168 * ImageMagickThumbnailToGD() aborting because cannot find convert in $this->config_imagemagick_path(), and which convert returned() in file "phpthumb.class.php" on line 1198 * $AvailableImageOutputFormats = array(text;ico;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 * ResolveSource() exiting because $this->rawImageData is set (58 bytes) in file "phpthumb.class.php" on line 847 * setCacheDirectory() starting with config_cache_directory = "E:\wamp\www\mybb/inc\plugins\topposts\temp\" in file "phpthumb.class.php" on line 958 * setting config_cache_directory to realpath(E:\wamp\www\mybb\inc\plugins\topposts\temp) = "E:\wamp\www\mybb\inc\plugins\topposts\temp" in file "phpthumb.class.php" on line 986 * SetCacheFilename() _raw set from md5($this->rawImageData) = "9fcad44eb8ae21004afb1addf5f08404" in file "phpthumb.class.php" on line 3236 * SetCacheFilename() _par set from md5(_zcC_h100_w200_dpi150_q75) in file "phpthumb.class.php" on line 3273 * starting ExtractEXIFgetImageSize() in file "phpthumb.class.php" on line 3035 * skipping GetImageSize() because $this->sourceFilename is empty in file "phpthumb.class.php" on line 3047 * bypassing EXIF and GetImageSize sections because $this->rawImageData is set, and $this->sourceFilename is not set, and source image is not too large for GD (x=0MB) in file "phpthumb.class.php" on line 3065 * SetOrientationDependantWidthHeight() starting with ""x"" in file "phpthumb.class.php" on line 3014 * SetOrientationDependantWidthHeight() setting w="200", h="100" in file "phpthumb.class.php" on line 3030 * exif_thumbnail() does not exist, cannot extract EXIF thumbnail in file "phpthumb.class.php" on line 3138 * 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 * ImageCreateFromStringReplacement() calling built-in ImageCreateFromString() in file "phpthumb.class.php" on line 3956 * SourceImageToGD.ImageCreateFromStringReplacement() failed with unknown image type "E:\w" (0x45 0x3a 0x5c 0x77) in file "phpthumb.class.php" on line 3443 * 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

Unknown image type identified by "E:\w" (0x45 0x3a 0x5c 0x77) in SourceImageToGD() [3647] in file "phpthumb.class.php" on line 3847 * SourceImageToGD() failed in file "phpthumb.class.php" on line 342

I`ve這個了5小時(早上6點現在),我只是無法得到它的工作任何幫助將不勝感激

感謝 生態

回答

0

設法解決它。我認爲這是相對路徑的問題。

不過這個正則表達式我m using here isn噸所有的工作時間...

unction tp_createThumb($source_url,$target_file, $thumb_file_name){ 
    require_once MYBB_ROOT.'inc/plugins/topposts/phpthumb.class.php'; 
    require_once MYBB_ROOT.'inc/plugins/topposts/phpThumb.config.php'; 

    echo(" MYBB_ROOT=".MYBB_ROOT." source_url=".$source_url." target_file=".$target_file." thumb_file_name=".$thumb_file_name); 
    // create phpThumb object 
    $phpThumb = new phpthumb(); 


    //download file 
    echo ("URL:".$source_url); 
    downloadFile($source_url, MYBB_ROOT.'inc\\plugins\\topposts\temp\\'.$thumb_file_name); 

    // set data source -- do this first, any settings must be made AFTER this call 

    $phpThumb->setSourceData(file_get_contents(MYBB_ROOT.'inc/plugins/topposts/temp/'.$thumb_file_name)); 
    //$phpThumb->setSourceData(file_get_contents(MYBB_ROOT.'inc/plugins/topposts/temp/thumb_13863.jpg')); 
    echo (' source:./topposts/temp/'.$thumb_file_name); 

    // PLEASE NOTE: 
    // You must set any relevant config settings here. The phpThumb 
    // object mode does NOT pull any settings from phpThumb.config.php 

    // set parameters (see URL Parameters in phpthumb.readme.txt) 
    $thumbnail_width = 100; 
    $phpThumb->setParameter('w', $thumbnail_width); 
    $phpThumb->setParameter('nohotlink_enabled', 'false'); 
    $phpThumb->setParameter('config_output_format', 'jpeg'); 
    $phpThumb->setParameter('zc', "C"); 
    $phpThumb->setParameter('config_allow_src_above_docroot', true); 
    $phpThumb->setParameter('w', 200); 
    $phpThumb->setParameter('h', 100); 
    $phpThumb->setParameter('config_cache_directory','./topposts/temp/'); 
    $phpThumb->setParameter('config_temp_directory', './topposts/temp/'); 
    $phpThumb->setParameter('config_cache_disable_warning', true); 
    $phpThumb->setParameter('config_cache_disable_warning', true); 
    $phpThumb->setParameter('config_imagemagick_path', null); 
    $phpThumb->setParameter('config_prefer_imagemagick', false); 



    // generate & output thumbnail 
    if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! 
     if ($phpThumb->RenderToFile($target_file)) { 
      // do something on success 
      echo 'Successfully rendered to "'.$target_file.'"'; 
     } else { 
      // do something with debug/error messages 
      echo 'Failed bla:<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; 
     } 
     $phpThumb->purgeTempFiles(); 
    } else { 
     // do something with debug/error messages 
     echo '<form><textarea rows="55" cols="120" wrap="off">'.htmlentities(implode("\n* ", $phpThumb->debugmessages)).'</textarea></form><hr>'; 
    } 
}