我在根文件夹中安装了wordpress,
直到昨天它还工作得很好,但今天它给出了下面的错误,我猜是生成缩略图,
Warning: imagejpeg() [function:imagejpeg]: gd-jpeg: JPEG library reports unrecoverable error: in public_html/wp-includes/media.php on line 459有没有人知道这个警告??
请帮帮我
以下代码位于第459行
if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )发布于 2012-05-20 03:17:54
1)检查disk中的空间
您的系统必须有足够的磁盘空间
2)检查内存限制
在你的php中设置更多的内存:
ini_set("memory_limit","256M");3)检查post_max_size和upload_max_filesize
在htaccess文件中设置更多:
php_value post_max_size 16M
php_value upload_max_filesize 6M4)在函数前面加上@
@imagejpeg(..............);第1点)对我有效。
发布于 2014-01-10 21:20:29
您可能试图从非jpeg的jpeg创建映像。
当我在PHP中测试缩略图脚本时,我得到了同样的错误。然后,我发现我的输入文件头是png,尽管它的扩展名是.jpg。
因此,我编辑了我的脚本,以便如果在从jpeg创建图像时出现错误,它将尝试从png创建图像(如果发生其他错误,则尝试从gif创建图像)。
发布于 2017-06-14 15:08:34
您必须使用函数来正确确定图像的mime类型。具有jpg扩展名的png图像将导致此错误。
为了避免这个错误,你必须获取图片的correct mime type。
function getImage($path) {
switch(mime_content_type($path)) {
case 'image/png':
$img = imagecreatefrompng($path);
break;
case 'image/gif':
$img = imagecreatefromgif($path);
break;
case 'image/jpeg':
$img = imagecreatefromjpeg($path);
break;
case 'image/bmp':
$img = imagecreatefrombmp($path);
break;
default:
$img = null;
}
return $img;
}https://stackoverflow.com/questions/10611883
复制相似问题