Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP exif_read_data Illegal IFD size

Tags:

php

jpeg

exif

I'm working on an application where I fix orientation (if it is present) of jpeg files downloaded from an AWS bucket.

Here you can verify that this image has exif Rotation section.

I download the image with

file_put_contents('/local/path/to/file', file_get_contents('/path/to/url/image'));

And after I try to fix orientation through the Gregwar Image library.

Image::open($path)->fixOrientation()->save($dest, $type, $quality);

I tried with several images and I always receive the message

Warning: exif_read_data('/local/path/to/file'): Illegal IFD size

I thought that was a problem related with how I retrieve the images, but I tried also with cUrl and fopen with the same result.

Someone has some advices?

like image 624
stuzzo Avatar asked May 20 '16 17:05

stuzzo


2 Answers

You can use a "@" before to ignore warnings: @Image::open($path)->fixOrientation()->save($dest, $type, $quality);

That is a lot of people complaining about this over the internet. Probably some exif data with error. If you operation is working the way you want, just document it and move on.

like image 122
Felippe Duarte Avatar answered Sep 23 '22 17:09

Felippe Duarte


PHP 5.6.2x is having a bug with its EXIF capability (see bug #72914 as well as #72819 for further info). Attempting to read EXIF data will result in one of the described errors (Illegal IFD size, IFD bad data, other).

At present (2016-11-21) there is no fix available for the 5.6 branch. There is some testing going on in branch 7.

Implement a local fix by testing for the function throwing IFD errors, and when confirmed assume EXIF to be unavailable for the duration of the script.

(You can patch that into the loader if you wish, and 'overload' the functions to return default false/0/null instead to indicate breakage)

like image 43
Kadigan.KSB Avatar answered Sep 22 '22 17:09

Kadigan.KSB