Reputation: 21
i built an upload page that lets me upload images and i came onto this error when uploaded a file with an extension of jpg.
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]:
gd-jpeg, libjpeg: recoverable error: Premature end of JPEG
after playing with it i noticed that not even photoshop can open it. the file is corrupt. I then tried to upload it into facebook and facebook was able to accept it. it is weird how imaagecreatefromjpeg() in php wont accept this jpeg but facebook does. wonder what their using... but is it possible to force this image as a jpeg?
Upvotes: 0
Views: 144
Reputation: 48887
You'll notice that this is a recoverable error. You can ignore this error and GD should continue by setting:
ini_set('gd.jpeg_ignore_warning', 1);
at the top of your script.
http://php.net/manual/en/image.configuration.php
As an aside, you should always ensure that scripts dealing with image manipulation have a high enough memory limit.
Upvotes: 1