dongzhunqiu4841 2013-05-11 09:35
浏览 55

PhpThumb错误

Trying to get phpthumb to work, but with a bit of issue at the moment. Got the simple demo to work, so I might be missing something on my function, but just can`t find what :(

The variables in this function have the following values:

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("

", $phpThumb->debugmessages).'</pre>';
        }
        $phpThumb->purgeTempFiles();
    } else {
        // do something with debug/error messages
        echo '<form><textarea rows="25" cols="100" wrap="off">'.htmlentities(implode("
* ", $phpThumb->debugmessages)).'</textarea></form><hr>';
    }
}

And here is the output error:

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 been over this for 5 hours (6am right now) and I just can't get it to work. Any help will be greatly appreciated.

thanks Eco

  • 写回答

1条回答 默认 最新

  • douping3891 2013-05-12 05:51
    关注

    managed to fix it. I think it was some issue with the relative paths.

    Still this regexp Im using here isnt working all the time...

    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("
    
    ", $phpThumb->debugmessages).'</pre>';
            }
            $phpThumb->purgeTempFiles();
        } else {
            // do something with debug/error messages
            echo '<form><textarea rows="55" cols="120" wrap="off">'.htmlentities(implode("
    * ", $phpThumb->debugmessages)).'</textarea></form><hr>';
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器