PhpThumb错误

时间:2013-05-11 09:35:32

标签: php phpthumb

尝试让phpthumb工作,但目前还有一些问题。 得到了简单的演示,所以我可能会遗漏我的功能,但却找不到:(

此函数中的变量具有以下值:

  

MYBB_ROOT = E:\瓦帕\ 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:\瓦帕\ WWW \的MyBB /图像/ topposts /缩略图/ 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在文件“phpthumb.class.php”上线   216   * setSourceData()设置$ this-&gt; rawImageData(58字节; magic =“E:\ w”(0x45 0x3a 0x5c 0x77))在第271行的文件“phpthumb.class.php”中   * 1165行文件“phpthumb.class.php”中的文件_exists()= 0   * 1166行文件“phpthumb.class.php”中的file_exists_ignoreopenbasedir()= 0   第1167行的文件“phpthumb.class.php”中的* is_file()= 0   第1168行的文件“phpthumb.class.php”中的* is_executable()= 0   * ImageMagickThumbnailToGD()中止因为无法在$ this-&gt; config_imagemagick_path()中找到转换,而which convert返回()   第1198行的文件“phpthumb.class.php”   * $ AvailableImageOutputFormats =第923行的文件“phpthumb.class.php”中的数组(text; ico; wbmp; gif; png; jpeg)   * $ this-&gt; thumbnailFormat在第934行的文件“phpthumb.class.php”中设置为$ this-&gt; config_output_format“jpeg”   * $ this-&gt; thumbnailQuality在第951行的文件“phpthumb.class.php”中设置为“75”   * ResolveSource()退出,因为$ this-&gt; rawImageData在第847行的文件“phpthumb.class.php”中设置(58字节)   * setCacheDirectory()以文件中的config_cache_directory =“E:\ wamp \ www \ mybb / inc \ plugins \ topposts \ temp \”开头   第958行的“phpthumb.class.php”   *将config_cache_directory设置为realpath(E:\ wamp \ www \ mybb \ inc \ plugins \ topposts \ temp)=   文件中的“E:\ wamp \ www \ mybb \ inc \ plugins \ topposts \ temp”   第986行的“phpthumb.class.php”   *来自文件“phpthumb.class.php”的md5($ this-&gt; rawImageData)=“9fcad44eb8ae21004afb1addf5f08404”中的SetCacheFilename()_ raw设置   第3236行   * SetCacheFilename()_ par在第3273行的文件“phpthumb.class.php”中从md5(_zcC_h100_w200_dpi150_q75)设置   *在第3035行的文件“phpthumb.class.php”中启动ExtractEXIFgetImageSize()   *跳过GetImageSize()因为$ this-&gt; sourceFilename在3047行的文件“phpthumb.class.php”中为空   *绕过EXIF和GetImageSize部分,因为设置了$ this-&gt; rawImageData,并且未设置$ this-&gt; sourceFilename,并且源图像不是   在3065行的文件“phpthumb.class.php”中,GD(x = 0MB)太大了   * SetOrientationDependantWidthHeight()以第3014行的文件“phpthumb.class.php”中的“”x“”开头   *第3030行文件“phpthumb.class.php”中的SetOrientationDependantWidthHeight()设置w =“200”,h =“100”   * exif_t​​humbnail()不存在,无法在3138行的文件“phpthumb.class.php”中提取EXIF缩略图   * EXIF缩略图提取:(size = 0; type =“”; 0x0)在3142行的文件“phpthumb.class.php”中   *在3400行的文件“phpthumb.class.php”中启动SourceImageToGD()   * ImageCreateFromStringReplacement()在第3956行的文件“phpthumb.class.php”中调用内置的ImageCreateFromString()   * SourceImageToGD.ImageCreateFromStringReplacement()失败,文件中的未知图像类型为“E:\ w”(0x45 0x3a 0x5c 0x77)   第3443行的“phpthumb.class.php”   *不使用EXIF缩略图数据,因为$ this-&gt; exif_t​​humbnail_data在第3471行的文件“phpthumb.class.php”中为空   * $ this-&gt; gdimg_source在第3523行的文件“phpthumb.class.php”中仍为空   * ImageMagickThumbnailToGD()在第3525行的文件“phpthumb.class.php”中失败   * phpThumb()v1.7.11-201108081537 http://phpthumb.sourceforge.net

     

未知图像类型由“E:\ w”(0x45 0x3a 0x5c 0x77)标识   SourceImageToGD()[3647]在3847行的文件“phpthumb.class.php”中   * SourceImageToGD()在第342行的文件“phpthumb.class.php”中失败

我已经过了5个小时(现在早上6点),我无法让它工作。任何帮助将不胜感激。

感谢 生态

1 个答案:

答案 0 :(得分: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>';
    }
}