当我尝试让 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 第 39 行”
return imagejpeg($handle, $uri, $quality);
不过我不应该碰这个库。我尝试给出文件、本地主机和远程主机的绝对路径。没有什么区别。我知道图像的路径是正确的。这就是为什么这个错误没有意义。
已解决:
违规行是这样的:
WideImage::load($image_handle)->resize(300, 200)->saveToFile('/images/articles/thumbs/th_' . $article['image']);
即使在这里,我也必须使用完整路径(包括根:Config::getAbsPath()),而不仅仅是在图像处理程序中。
这可能是由于错误的文件夹权限造成的。就我而言,我需要将
775
提供给 photos
文件夹中的图像文件夹:
chmod -R 775 photos/*