16-bit CIELAB (LabS) TIFF with associated alpha: alpha is clipped to 8 bits on load

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

维护者通常 1 天内回复

@jcupitt 已经在做这个了。

开始于 2026年11月27日。

  • #5353 来自 @jcupitt —— 未关闭

评估

难度
3/5
预计耗时
半天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
cli, data

调研方向

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

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 模板
  • 阅读贡献指南

从这里开始

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

libvips/libvips 的其他 Issue

查看 libvips/libvips 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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