#2184 closed defect (fixed)
[STEPS TO FIX] libpng warning: iCCP: known incorrect sRGB profile
Reported by: | Adrián Chaves | Owned by: | ben |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 18 |
Component: | Core engine | Keywords: | libpng |
Cc: | Patch: |
Description
This problem has been reported in the forums: http://www.wildfiregames.com/forum/index.php?showtopic=17664&hl=srgb#entry275716
For information about the underlying cause: https://wiki.archlinux.org/index.php/Libpng_errors
I’m not providing a patch as it would be a 1.3 GiB patch. However, I can provide you with a command-line to fix it. Run this on a Linux box with Image Magick installed (provides the “convert” command):
find . -name "*.png" -print0 | while read -d $'\0' file; do convert "$file" -strip "$file"; done
As a side effect, affected images will see its size slightly reduced (0-2%).
Change History (14)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Something like this can be used instead, that reverts files that did not throw error messages during the conversion:
find . -name "*.png" -print0 | \ while read -d $'\0' file do temporaryFile="$file.asdf.tmp" convert "$file" -strip "$file" &> $temporaryFile if [[ -s $temporaryFile ]] ; then echo "Changed with reason: “$file”" else echo "Changed without reason, reverting: “$file”" git checkout -- "$file" fi rm "$temporaryFile" done
(replacing “git checkout -- "$file"” with “svn revert "$file"” if using the Subversion repository)
That makes the patch size 578.5 MiB.
comment:3 by , 11 years ago
That looks like an ugly hack, isn't there a command that can check for the invalid data and then we can convert it if needed?
Related concern: how do we keep people from saving PNGs like this in the future, is some particular program/settings at fault?
comment:4 by , 11 years ago
https://gist.github.com/leper/6844238 for a list of files with incorrect sRGB profiles as of r13947.
Use find . -name '*.png' -exec identify {} \; 1>/dev/null 2>files
to generate.
comment:5 by , 11 years ago
how do we keep people from saving PNGs like this in the future, is some particular program/settings at fault?
I think this is the most important question. We can safely hide the warning for now, but sooner or latter this might become an actual issue, so we must ensure that new images do not throw this warning anymore.
Judging by what https://wiki.archlinux.org/index.php/Libpng_errors says, I would say that it is possible that some Photoshop setting is responsible for this.
In any case, I suggest asking artists to open some of their next PNG files with GIMP as described in the Arch wiki before they upload them to the repositories, to check whether the generated PNG is OK or not. If it is not, the artist should try to find out what setting in PhotoShop (or any other tool) produces the error, so that we can provide steps in the documentation for reference (for other art contributors).
comment:6 by , 11 years ago
comment:7 by , 11 years ago
I don't think there's any chance this will cause any real problems in the future (we don't care about the colour profile data at all, so it's fine if those chunks get skipped, and libpng isn't going to start refusing to load those files entirely since that would break the world). Given the amount of files affected, it's not worth the disk space cost of converting the existing ones (especially since moving to Git means every user would have to bear that cost forever). So we should just suppress that warning from libpng and not change anything else.
comment:8 by , 10 years ago
Component: | Art & Animation → Core engine |
---|
comment:9 by , 10 years ago
I have read other solutions.
The newest libpng update (1.6.2 I believe?) has stricter rules about iCCP and will print this warning every time it finds a png that is broken. This warning can be ignored. Fixes would include:
- Downgrade to a older version of libpng
- Install imagemagick and convert all .png files with convert -strip (script below)
- Maybe even just disable this warning?
In the end this is a problem that should be fixed by the maintainer of the code.
Script that would change all .png files (but you can alter the path in find)
for i in $(find / -type f -name "*.png") do convert $i -strip $i done
comment:10 by , 10 years ago
Disabling the warning seems to be the way to go, as explained by Philip. Any patch on that front is welcome.
comment:11 by , 10 years ago
I have looked for a solution on Google and was not able to find a fix. Do you want me to look for one again ? I won't be able to make it myself, but that may help if someone wants to work on it :)
comment:13 by , 9 years ago
Milestone: | Backlog → Alpha 18 |
---|
Running that command over all the .png files would not be good, since most of them probably don't have this problem and it'll just waste a huge amount of space in the SVN repository - we need some way to find exactly which of the .png files have this problem and only strip those ones.