Bug 386396 - Eliminate useless and misleading libpng terminal message
Summary: Eliminate useless and misleading libpng terminal message
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-DImg-PNG (show other bugs)
Version: 5.7.0
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 18:25 UTC by Elle Stone
Modified: 2022-01-14 16:18 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.5.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elle Stone 2017-10-31 18:25:28 UTC
Upon creating a new database, and probably every time digikam is run, the following lines are printed to the terminal:

digikam.dimg: "/usr/share/digikam/data/sample-aix.png"  : PNG file identified
digikam.metaengine: Loading image history  ""
digikam.metaengine: DateTime => Exif.Photo.DateTimeOriginal =>  QDateTime(2010-07-27 06:40:05.000 EDT Qt::TimeSpec(LocalTime))
libpng warning: iCCP: known incorrect sRGB profile

For unfathomable reasons, libpng searches for and flags certain sRGB profiles as problematic. Once such profile is an sRGB profile that is commonly found on Windows computers and consequently also in images downloaded from the internet. There is absolutely nothing wrong with this profile and probably nothing with other profiles that libpng flags. But the error messages cause consternation for users.

This GIMP bug report has a patch that shows how to eliminate this misleading libpng "known incorrect sRGB profile" terminal message: Deal with libpng error gracefully when exporting an image with the color profile "sRGB IEC61966-2.1": https://bugzilla.gnome.org/show_bug.cgi?id=765850#c3

The GIMP bug report references an imagemagick forum discussion on the topic. Quoting from the GIMP bug report:

#Begin quote: 
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);

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.

#End quote.

Of course the patch attached to the GIMP bug report (https://bug765850.bugzilla-attachments.gnome.org/attachment.cgi?id=334241) won't work with digiKam. But the relevant code changes to disable the png warnings are hopefully easy to port over to digiKam.
Comment 1 Elle Stone 2017-10-31 18:54:56 UTC
Hmm, digiKam terminal output just printed a useless libpng warning that I've never seen before:

digikam.dimg: "/hdd/edit/edit/archiveprints/20080416 pond leaves/586-587.png"  : PNG file identified
libpng warning: iCCP: profile 'ICC profile': 0h: PCS illuminant is not D50

The profile in question is an old Kodak Romm profile directly from the old Kodak website. Apparently libpng is now checking profile illuminant values, and complaining about the following discrepancy (using iccToXml to print out the profile contents:

What is in the old Kodak profile:

      <XYZNumber X="0.96420288" Y="1.00000000" Z="0.82487488"/>

What is in most profile's illuminant field (until iccMAX comes along and makes it OK to use other illuminants):

      <XYZNumber X="0.96420288" Y="1.00000000" Z="0.82490540"/>

This libpg warning is useless. Users won't know what to do with it. The profile is fine just as it is. Yes, the D50 illuminant values are slightly off from what is normally found in V2 and V4 ICC profiles. No, this small difference won't make a bit of practical difference to the user, especially in a V4 CMM such as LCMS2 provides. All this warning does is confuse the user (if they see it) and waste processing time to detect and print.

AFAIK no other file format prints such warnings. As the warnings are about things that make no difference whatsoever to users, it would be good to disable the libpng warnings to keep them from being printed to the terminal, where they might confuse users. In fact they do confuse users, as a search on the internet will quickly show.
Comment 2 caulier.gilles 2020-08-04 08:25:17 UTC
digiKam 7.0.0 stable release is now published:

https://www.digikam.org/news/2020-07-19-7.0.0_release_announcement/

We need a fresh feedback on this file using this version.

Best Regards

Gilles Caulier
Comment 3 caulier.gilles 2022-01-14 16:18:36 UTC
Git commit 24812e95ff67f9117e74d614011eaa125325b152 by Gilles Caulier.
Committed on 14/01/2022 at 16:17.
Pushed by cgilles into branch 'master'.

Reduce error messages from libpng
FIXED_IN: 7.5.0

M  +52   -4    core/dplugins/dimg/png/dimgpngloader_load.cpp
M  +12   -1    core/dplugins/dimg/png/dimgpngloader_save.cpp
M  +1    -1    core/dplugins/dimg/png/dimgpngplugin.cpp

https://invent.kde.org/graphics/digikam/commit/24812e95ff67f9117e74d614011eaa125325b152