libpng warning: iCCP: known incorrect sRGB profile
Solution 1
Libpng-1.6 is more stringent about checking ICC profiles than previous versions. You can ignore the warning. To get rid of it, remove the iCCP chunk from the PNG image.
Some applications treat warnings as errors; if you are using such an application you do have to remove the chunk. You can do that with any of a variety of PNG editors such as ImageMagick's
convert in.png out.png
To remove the invalid iCCP chunk from all of the PNG files in a folder (directory), you can use mogrify
from ImageMagick:
mogrify *.png
This requires that your ImageMagick was built with libpng16. You can easily check it by running:
convert -list format | grep PNG
If you'd like to find out which files need to be fixed instead of blindly processing all of them, you can run
pngcrush -n -q *.png
where the -n
means don't rewrite the files and -q
means suppress most of the output except for warnings. Sorry, there's no option yet in pngcrush to suppress everything but the warnings.
Binary Releases of ImageMagick are here
For Android Projects (Android Studio) navigate into res
folder.
For example:
C:\{your_project_folder}\app\src\main\res\drawable-hdpi\mogrify *.png
Solution 2
Use pngcrush
to remove the incorrect sRGB profile from the png file:
pngcrush -ow -rem allb -reduce file.png
-
-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 reduction
In 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.
Solution 3
Solution
The incorrect profile could be fixed by:
- Opening the image with the incorrect profile using QPixmap::load
- Saving the image back to the disk (already with the correct profile) using QPixmap::save
Note: This solution uses the Qt Library.
Example
Here is a minimal example I have written in C++ in order to demonstrate how to implement the proposed solution:
QPixmap pixmap;
pixmap.load("badProfileImage.png");
QFile file("goodProfileImage.png");
file.open(QIODevice::WriteOnly);
pixmap.save(&file, "PNG");
The complete source code of a GUI application based on this example is available on GitHub.
UPDATE FROM 05.12.2019: The answer was and is still valid, however there was a bug in the GUI application I have shared on GitHub, causing the output image to be empty. I have just fixed it and apologise for the inconvenience!
Solution 4
You can also just fix this in photoshop...
- Open your .png file.
- File -> Save As and in the dialog that opens up uncheck "ICC Profile: sRGB IEC61966-2.1"
- Uncheck "As a Copy".
- Courageously save over your original .png.
- Move on with your life knowing that you've removed just that little bit of evil from the world.
Solution 5
To add to Glenn's great answer, here's what I did to find which files were faulty:
find . -name "*.png" -type f -print0 | xargs \
-0 pngcrush_1_8_8_w64.exe -n -q > pngError.txt 2>&1
I used the find and xargs because pngcrush could not handle lots of arguments (which were returned by **/*.png
). The -print0
and -0
is required to handle file names containing spaces.
Then search in the output for these lines: iCCP: Not recognizing known sRGB profile that has been edited
.
./Installer/Images/installer_background.png:
Total length of data found in critical chunks = 11286
pngcrush: iCCP: Not recognizing known sRGB profile that has been edited
And for each of those, run mogrify on it to fix them.
mogrify ./Installer/Images/installer_background.png
Doing this prevents having a commit changing every single png file in the repository when only a few have actually been modified. Plus it has the advantage to show exactly which files were faulty.
I tested this on Windows with a Cygwin console and a zsh shell. Thanks again to Glenn who put most of the above, I'm just adding an answer as it's usually easier to find than comments :)
Related videos on Youtube

Reza Karami
Updated on July 08, 2022Comments
-
Reza Karami 6 months
I'm trying to load a PNG image using SDL but the program doesn't work and this error appears in the console
libpng warning: iCCP: known incorrect sRGB profile
Why does this warning appear? What should I do to solve this problem?
-
Jesse W at Z - Given up on SE almost 8 years
-
Jesse W at Z - Given up on SE almost 8 years
-
-
Maxito about 8 years
-
Glenn Randers-Pehrson about 8 yearsThe -strip option will remove all profiles. If you omit the -strip option (mogrify *.png), only incorrect profiles will be deleted.
-
Andy Brice almost 7 yearsThat worked! Do do it recursively from the current folder put this in a .bat file : For /R %%i in (*.png) do PNGCRUSH.EXE -ow -rem allb -reduce %%i
-
friederbluemle almost 7 yearsAnd a one-liner for *nix to recursively fix all png files in the current directory:
find . -type f -iname '*.png' -exec pngcrush -ow -rem allb -reduce {} \;
(Tested on GNU/Linux) -
Kyle Strand over 6 yearsThis is nicely cross-platform, though if you're on a platform that supports a nice *NIX-y shell such as Zsh or Bash, you can just use
mogrify **/*.png
. -
Devan Williams over 6 yearsYeah, good point. I only used Python because we develop on Windows and Linux and wanted to commit this script to our repo for future use.
-
Uflex about 6 yearsIs there a way of finding out which file is triggering the warning? Running
mogrify **/*.png
seems to modify all files in the tree. I would prefer updating only the one faulty image. -
Quantuple almost 6 yearsI am surprised that this answer did not get upvoted. It does not require installing anything and it works... what more could one ask for :)
-
iKlsR almost 6 yearsAbove line by frieder works inside git bash on windows as well.
-
guido over 5 yearsI didn't find pngfix in the standard OS El Capitan installation (or perhaps I didn't search well enough), but I found it in the MAMP installation which I had. Worked perfectly! Thanks! Upvoted
-
Adriel Jr over 5 yearsYou are right! I installed it with "brew install libpng" a long time ago.
-
kfunk over 5 yearsThis deserves more upvotes. All the other solutions touch every file, which is especially bad if you have lots of images in a version-control system. Thanks for the script!
-
Mitch almost 5 yearsI got "n!ew ERR 08 read Undefined_error:_0 Undefined_error:_0 not_a_PNG_(too_short) car.png" when running this on 10.13.2.
-
val is still with Monica over 4 yearsUse
find . -type f -name '*.png' -execute mogrify \{\} \;
to recursively modify.png
files in current directory. -
Adriel Jr over 4 years@Mitch Still runs ok after upgrading to 10.13.6.
-
pbhj over 4 yearsI have
pngcrush 1.7.85, uses libpng 1.6.21 and zlib 1.2.8
but my pngcrush doesn't have-warn
nor-reduce
flags so this solution doesn't work. -
Gabriel Devillers about 4 yearsOn Debian, to find the files that were problematic in my software, I used
find . -name "*.png" -exec sh -c 'echo Testing {} && pngcrush -n -q {}' \;
Every erroneous PNG will generatepngcrush: iCCP: known incorrect sRGB profile
-
Pysis over 3 yearsHad the ImageMagick binaries freeze my computer, maybe from working too hard, and after leaving overnight, had to restart forcefully. Used the pngcrush application to detect the issue as mentioned,
-ow
to overwrite and fix the file, and also reduced the size by about 1/6th! Just had to get the program's source code for my mac, compile, install manually, and run it. GitHub Kjuly/pngcrush might have a precompiled binary, but not sure. Sourceforge only seemed to have Windows exe's available and the source code. friederbluemle's answer seems to do this and more. -
KeyC0de about 3 yearsPngcrush doesn't remove this chunk in my case. But imagemagick's mogrify did it.
-
MH.AI.eAgLe over 1 yearI've tested your solution but I'm getting this error: find: ‘’: No such file or directory 0 errors fixed" please guide precisely how to address the image folder.
-
Lin GU over 1 yeargreat, it works for me, thanks for sharing
-
Sunchock over 1 yearI did the trick with Photofiltre 7. Just open the image and then save as a new one over the orginal png. Works fine, thanks for the tip
-
Spencer over 1 year@Sunchock Nice. Somehow this is still my top rated answer 4 years later... Just a simple "Save".
-
Charles Duffy 9 monthsYou don't need to both use a raw string and double up backslashes -- only one or the other is required.