Add AVIF gain-map support (via libultrahdr v2)
Is your feature request related to a problem? Please describe.
ImageMagick now supports JPEG gain maps through libultrahdr, but it cannot currently read or write ISO 21496-1 AVIF gain-map images.
AVIF gain maps are particularly valuable for the web. In my testing, they can be approximately half the size of equivalent Ultra HDR JPEGs while producing fewer visually obvious compression artifacts. An SDR base also provides a safe fallback in software that does not reconstruct the HDR rendition.
libultrahdr 2.0 now offers AVIF gain-map encoding and decoding: https://github.com/google/libultrahdr/releases/tag/v2.0.0
Describe the solution you'd like
Extend ImageMagick’s existing libultrahdr integration to:
- recognize and decode ISO 21496-1 AVIF gain-map images;
- encode AVIF gain maps from suitable HDR input;
- preserve the required color information and gain-map metadata; and
- expose AVIF output through an interface consistent with the existing Ultra HDR support.
The implementation can reasonably wait for the relevant libultrahdr and libheif interfaces to stabilize. This request is intended to provide a focused tracker and start discussion around the preferred architecture.
Describe alternatives you've considered
Ultra HDR JPEG remains a useful alternative (with greater compatibility today), but AVIF can offer substantially smaller files and fewer visible compression artifacts.
libultrahdr can be used standalong, but native ImageMagick support would enable AVIF gain maps in existing ImageMagick-based image-processing and publishing workflows.
libultrahdr 2.0 also supports HEIF/HEIC gain maps. This request is intentionally focused on AVIF because it has the clearest immediate use case and avoids introducing HEVC complexity.
Additional context
This follows the completed JPEG gain-map work originally tracked in https://github.com/ImageMagick/ImageMagick/issues/6377
Relevant upstream work:
- libultrahdr 2.0 AVIF support: https://github.com/google/libultrahdr/releases/tag/v2.0.0
- libheif ISO
tmapsupport (to replace patch used in libultrahdr v2.0: https://github.com/strukturag/libheif/pull/1503 - Proposed high-level libultrahdr transcoding API: https://github.com/google/libultrahdr/issues/398
- Related libvips discussion: https://github.com/libvips/libvips/discussions/5186
This request specifically concerns standardized ISO 21496-1 AVIF gain maps. It does not include older proprietary Apple HEIC gain-map representations.
I can provide AVIF gain-map samples, help with testing, or contribute code at the appropriate time. I expect the relevant libheif work will need to land first, and I would want to understand the maintainers’ expectations before preparing a PR.
Source: ImageMagick/ImageMagick