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.
Hope you found this post useful...
...so please read on! I love writing articles that provide beneficial information,
tips and examples to my readers. All information on my blog is provided free of
charge and I encourage you to share it as you wish. There is a small favour I ask in return however -
engage in comments below, provide feedback, and if you see mistakes let me know.
If you want to show additional support and help me pay for web hosting and
domain name registration,
donations, no matter how small, are always welcome!
Use of any information contained in this blog post/article is subject to this disclaimer
Other posts you may like...