Skip to content

[BUG] PNG Upload Fails with iCCP Color Profile Warning #4747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
samex opened this issue Apr 10, 2025 · 1 comment
Open
1 task done

[BUG] PNG Upload Fails with iCCP Color Profile Warning #4747

samex opened this issue Apr 10, 2025 · 1 comment
Labels
bug unconfirmed bug review needed Problem should be verified

Comments

@samex
Copy link

samex commented Apr 10, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When uploading certain PNG images (specifically those with a non-standard or incorrect color profile), the following PHP warning is triggered:

Warning: imagecreatefrompng(): gd-png: libpng warning: iCCP: known incorrect sRGB profile in /app/lib/Varien/Image/Adapter/Gd2.php on line 64

This happens when uploading images through the admin panel or regular file upload processes.

If I instead import the image via PHP, the upload appears to succeed, but on the frontend, the image is not displayed. Instead, the placeholder image is shown.

Image

Expected Behavior

Expected Behavior
Images with embedded color profiles (even if incorrect) should be handled gracefully.

No PHP warning should be thrown, and images should appear correctly on the frontend after upload or import.

Steps To Reproduce

Prepare a PNG file that includes an embedded iCCP color profile (commonly found in images exported from certain graphic tools). Or download the attached one here.

Go to the admin panel and attempt to upload the image through the media uploader.

Observe the warning in logs or output:

Environment

- OpenMage: 20.9.0
- php: 7.4

Anything else?

Sample image is attached which triggers the issue.

Image

Temp. solution: mogrify -format png -strip file.png

Maybe it is possible to clean a image in PHP like mogrify does, before upload?

@samex samex added bug review needed Problem should be verified labels Apr 10, 2025
@kiatng
Copy link
Contributor

kiatng commented Apr 16, 2025

GD is not designed to repair image. The issue lies with the image file itself, not the code reading it. The most appropriate solution is to fix the problematic PNG files at the source or before they are processed by this adapter. As noted in the description, this can be done using external tools like mogrify -strip (from ImageMagick) or pngcrush to remove or correct the invalid profile.

While we can suppress the warning by using the @ operator, this only hides the symptom; it doesn't fix the underlying problem with the image file.

I suggest we close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unconfirmed bug review needed Problem should be verified
Projects
None yet
Development

No branches or pull requests

2 participants