title: In PHP, why has imagecreatefromjpeg "not a jpeg file" changed to a fatal error?
body: <p>I've got an older piece of code that attempts to load an image file. Since it doesn't know what type it is, the code tries them all:</p>
  
  <pre><code>$res = @imagecreatefromjpeg($sourceName);
  if ( $res === false)
      $res = @imagecreatefromgif($sourceName);
  if ( $res === false)
      $res = @imagecreatefrompng($sourceName);
  if ( $res === false) {
      $err[] = 'Cannot load file as JPEG, GIF or PNG!';
  </code></pre>
  
  <p>This used to work perfectly for a long time, but after a recent server migration it stopped working when using a PNG file (JPEG files work fine). Investigation revealed that the very first line produces a fatal error:</p>
  
  <blockquote>
    <p>Fatal error: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: Not a JPEG file: starts with 0x89 0x50</p>
  </blockquote>
  
  <p>Since the line has the error-suppression operator, the script simply stopped executing and returned HTTP 200 with an empty response.</p>
  
  <p>What I don't understand is... wha... how... why... since when... huh?</p>
  
  <p>Even the <a href="http://php.net/manual/en/function.imagecreatefromjpeg.php" rel="noreferrer">official documentation</a> says that these functions return <code>FALSE</code> when unable to load a file, and the construct with the <code>@</code> operator is shown there too. I can find nothing on the web which would say that "not a JPEG file" is a fatal error. Everywhere it's mentioned, it's a warning as it always has been. Why am I getting a fatal error now?</p>
  
  <p>My PHP is 5.6.30, GD is there with everything.</p>