I'm trying to load a PNG file using SDL but the program doesn't work and this error appears in the console
"libpng warning: iCCP: known incorrect sRGB profile"
Why this warning appears? what should I do to solve this problem?
I'm trying to load a PNG file using SDL but the program doesn't work and this error appears in the console
"libpng warning: iCCP: known incorrect sRGB profile"
Why this warning appears? what should I do to solve this problem?
Here is a ridiculously brute force answer:
I modified the gradlew script. Here is my new exec command at the end of the file in the
You can also just fix this in photoshop... I've got CC2015 but I'm sure this is the same for all versions.
Thanks to the fantastic answer from Glenn, I used ImageMagik's "mogrify *.png" functionality. However, I had images buried in sub-folders, so I used this simple Python script to apply this to all images in all sub-folders and thought it might help others:
Use
pngcrush
to remove the incorrect sRGB profile from the png file:-ow
will overwrite the input file-rem allb
will remove all ancillary chunks except tRNS and gAMA-reduce
does lossless color-type or bit-depth reductionIn the console output you should see
Removed the sRGB chunk.
, and possibly more messages about chunk removals. You will end up with a smaller, optimized png file. As the command will overwrite the original file, make sure to create a backup or use version control.There is an easier way to fix this issue with Mac OS with Homebrew:
or to do it with every file in the current directory:
It will create a fixed copy for each png file in the current directory and put it in the the tmp subdirectory. After that, if everything is OK, you just need to override the original files.
Another tip is to use the Keynote and Preview applications to create the icons. I draw them using Keynote, in the size of about 120x120 pixels, over a slide with a white background (the option to make polygons editable is great!). Before exporting to Preview, I draw a rectangle around the icon (without any fill or shadow, just the outline, with the size of about 135x135) and copy everything to the clipboard. After that, you just need to open it with the Preview tool using "New from Clipboard", select a 128x128 pixels area around the icon, copy, use "New from Clipboard" again, and export it to PNG. You won't need to run the pngfix tool.
Using IrfanView image viewer in Windows, I simply resaved the PNG image and that corrected the problem.