JPEG文件过早结束 [英] Premature end of JPEG file

查看:727
本文介绍了JPEG文件过早结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调整某些图像大小时遇到​​了JPEG文件错误的过早结束。有趣和奇怪的部分是,我只是在上传任何相机拍摄的图像时才会收到此错误,例如来自移动设备,除了那些每件事情都很棒。我认为这可能是因为plupload中使用的块大小。所以,我上传了更大尺寸的图像,有点像3mb测试。与相机拍摄图像以外的图像一起使用。因此,每当我上传相机图片时,我都会收到此错误。

I am getting this Premature end of JPEG file error while resizing some of the images. Interesting and strange part is that i am getting this error only when i upload any camera taken images, like from mobile, other than those every thing works great. I thought this could be because of the chunk size used in plupload. So, i uploaded with larger sized image to somewhat like 3mb to test. Works fine with images other than camera taken images. So, whenever i upload camera pics i get this error.

错误的进一步阐述:php函数imagecreatefromjpeg抛出错误imgname.jpg不是有效的JPEG文件。

Further elaborations on the error: php function imagecreatefromjpeg is throwing an error "imgname.jpg is not a valid JPEG file".

要调整图像大小我正在使用Codeigniter的图像操作类。

To resize images i am using Codeigniter's image Manipulation Class.

推荐答案

根据你提供的内容,我只能给你扣除。

Based on what you have provided, I can only give you my deductions.

相机图像通常非常大。我建议您尝试调整相机图像的大小,看它是否有效。

Camera images are usually very big. I suggest that you try to resize the camera images and see if it works.

您的PHP版本是什么?有一个与此相关的错误: https://bugs.php.net/bug.php ?id = 29878

What is your PHP version? There is a bug related to this: https://bugs.php.net/bug.php?id=29878

还请检查您的JPEG文件是否为RGB格式。在手册中的某处提到它无法为某些版本的GD库正确加载CMYK。

Please also check if your JPEG files are in RGB format. Somewhere in the manual mentioned that it could not properly load CMYK for certain versions of the GD library.

你是否愿意使用另一个类?我使用这个类来调整图像大小并且多年来没有遇到任何问题。

Are you open to using another class? I use this class to resize images and have not encountered any problems with it for years.

调整图像大小非常简单:

Resizing images is as easy as:

<?php
   include('SimpleImage.php');
   $image = new SimpleImage();
   $image->load('picture.jpg');
   $image->resizeToHeight(500);
   $image->save('picture2.jpg');
   $image->resizeToHeight(200);
   $image->save('picture3.jpg');
?>

如果所有建议都没有解决,你可以尝试使用 ImageMagick

If all the suggestions did not work out, you can try using ImageMagick.

这篇关于JPEG文件过早结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆