【发布时间】:2016-04-24 00:56:27
【问题描述】:
我尝试调整图像大小,但仍然出现同样的错误:
警告:imagecreatefromjpeg():gd-jpeg:JPEG 库报告不可恢复的错误:在第 18 行的 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 中
警告:imagecreatefromjpeg(): 'img/test/Bildschirmfoto 2014-01-25 um 08.05.13 nachm Kopie.jpg' 不是 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 中的有效 JPEG 文件第 18 行
警告:imagesx() 期望参数 1 是资源,布尔值在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 19 行给出
警告:imagesy() 期望参数 1 是资源,布尔值在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 20 行给出
注意:在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 24 行中遇到格式不正确的数值
注意:在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 24 行中遇到格式不正确的数值
警告:imagesx() 期望参数 1 是资源,布尔值在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 25 行给出
警告:imagesy() 期望参数 1 是资源,布尔值在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 25 行给出
警告:imagecopyresized() 期望参数 2 是资源,布尔值在 /Applications/XAMPP/xamppfiles/htdocs/dad/gallery.php 第 25 行给出
所以,这是我的代码:
function make_thumb($image_path, $thumb_path, $thumb_width) {
$src_img = imagecreatefromjpeg("$image_path");
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$new_w = $thumb_width;
$diff=$origw/$new_w;
$new_h=$new_w;
$dst_img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img, "$thumb_path");
RETURN TRUE;
}
【问题讨论】:
-
'img/test/Bildschirmfoto 2014-01-25 um 08.05.13 nachm Kopie.jpg' 不是有效的 JPEG 文件
-
哦,好吧...那是什么?