Problem/Motivation
When a PNG (and some other rarely used formats) image contains iCCP chunk with sRGB IEC61966-2.1
color profile, libpng
triggers warning:
Warning: imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile in Drupal\system\Plugin\ImageToolkit\GDToolkit->load() (line 201 of core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php).
This warning is printed for any such image, but they're still valid and displayed correctly.
Steps to reproduce
You need an image with iCCP chunk in it and sRGB IEC61966-2.1
color profile. You can achieve this in several ways.
You can find this color profile in attachments for that issue — sRGB IEC61966-2.1.zip. Extract it first to get .icc
profile.
For examples, I will use core/tests/fixtures/files/image-test.png
. It will be called image-test.png
in commands below without full path.
ImageMagick CLI (convert
)
Assuming that color profile (.icc
) and image (image-test.png
) in the same folder.
convert image-test.png -profile sRGB\ IEC61966-2.1.icc -strip -profile sRGB\ IEC61966-2.1.icc -define png:include-chunk=zTXt,iCCP image-1-icpp.png
- Upload this image into Drupal and try to process it by any image style.
GIMP (OpenSource image editor)
- Open
image-test.png
in GIMP. - Go to Image | Color Management | Assign Color Profile…
- In Assign section in select element chose Select color profile from disk…
- Select downloaded
.icc
profile. - Click Assign.
- Save the image by File | Save as chose name and path and click Export. In open modal window, make sure you have checked Save color profile, and then again Export.
- Upload this image into Drupal and try to process it by any image style.
Proposed resolution
Add @ symbol before calling imagecreatefrompng()
to suppress this warning.