Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292894

Avoid warning from imagecreatefrompng when loading png with obscure iCCP profiles

$
0
0

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.

  1. 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
  2. Upload this image into Drupal and try to process it by any image style.

GIMP (OpenSource image editor)

  1. Open image-test.png in GIMP.
  2. Go to Image | Color Management | Assign Color Profile…
  3. In Assign section in select element chose Select color profile from disk…
  4. Select downloaded .icc profile.
  5. Click Assign.
  6. 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.
  7. 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.


Viewing all articles
Browse latest Browse all 292894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>