Search code examples
phplaravelintervention

Intervention with Laravel - Unsupported image type provided with JPG


I am building a Laravel app and am using Intervention with GD to do image manipulation.

When I tried to upload a JPG image to my controller, the following error occurred with a Whoops error screen:

Intervention\Image\Exception\NotReadableException: Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. in file /var/www/html/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php on line 57

Stack trace:

  1. Intervention\Image\Exception\NotReadableException->() /var/www/html/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:57
Files:

file    
array:5 [
  "name" => "matt-thomason-735925-unsplash.jpg"
  "type" => ""
  "tmp_name" => ""
  "error" => 1
  "size" => 0
]

...
HTTP_ACCEPT_ENCODING    "gzip, deflate"
CONTENT_TYPE    "multipart/form-data; boundary=--------------------------023031476826032436071549"
CONTENT_LENGTH  "2947672"
...

From the content length, since I know my file was ~2.9MB, so it was around the full size of the image.

So I ran the file through the Linux file command to see whether the .jpg extension was fake, but this is the result:

$ file ./matt-thomason-735925-unsplash.jpg
./matt-thomason-735925-unsplash.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 4032x3024, frames 3

Here is the image source: https://unsplash.com/photos/YBLvEQ6npQo

Why is there a problem with this image and what are the possible causes? Could it be that the file was somehow corrupted when the server tries to read it?


Solution

  • It was my fault. The file exceeded the maximum size. I needed to change my php.ini to increase the max filesize as well as max post size.