16-bit CIELAB (LabS) TIFF with associated alpha: alpha is clipped to 8 bits on load
维护者通常 1 天内回复
评估
调研方向
Start in libvips/iofuncs or libvips/iofuncs/... where vips_interpretation_max_alpha() is defined and look at its switch over interpretations, which has explicit GREY16 and RGB16 cases and a default of 255. Reproduce with the attached labs16_alpha.tif via vips copy labs16_alpha.tif out.tif and compare the alpha column. Done means LabS 16-bit alpha uses the signed-short maximum of 32767 and the colour bands are preserved, verified by a test that checks the first row values in the table.
由索引模型根据 Issue 内容生成。
描述
Bug report
Description
Loading a 16-bit CIELAB TIFF that carries an associated (premultiplied) alpha band destroys the alpha channel. Every alpha sample above 255 is clipped to 255.
Reproducible example
labs16_alpha.tif is a 16x16, 4-band, 16-bit TIFF: photometric CIELAB,
EXTRASAMPLE_ASSOCALPHA, seven distinct alpha values, 2.3 KB.
labs16_alpha.tif
$ vips copy labs16_alpha.tif out.tif
The first pixel row, before and after (bands are L, a, b, alpha):
| source | out (8.18.7) |
|---|---|
[32766, 16383, 16383, 32767] |
[254, 127, 127, 255] |
[4680, 2340, 2340, 4681] |
[254, 127, 127, 255] |
[1056, 528, 528, 1057] |
[254, 127, 127, 255] |
[216, 108, 108, 217] |
[252, 126, 126, 217] |
[150, 75, 75, 151] |
[252, 126, 126, 151] |
[30, 15, 15, 31] |
[246, 123, 123, 31] |
[6, 3, 3, 7] |
[218, 109, 109, 7] |
Expected result
vips copy keeps all of the alpha data and the full 16-bit range of the colour bands
Actual result
The alpha column is exactly clip(src, 0, 255), so 32767, 4681 and 1057 all collapse to 255. Other values miscalculated accordingly.
Environment
- OS: Windows 11 Pro
- libvips version: 8.18.7, and also tested 9edee694f built with MSYS2 UCRT64
Severity / impact
- Crash / data loss.
- Incorrect result.
- Build / install problem.
- Performance / memory issue.
- Other (please specify).
Additional context
vips_interpretation_max_alpha() has explicit cases for GREY16 and RGB16
(65535) and for scRGB (1.0), and lets everything else fall through to a
default of 255. LABS is not listed, so 16-bit LabS alpha is treated as 8-bit
alpha.
Possible steps
- add the missing 16-bit interpretations to the switch, using the maximum of the
corresponding 16-bit range (for LabS that maximum is 32767, not 65535. LabS is stored as signed short) - Another option: whether the scale can be derived from the band format together with the interpretation instead of a hand-maintained list
Disclaimer
I did not encounter this issue in my real pipeline, it just popped up when researching #5280 It probably has low priority given the rarity of the image format
- 主要语言
- C
- 星标
- 11.9k
- 派生
- 811
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 44
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
libvips/libvips 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
libvips/libvips#5297 · 5 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
Make the HTTP server's keep-alive and headers timeouts configurable可能已有人在做 @mattgodbolt 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
compiler-explorer/compiler-explorer#9902 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
timescale/pg_vectorsearch#446 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
signalwire/freeswitch#3329 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
Status: Opened
难度 2/5 1-3 小时 新手友好度 83/100
espressif/esp-protocols#1224 ·
维护者通常 1 天内回复