求救:老师遇到问题:Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:
Warning: imagecreatefromjpeg(): '1.jpg' is not a valid JPEG file in
( ! ) Warning: imagejpeg() expects parameter 1 to be resource, boolean given in
运行第一个测试时遇到这几个提示,是因为php版本太高的原因吗?
代码如下,我检查过一遍并没有检查出来问题:
<?php $filename="1.jpg"; $src_image=imagecreatefromjpeg($filename); list($src_w,$src_h)=getimagesize($filename); $scale=0.5; $dst_w=ceil($src_w*$scale); $dst_h=ceil($src_h*$scale); $dst_image=imagecreatetruecolor($dst_w, $dst_h); imagecopyresampled($dst_image, $src_image, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h); header("content-type:image/jpeg"); imagejpeg($dst_image); imagedestroy($src_image); imagedestroy($dst_image);