0

当我尝试让 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。同样的错误。

要求的补充:

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

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

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

4

1 回答 1

1

解决了:

违规行是这样的:

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

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

于 2013-01-08T11:47:20.253 回答