Gain maps in JPEG XL (jhgm box, libjxl 0.11)

未关闭
#5,273 7 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
c

调研方向

Read the existing jxlload and jxlsave paths, then compare how uhdrload and uhdrsave attach and preserve gain-map data. Check libjxl 0.11's jxl/gain_map.h and the existing EXIF and XMP box handling; done means JPEG XL load and save preserve the jhgm gain-map box, including conversion from another format.

由索引模型根据 Issue 内容生成。

描述

enhancement
Discussed in https://github.com/libvips/libvips/discussions/5272

Originally posted by tina-junold October 27, 2026
libvips 8.18 keeps the gain map of Ultra HDR JPEG images through uhdrload and uhdrsave, and #5186 covers AVIF and HEIF through libultrahdr 2. libultrahdr doesn't handle JPEG XL, though, while libjxl has supported gain maps on its own since 0.11.

What libjxl provides

jxl/gain_map.h (libjxl 0.11, e.g. 0.11.2 in Debian trixie) reads and writes the jhgm box: a JxlGainMapBundle holds the ISO 21496-1 metadata as a binary blob, an optional alternative color encoding or ICC profile, and the gain map itself as a JPEG XL codestream. JxlGainMapWriteBundle / JxlGainMapReadBundle serialize it, and the box is written with JxlEncoderAddBox like the EXIF and XMP boxes jxlsave writes already, or read from the box events of the decoder.

What it could look like in libvips

Following the JPEG path:

  • jxlload attaches the gain map and its metadata when the image has a jhgm box, like uhdrload does with gainmap-data and the gainmap-* fields, so vips_image_get_gainmap() and thumbnail work on JPEG XL images as well;
  • jxlsave writes a jhgm box when the image has a gain map, keeping it with keep=gainmap, and recompresses it as a JPEG XL codestream if it came from another format, e.g. an Ultra HDR JPEG saved as JPEG XL.

The metadata in the box is ISO 21496-1, the same as in Ultra HDR JPEG and the ISO gain maps of AVIF and HEIF, so the gainmap-* fields would mean the same for every format.

Why

Phones write gain maps (Android as Ultra HDR JPEG, iPhones as JPEG and HEIC), and JPEG XL is gaining browser support. Today an Ultra HDR JPEG saved as JPEG XL with libvips loses its HDR, unless it is converted to scRGB, which drops the SDR rendition. For example, an image service built on libvips which transforms the gain map along with the image, like thumbnail does, can only offer HDR for JPEG output so far.

主要语言
C
星标
11.9k
派生
811
平均合并
1 天 6 小时
30 天内合并 PR
44

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

libvips/libvips 的其他 Issue

查看 libvips/libvips 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。