WideImage由于未知原因无法保存到文件,并且由于标题问题而无法输出

时间:2013-01-08 11:28:23

标签: php image

当我尝试让WideImage创建thumnail(在检查它是否存在之后):

    public function printSummaryArticle($article, $copy) {
    // create a thumbnail for the image as per the row data if one does not exist
    if (!file_exists('/images/articles/thumbs/th_' . $article['image'])) {
        $image_handle = imagecreatefromjpeg(Config::getAbsPath() . '/images/articles/' . $article['image']);
        // WideImage plugin
        WideImage::load($image_handle)->resize(300, 200)->saveToFile(Config::getAbsPath() . '/images/articles/thumbs/th_' . $article['image']);
    }
    // echo the thumbnail just created
    echo
        '<div class="summary_article"><img src="/images/articles/thumbs/th_'
        . $article['image']
        . '">';
}

我收到以下错误:

Warning: imagejpeg(/images/articles/thumbs/th_037.jpg): failed to open stream: No such file or directory in /home2/obmonco1/public_html/gulfinsight/lib/omc_frmwrk/plugins/WideImage/Mapper/JPEG.php on line 39

Fatal error: Uncaught exception 'WideImage_UnknownErrorWhileMappingException' with message 'WideImage_Mapper_JPEG returned an invalid result while saving to /images/articles/thumbs/th_037.jpg' in /home2/obmonco1/public_html/gulfinsight/lib/omc_frmwrk/plugins/WideImage/Image.php:164 Stack trace: #0 /home2/obmonco1/public_html/gulfinsight/lib/omc_frmwrk/bespoke/DisplayEngine.php(181): WideImage_Image->saveToFile('/images/article...') #1 /home2/obmonco1/public_html/gulfinsight/lib/omc_frmwrk/bespoke/PageTemplate.php(70): DisplayEngine->printSummaryArticle(Array, Object(GetCopy)) #2 /home2/obmonco1/public_html/gulfinsight/index.php(100): PageTemplate->homePage() #3 {main} thrown in /home2/obmonco1/public_html/gulfinsight/lib/omc_frmwrk/plugins/WideImage/Image.php on line 164

我必须使用绝对路径,但无论是否有路径的“根”部分( Config :: getAbsPath())都无法使用。 我也尝试过直接访问图像,而不是首先创建图像处理程序,如上所示。

当我尝试使用输出方法直接输出图像时:

    public function printSummaryArticle($article, $copy) {
    // create a thumbnail for the image as per the row data if one does not exist
    if (!file_exists('/images/articles/thumbs/th_' . $article['image'])) {
        $image_handle = imagecreatefromjpeg(Config::getAbsPath() . '/images/articles/' . $article['image']);
        // WideImage plugin
        WideImage::load($image_handle)->resize(300, 200)->output('jpeg');
    }
    // echo the thumbnail just created
    echo
        '<div class="summary_article"><img src="/images/articles/thumbs/th_'
        . $article['image']
        . '">';
}

我收到以下错误:

Warning: Cannot modify header information - headers already sent by (output started at D:\Open Media Collective\Projects\Gulf Insight\web\publish\lib\omc_frmwrk\bespoke\DisplayEngine.php:130) in D:\Open Media Collective\Projects\Gulf Insight\web\publish\lib\omc_frmwrk\plugins\WideImage\Image.php on line 198

其后是图像的二进制数据

我已经打开并检查了每个php文件,我必须在打开 - 关闭php标签之前和之后查找空格。我宁愿不使用输出缓冲区。

编辑:忘记提及,我已为图像,文章和拇指文件夹设置了777的权限。同样的错误。

请求添加:

第39行的“WideImage / Mapper / JPEG.php”

    return imagejpeg($handle, $uri, $quality);

我不应该触摸lib。我尝试给文件,localhost和远程主机提供绝对路径。没有区别。我知道图像的路径是正确的。这就是错误没有意义的原因。

1 个答案:

答案 0 :(得分:0)

解决:

违规行是:

WideImage::load($image_handle)->resize(300, 200)->saveToFile('/images/articles/thumbs/th_' . $article['image']);

我必须在这里使用完整路径(包括root:Config :: getAbsPath()),而不仅仅是在图像处理程序中。