NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ
for more details.
While updating code my my travelblog.ws
project I came across an issue where I was not able to upload certain JPEG
files to the blog and have them automatically scaled down for thumbnail generation. The files opened fine on my Mac
would not load them.
This was the kind of error I was getting...
I wasn't exactly sure what that meant but since these files were loadable on my Mac
there had to be a way to get them loaded via GD
too, and I found it. There was a runtime configuration
documentation page for the PHP GD
library that described an INI
parameter that could be set that would make GD
ignore warnings while loading JPEGs
. After setting the gd.jpeg_ignore_warning
parameter to 1
I was able to load these seemingly 'corrupted' JPEGs
Here's the code I used to set the parameter. I placed this right before any of the calls to the GD
Interestingly from version 7.1 of PHP, the documentation says this - The default of gd.jpeg_ignore_warning has been changed from 0 to 1.
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
If you spot something out of place, please do let me know.
All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle).
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...