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


WideImage can't save to file for unknown reason and can't output due to headers issue

当我尝试让WideImage创建缩略图时(检查它是否存在):

    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权限。同样的错误。

请求添加:

"WideImage/Mapper/JPEG.php on line 39"

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

我不应该碰lib。我尝试给文件、本地主机和远程主机提供绝对路径。没什么区别。我知道图像的路径是正确的。这就是为什么错误没有意义。

SOLVED:

违规行是这样的:

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

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