phillipberndt / pqiv

Powerful image viewer with minimal UI
http://www.pberndt.com/Programme/Linux/pqiv/index.html
GNU General Public License v3.0
309 stars 44 forks source link

Proper color management with ICC profiles #235

Open T-3B opened 8 months ago

T-3B commented 8 months ago

It appears that pqiv is ignoring color profiles (ICC).

For example this comparison: image Left is the PNG version, and right is a JPG with XYB ICC. The right part of the screenshot should be identical to the left if there was a proper color management.

Here is the XYB JPG: xyb

Note that mpv does output the correct colors because it fetches the ICC profile (and MPV uses FFmpeg as pqiv does). Browsers also support ICC profiles.

I really hope this will be implemented in pqiv. Thank you very much for this minimalist and keyboard-oriented image viewer, I love it :)

phillipberndt commented 8 months ago

pqiv uses GTK's own GdkPixbuf for rendering standard file formats, and it looks like it doesn't really support this:

https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/104

Do any Gnome default viewers get this right for you? If yes I could take a look at how they do this.

Does disabling the gdkpixbuf backend fix this for you?

T-3B commented 8 months ago

GdkPixbuf supports ICC profiles. An example of Gnome viewer supporting this JPG file: "Eye of Gnome"

Does disabling the gdkpixbuf backend fix this for you? No, as well as disabling everything except wand (ImageMagick)

A "friend of mine" explained me:

the ICC profile is a base64-encoded null-terminated ASCII string icc-profile option key used in gdk_pixbuf_get_option

you can call gdk_pixbuf_get_option("icc-profile") which returns a gchar * string, and then you can use g_base64_decode to get the actual ICC profile buffer which can be fed to lcms2 or something of that form

I don't know many things about all that stuff (sorry), but it feels like it is possible to render this JPG correctly in pqiv. Thank you for your fast answer!

T-3B commented 8 months ago

Don't hesitate to say if the information of the previous message was enough (or not), or if I should redirect you to actual code of a Gnome image viewer supporting ICC profiles. 🙂