我有同样的错误。但现在我解决了同样的问题。
答案是:我们正在上传 png 并将其转换为 jpg 。
请检查 jpg 是否有效。我们需要将 png 转换为 jpg 以便其他功能可用,请检查相同。
下面的代码对于使用 GD 库转换图像很有用。
//variable declare or parameter use
$originalImage ="1.jpg";
$quality=100; // for jpg good quality
$outputImage; //for source file save.
// jpg, png, gif or bmp?
$exploded = explode('.',$originalImage);
$ext = $exploded[count($exploded) - 1];
if (preg_match('/jpg|jpeg/i',$ext))
$imageTmp=imagecreatefromjpeg($originalImage);
else if (preg_match('/png/i',$ext))
$imageTmp=imagecreatefrompng($originalImage);
else if (preg_match('/gif/i',$ext))
$imageTmp=imagecreatefromgif($originalImage);
else if (preg_match('/bmp/i',$ext))
$imageTmp=imagecreatefrombmp($originalImage);
else
return 0;
// quality is a value from 0 (worst) to 100 (best)
imagejpeg($imageTmp, $outputImage, $quality);
imagedestroy($imageTmp);