GNOME Bugzilla – Bug 765850
Deal with libpng error gracefully when exporting an image with the color profile "sRGB IEC61966-2.1"
Last modified: 2016-10-31 08:42:56 UTC
`sRGB IEC61966-2.1` is one of known invalid color profiles of libpng. I opened a jpg file with `sRGB IEC61966-2.1` color profile and tried to save it as a png. But, gimp said it couldn't save the file as a png for some reason. I had to run gimp on terminal to see the actual error on the terminal. This process took more than half an hour, and I think we can save people's time by dealing with libpng error more gracefully in GIMP. GIMP could do at least two things to help users deal with the error. 1) Offer an option to convert the color profile to `sRGB built-in`? 2) Explain the workaround in a message box. (i.e. tell the user to convert the color profile to `sRGB built-in`.)
Can you please attach such a file? GIMP should already ask you when importing files with profiles, please check the bottom combo box in preferences -> color management.
Created attachment 327459 [details] The file that causes the issue.
Created attachment 334241 [details] [review] Eliminate libpng warnings about known incorrect sRGB profiles What is possible to do with libpng depends on the version of libpng that the user compiled GIMP against. There are several earlier versions of libpng that cause a lot of problems, including an inability to save as a png. Code could be added to GIMP to offer workarounds as suggested. But maybe instead the minimum libpng version requirement for GIMP could be bumped up to a version that supports PNG_BENIGN_ERRORS_SUPPORTED. GIMP already has this code: #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Change some libpng errors to warnings (e.g. bug 721135) */ png_set_benign_errors (pp, TRUE); #endif On my system running commit dfa390f compiled with libpng-1.6.21, I can open the file attached by the OP and save it as a png with no problems. There is, however, a libpng terminal complaint on exporting the image as a png: libpng warning: known incorrect sRGB profile libpng warning: profile matches sRGB but writing iCCP instead And more libpng terminal complaints upon opening the saved png: magic match 8 on file-png-load best magic match on file-png-load libpng warning: iCCP: known incorrect sRGB profile The attached patch suppresses these libpng terminal warnings. It just adds this option: png_set_option(pp, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON); taken from the last post here: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=25809 But maybe I should have added all of this as per the third-from-last post #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \ defined(PNG_SET_OPTION_SUPPORTED) png_set_option(png, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON); #endif This option to suppress the libpng known incorrect sRGB profile warning is available starting with libpng 1.6.11, which was released back in 2014. The "known incorrect" sRGB profiles that libpng detects are still being embedded in sRGB images exported from PhotoShop CS5 and CS6 (I confirmed this today from some images a PhotoShop user sent me). Also these profiles are embedded in many, many images already up on the web. No other software detects these profiles as "known incorrect", so I think it would a nice thing for GIMP users to disable having these messages printed to the terminal.
(In reply to Elle Stone from comment #3) > No other software detects these profiles as "known incorrect", so I think it > would a nice thing for GIMP users to disable having these messages printed > to the terminal. Sorry, that wasn't clear. I meant no other software besides libpng. Any software using libpng gets these useless warnings if they aren't suppressed.
Seems we forgot to resurrect this one from NEEDINFO and go for the attached patch.
First, a proper libpng version: commit a5073ad9289f7e05ef38d2ce99dc71e91983b434 Author: Michael Natterer <mitch@gimp.org> Date: Mon Oct 31 09:36:15 2016 +0100 configure.ac: require libpng 1.6.25 Addresses bug #765850, and probably avoids a gazillion of vulnerabilities in the versions since the ancient 1.2.37 we required before. configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Fixed in master: commit ccb30a625c14a93c2d94b00bafbe6082faa910f7 Author: Elle Stone <ellestone@ninedegreesbelow.com> Date: Fri Aug 26 15:11:12 2016 -0400 Bug 765850 - Deal with libpng error gracefully when exporting... ...an image with the color profile "sRGB IEC61966-2.1" Eliminate libpng warnings about known incorrect sRGB profiles. These "known incorrect sRGB profiles" are only considered "incorrect" by libpng. Such profiles are perfectly good sRGB profiles currently being embedded by PhotoShop 5 and 6 and also already embedded in many, many images on the web. plug-ins/common/file-png.c | 6 ++++++ 1 file changed, 6 insertions(+)