title: PHP exif_read_data Illegal IFD size
body: <p>I'm working on an application where I fix orientation (if it is present) of jpeg files downloaded from an AWS bucket.</p>
  
  <p><a href="http://regex.info/exif.cgi?imgurl=https://s3.amazonaws.com/premise-mike/894dfa36-621f-4fdc-abf5-a29e1b4ae70e.jpg">Here</a> you can verify that this image has exif Rotation section.</p>
  
  <p>I download the image with</p>
  
  <pre><code>file_put_contents('/local/path/to/file', file_get_contents('/path/to/url/image'));
  </code></pre>
  
  <p>And after I try to fix orientation through the <a href="https://github.com/Gregwar/Image">Gregwar Image library</a>.</p>
  
  <pre><code>Image::open($path)-&gt;fixOrientation()-&gt;save($dest, $type, $quality);
  </code></pre>
  
  <p>I tried with several images and I always receive the message</p>
  
  <pre><code>Warning: exif_read_data('/local/path/to/file'): Illegal IFD size
  </code></pre>
  
  <p>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.</p>
  
  <p>Someone has some advices?</p>