Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#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:


This problem has been reported in the forums:

For information about the underlying cause:

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 Changed 5 years ago by Philip Taylor

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.

comment:2 Changed 5 years ago by Adrián Chaves

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
	convert "$file" -strip "$file" &> $temporaryFile
	if [[ -s $temporaryFile ]] ; then
		echo "Changed with reason: “$file”"
		echo "Changed without reason, reverting: “$file”"
		git checkout -- "$file"
	rm "$temporaryFile"

(replacing “git checkout -- "$file"” with “svn revert "$file"” if using the Subversion repository)

That makes the patch size 578.5 MiB.

Last edited 5 years ago by Adrián Chaves (previous) (diff)

comment:3 Changed 5 years ago by Ben Brian

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 Changed 5 years ago by leper 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 Changed 5 years ago by Adrián Chaves

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 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 Changed 5 years ago by fabio

Rather than using convert to regenerate these PNGs I suggest using optipng -o5 followed by advdef -z -4 to also recompress them better. Note that optipng can losslessly reduce depth and similar actions that may make re-editing the files different.

Last edited 5 years ago by fabio (previous) (diff)

comment:7 Changed 5 years ago by Philip Taylor

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 Changed 5 years ago by stanislas69

Component: Art & AnimationCore engine

comment:9 Changed 5 years ago by stanislas69

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")
convert $i -strip $i

comment:10 Changed 5 years ago by Adrián Chaves

Disabling the warning seems to be the way to go, as explained by Philip. Any patch on that front is welcome.

comment:11 Changed 5 years ago by stanislas69

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:12 Changed 4 years ago by ben

Owner: set to ben
Resolution: fixed
Status: newclosed

In 16350:

Suppresses libpng warning "iCCP: known incorrect sRGB profile" by manually handling warning messages (errors still use default handler), fixes #2184

comment:13 Changed 4 years ago by Ben Brian

Milestone: BacklogAlpha 18

comment:14 Changed 4 years ago by stanislas69

Didn't expect it to be that simple X)

Note: See TracTickets for help on using tickets.