0

试图让 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 在第 216 行的文件“phpthumb.class.php”中 * setSourceData() 设置 $this->rawImageData (58 bytes; magic="E:\w" (0x45 0x3a 0x5c 0x77))第 271 行的文件“phpthumb.class.php” * 第 1165 行的文件“phpthumb.class.php”中的 file_exists() = 0 * 第 1166 行的文件“phpthumb.class.php”中的 file_exists_ignoreopenbasedir() = 0 * is_file( ) = 0 在第 1167 行的文件“phpthumb.class.php”中 * is_executable() = 0 在第 1168 行的文件“phpthumb.class.php”中 * ImageMagickThumbnailToGD() 中止,因为在 $this->config_imagemagick_path () 中找不到转换, 和which convert在第 1198 行的文件“phpthumb.class.php”中返回 () * $AvailableImageOutputFormats = 第 923 行的文件“phpthumb.class.php”中的数组(text;ico;wbmp;gif;png;jpeg) * $this-> thumbnailFormat 在第 934 行的文件“phpthumb.class.php”中设置为 $this->config_output_format “jpeg” * 在第 951 行的文件“phpthumb.class.php”中 $this->thumbnailQuality 设置为“75” * ResolveSource()退出,因为 $this->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” 在文件 “phpthumb.class.php” 中的第 986 行 * SetCacheFilename() _raw set from md5($this->rawImageData) = “9fcad44eb8ae21004afb1addf5f08404” 在文件 “phpthumb” .class.php" 在第 3236 行 * SetCacheFilename() _par 从 md5(_zcC_h100_w200_dpi150_q75) 设置在第 3273 行的文件 "phpthumb.class.php" * 在第 3035 行的文件 "phpthumb.class.php" 中开始 ExtractEXIFgetImageSize() * 跳过GetImageSize() 因为 $this->sourceFilename 在第 3047 行的文件“phpthumb.class.php”中为空 * 绕过 EXIF 和 GetImageSize 部分,因为设置了 $this->rawImageData,并且未设置 $this->sourceFilename,并且源文件“phpthumb.class.php”中的 GD (x=0MB) 图像不是太大在第 3065 行 * SetOrientationDependantWidthHeight() 在文件 "phpthumb.class.php" 中以 ""x"" 开头 在第 3014 行 * SetOrientationDependantWidthHeight() 在文件 "phpthumb.class.php" 中设置 w="200", h="100" " 在第 3030 行 * exif_t​​humbnail() 不存在,无法在第 3138 行的文件 "phpthumb.class.php" 中提取 EXIF 缩略图 * EXIF 缩略图提取: (size=0; type=""; 0x0) 在文件 "phpthumb. class.php”在第 3142 行 * 在第 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->exif_t​​humbnail_data 在第 3471 行的文件“phpthumb.class.php”中为空 * $this->gdimg_source在第 3523 行的文件“phpthumb.class.php”中仍然为空 * ImageMagickThumbnailToGD() 在第 3525 行的文件“phpthumb.class.php”中失败 * phpThumb() v1.7.11-201108081537http://phpthumb.sourceforge.net

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

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

感谢生态

4

1 回答 1

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>';
    }
}
于 2013-05-12T05:51:27.783 回答