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

Đang mở
#5,283 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@jcupitt đang làm issue này rồi.

Từ ngày 27/11/2026.

  • #5353 của @jcupitt — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
cli, data

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
C
Star
11.9k
Fork
811
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
44

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của libvips/libvips

Tất cả issue của libvips/libvips

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.