title: imagecreatefromjpeg() - Invalid SOS parameters for sequential JPEG
body: <p>I can't upload image with codeigniter and get following error.</p>
  
  <blockquote>
    <p><strong>A PHP Error was encountered</strong><br> Severity: Warning<br> Message:
    imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Invalid
    SOS parameters for sequential JPEG<br> Filename:
    libraries/Image_lib.php<br> Line Number: 1455 <p> <strong>A PHP Error was
    encountered</strong><br> Severity: Warning<br> Message: imagecreatefromjpeg():
    '/home/gsgsadh/public_html/uploads/a31d12f51b36659f5456e2530237e779.jpg'
    is not a valid JPEG file<br> Filename: libraries/Image_lib.php<br>
    Line Number: 1455<br></p>
  </blockquote>
  
  <p>function <code>image_create_gd</code> at <strong>application/libraries/MY_Image_lib.php</strong></p>
  
  <pre><code>public function image_create_gd($path = '', $image_type = '')
  {
      if ($path === '')
      {
          $path = $this-&gt;full_src_path;
      }
  
      if ($image_type === '')
      {
          $image_type = $this-&gt;image_type;
      }
  
      switch ($image_type)
      {
          case 1:
              if ( ! function_exists('imagecreatefromgif'))
              {
                  $this-&gt;set_error(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
                  return FALSE;
              }
  
              return imagecreatefromgif($path);
          case 2:
              if ( ! function_exists('imagecreatefromjpeg'))
              {
                  $this-&gt;set_error(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
                  return FALSE;
              }
  
  /*No.1455*/  return imagecreatefromjpeg($path); //****Line number is 1455****
          case 3:
              if ( ! function_exists('imagecreatefrompng'))
              {
                  $this-&gt;set_error(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
                  return FALSE;
              }
  
              return imagecreatefrompng($path);
          default:
              $this-&gt;set_error(array('imglib_unsupported_imagecreate'));
              return FALSE;
      }
  }
  </code></pre>
  
  <p>what's the solution? How to change the code?</p>