geeqie icon indicating copy to clipboard operation
geeqie copied to clipboard

Missing color profile support for AVIF/HEIF and possible others formats

Open cytrinox opened this issue 2 years ago • 7 comments

ISSUE TYPE

  • Feature Request

GEEQIE VERSION

Geeqie 1.7.2 GTK3 from [6d54123](https://github.com/BestImageViewer/geeqie/commit/6d541232b1c2c670ff9417b9797e16ca56439318)

SUMMARY

AVIF support ist listed in geeqies featured file formats, but I was unable to show any .avif files in geeqie. I thought https://github.com/BestImageViewer/geeqie/pull/980 is the only thing missing, but turns out there is something more to do. AVIF and HEIF images often comes with Rec2020 Linear or PQ profiled image data, but I don't see any code in geeqie dealing with profile information from libheif. My linear files are too dark while the PQ files are too bright displayed in geeqie, which is expected when profiles are ignored.

I've added HEIF support and profile data passing to darktable last year in https://github.com/darktable-org/darktable/pull/8800 but I don't see a good point to start in geeqie, as the file loaders seems to be not capable of loading/passing profile data.

It would be very nice have proper support of AVIF files. If someone can give me few hints what's the best way to implement libheif profile data passing, maybe I can do it. From my current understanding of the code architecture, the best way would be a modification of the image loaders, but I think this would be a rather huge change.

cytrinox avatar Apr 01 '22 20:04 cytrinox

Please note that I know nothing about colors and color profiles...

I think the pull request is not necessary. The gdk_pixbuf_get_formats() function shows heif as a supported format, so the file type gets loaded into the filefilter list (on my system, at least). The list on Edit/Preferences/Advanced/Usable File Type shows the output of gdk_pixbuf_get_formats(). This is the loader: https://github.com/strukturag/libheif/blob/master/gdk-pixbuf/pixbufloader-heif.c I tried a quick hack to use this loader, but images were just displayed as black.

As a temporary solution could you use an external profile file e.g. Rec2020.icm, and set it in Edit/Preferences/Color Management/Input Profiles?

As far as I can see, an embedded profile is loaded at line 466 of image.c/image_post_process_color(). So, in my trivial way of thinking, there needs to be a check on the file type and a call made to the relevant libheif get profile function.

caclark avatar Apr 15 '22 09:04 caclark

Could you upload a sample image with embedded profile?

caclark avatar Apr 23 '22 18:04 caclark

@caclark Attached is a full sample set of AVIFs with difference color profiles and a reference JPEG in sRGB.

For most AVIF/HEIF files, there is no embedded ICC profile but a NCLX information block. These are parameters like primary colors and tranfer curves etc., basically an instruction set for building the profile. This is "easy" with LittleCMS and some good code can be found in darktable sourcecode, for example here: https://github.com/darktable-org/darktable/blob/fae5e8fec080a05f2fdee26fde1b8b3945cee72d/src/common/colorspaces.c#L737

avif_profile_samples.zip

cytrinox avatar Apr 30 '22 12:04 cytrinox

On my Debian 11 system, HEIF files are enabled in Geeqie but AVIF not. That's why I've submitted the PR. Maybe there is some magic on some plattforms/code, but I'm unable to get *.avif files into Geeqies browser window without this PR.

cytrinox avatar Apr 30 '22 12:04 cytrinox

All iPhones produce HEIC with display p3 profile same as in jpeg tagged as Copyright Apple Inc., 2017. Rename to .heic (this is one of mine Public Domain CC0) Blood cells

Or https://bug1443863.bmoattachments.org/attachment.cgi?id=9240029 (converted not native to iOS yet still has same ICC profile).

ZaquL avatar May 30 '22 23:05 ZaquL

It would be very nice have proper support of AVIF files. If someone can give me few hints what's the best way to implement libheif profile data passing, maybe I can do it. From my current understanding of the code architecture, the best way would be a modification of the image loaders, but I think this would be a rather huge change.

Attached is a .diff that is a half-baked, mostly-unfinished, implementation. If someone wishes to do something with that, that would be good. Otherwise maybe I will continue with it, sometime or other.... 981-1.diff.gz

caclark avatar Jun 26 '22 15:06 caclark

The attached .diff is the result of some pretty uninformed copying from gimp. It works on some of the above test images, and not on others. There is debug output to show what the code thinks it is looking at. Thumbnails are not color managed. 981-2.diff.gz

caclark avatar Sep 25 '22 09:09 caclark

The attached .diff gives a good view of all images, but the colors are a little off on some - noticeably the PQ images. If someone knows why, that would be good to know.

981-3.diff.gz

caclark avatar Nov 09 '22 14:11 caclark