Home qt warning: libpng warning: iCCP: known incorrect sRGB profile

warning: libpng warning: iCCP: known incorrect sRGB profile




I got a warning when assembling:

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB

Why does this warning appear? What should I do to fix this problem ??

The question is translated from English but honestly tell me liked it and I myself faced such a problem.

Answer 1, authority 100%

ibpng-1.6 checks ICC profiles more stringently than the previous ones. You can ignore the warning. To get rid of it, remove the iCCP chunk from the PNG image.

Some applications (in my case OpenGL) treat warnings as errors; if you are using such an application, you need to remove the iCCP chunk from the PNG image. This can be done using any of the many PNG editors (in truth, standard paint in windows was not possible for me). Example ImageMagick’s editor: convert in.png out.png.

To remove a defective chunk (iCCP) from all PNG files in the directory, you can use the mogrify * .png command, provided that your ImageMagick was built using libpng16 (run this convert -list format | grep PNG to make sure you are building with the “correct” settings).

If you want to know which files to fix, rather than blindly process them all, you can run pngcrush -n -q * .png , where -n means that you are not rewriting files and - q means suppressing the “technical” part of the output, except for warnings. Unfortunately pngcrush does not yet have an option to suppress all “technical” messages other than warnings.

ImageMagick Binary Releases here

For Android projects (Android Studio) go to the res folder.

Example: C: \ AndroidProjects \ {your_project_folder} \ app \ src \ main \ res \ drawable-hdpi \ mogrify * .png

Use pngcrush to remove the wrong sRGB profile from the png file:

pngcrush -ow -rem allb -reduce file.png
  • ow will overwrite the input file
  • rem allb will remove all auxiliary chunks except tRNS and gAMA
  • reduce preserves color and depth

You should see Removed the sRGB chunk in the console output. , and maybe more messages about removing chunks of iCCP. You will end up with a smaller optimized png file. When the command overwrites the original file, be sure to create a backup or version control (git_hub, tartuiseHG, etc.).

Solution (I like this option because it is in Qt: 3)

Incorrect file can be fixed:

  1. Opening a picture (invalid file) with QPixmap :: load
  2. Save the picture (already a valid file) to disk using QPixmap :: save

Note this solution uses Qt library .


Here is a minimal example I wrote in C++ to demonstrate how to implement the proposed solution:

QPixmap pixmap;
pixmap.load ("badProfileImage.png");
QFile file ("goodProfileImage.png");
file.open (QIODevice :: WriteOnly);
pixmap.save (& amp; file, "PNG");

The complete “GUI Application” source code, based on this example, is available at GitHub .

You can fix this in Photoshop …. I have CC2015, but I’m sure all versions have it.

  1. Open your .png file
  2. File – & gt; Save As and in the opened dialog box uncheck “ICC Profile: sRGB IEC61966-2.1”
  3. uncheck “As a Copy”
  4. Feel free to save your “new” original .png.
  5. Move your life knowing that you have removed a little bit of evil from this world.

I used the "mogrify * .png" ImageMagik function. However, I had images buried in under folders, so I used this simple script Python to apply to all images in all under folders and thought he could help other people:

import os
import subprocess
def system_call (args, cwd = "."):
print ("Running '{}' in '{}'". format (str (args), cwd))
  subprocess.call (args, cwd = cwd)
def fix_image_files (root = os.curdir):
  for path, dirs, files in os.walk (os.path.abspath (root)):
    # sys.stdout.write ('.')
    for dir in dirs:
      system_call ("mogrify * .png", "{}". format (os.path.join (path, dir)))
fix_image_files (os.curdir)

Using the first method of solving this question, I changed the type of request:

find. -name "* .png" -type f -print0 | xargs -0 pngcrush_1_8_8_w64.exe -n -q & gt; pngError.txt 2 & gt; & amp; 1

I used find and xargs because pngcrush couldn’t handle a lot of arguments (which were returned by ** / *.png ). The parameters -print0 and -0 are required to handle filenames containing spaces.

Then search 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 them, run mogrify to fix them.

mogrify ./Installer/Images/installer_background.png

This prevents it from being indexed as if all png files have changed when only some of them have actually been changed. It also has the advantage of showing exactly which files were faulty.

I tested this on Windows with Cygwin console and zsh shell. And thanks also to the first option (by glen ) for an exact explanation of how this problem can be solved.

here’s an easier way to fix this problem on Mac OS using Homebrew:

& gt; install homebrew if it is not installed yet
$ brew install libpng
$ pngfix --strip = color --out = file2.png file.png

or do with every file in the current directory:

mkdir tmp; for f in ./*.png; do pngfix --strip = color --out = tmp / "$ f" "$ f"; done

Homebrew will create a fixed copy for each png file in the current directory and place it in a tmp subdirectory. After that, if everything is ok, you just need to override the original files.

Another tip is to use Keynote and Preview apps to create icons. I draw them using Keynote, about 120×120 pixels, above a slide with a white background (the option to edit polygons is great!). Before exporting to Preview, I draw a rectangle around the icon (no fill or shadow, only an outline around 135×135) and copy everything to the clipboard. After that, you just need to open it with the Preview tool with Create from Clipboard, select a 128×128 px area around the icon, copy, use Create from Clipboard again, and export it to PNG. You will not need to run the pngfix tool.

Using the IrfanView image viewer on Windows, I simply saved the PNG image and fixed the problem.

After trying a couple of suggestions on this page, I settled on using pngcrush. You can use the bash script below to recursively detect and fix bad png profiles. Just pass it the full path to the directory you want to find for the png files.

fixpng "/ path / to / png / folder"


#! / bin / bash
FILES = $ (find "$ 1" -type f -iname '* .png')
for f in $ FILES; do
  WARN = $ (pngcrush -n -warn "$ f" 2 & gt; & amp; 1)
  if [["$ WARN" == * "PCS illuminant is not D50" *]] || [["$ WARN" == * "known incorrect sRGB profile" *]]; then
    pngcrush -s -ow -rem allb -reduce "$ f"
    FIXED = $ ((FIXED + 1))
echo "$ FIXED errors fixed"

some background information on this:

Some changes in libpng 1.6+ make it
issues a warning or even does not work correctly with the original
HP / MS sRGB profile, resulting in the following warning
libpng warning: iCCP: known incorrect sRGB profile . old
the profile uses the D50 white point standard while the new D65 standard is the white point.
This profile is not uncommon to be used in Adobe Photoshop, although it is
was not embedded in images by default.

(source: https://wiki.archlinux.org/index.php/Libpng_errors )

Error detection has been improved in some elements. In particular, the reader
iCCP element now does a fairly complete check of the base
format. Some unsuccessful profiles that were previously adopted,
now rejected, in particular a very old broken profile
Microsoft / HP sRGB.png specification requirement that only
grayscale images can be displayed on images with
color type 0 or 4, and even if the image contains only grays
pixels, now only RGB profiles are applied in images with the type
colors 2, 3 or 6. The sRGB element is allowed to appear in images with
any type of color.

(source: https://forum.qt.io/topic/58638/solved-libpng-warning-iccp-known-incorrect-srgb-profile-drive-me-nuts/16 )

Answer 2, authority 50%

Save the graphic object you need in .PNG format
open Photoshop, create a new project, at the very bottom there is a menu, “Color Profile”.
Choose the very first option, “Cancel document color management”. Click OK.
Copy your image to a project, save it in .PNG format.
Enjoy the result without the pop-up error.

Answer 3

This problem can be easily solved in Photoshop.
Open Photoshop and execute: Edit & gt; Assign Profile & gt; Don’t Color Manage This Document

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions