Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrisgrim's avatar

Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files

Hi, I am using image Intervention to save images and resize them. I discovered this error when trying to use my same code on my server. It worked fine locally but errored out on the server. Following instructions online I changed my memory_limit = -1 and that seemed to work. However, just today I started getting the same error in my logs

[2020-07-02 18:18:14] production.ERROR: Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. {"userId":1,"exception":"[object] (Intervention\Image\Exception\NotReadableException(code: 0): Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files. at /var/www/html/ei/vendor/intervention/image/src/Intervention/Image/Gd/Decoder.php:59)
[stacktrace]

I haven't changed any of the code and I checked the memory_limit is still -1. I am currently downloading a lot of data so I thought maybe that could be causing it, but I still don't want other users to experience this if they have limited bandwidth as well. I timed how long after I tried uploading I got the 500 error and it was 6 seconds. So I tried changing my max_execution_time = -1 and max_input_time = 60 but it still errors out after 6 seconds which seems strange to me. Can anyone see anything I am missing? I am currently trying with a 5.7 mb image file that works fine when I try to upload to my local. If I try to use a smaller image around 200k that also works fine on my server. It is only when I try to upload the big image to my server.

0 likes
8 replies
MichalOravec's avatar
Level 75

What is your image driver on localhost and what on the server.

I recommend to you use imagick as driver in the both cases.

chrisgrim's avatar

@michaloravec I installed Imagick and created a config file for image that said to use imagick. Then cleared my config cache and still I am getting the ND error. Am I missing a step?

MichalOravec's avatar

Check http://image.intervention.io/getting_started/configuration (look for Memory Settings)

If you try to resize really big image with big dimension you don't have enough memory for that.

I usually use this in validation to avoid this problems on shared hosting.

'image' => 'image|max:15360|dimensions:max_width=4000,max_height=3000'

Docs: https://laravel.com/docs/7.x/validation#rule-max and https://laravel.com/docs/7.x/validation#rule-dimensions

chrisgrim's avatar

I guess what I dont understand is that I switched my driver to imagick and yet I am still getting the

GD driver is only able to decode JPG

error in my log whenever I try to upload

chrisgrim's avatar

I have installed it on both and ran

php -r 'echo "imagick is ".(extension_loaded("imagick")?"":"not ")."installed\n";'

and it says imagick is installed

Please or to participate in this conversation.