Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab TIFFs with alpha cause exceptions (with partial solution) #682

Closed
bernhardf-ro opened this issue May 31, 2022 · 3 comments
Closed

Lab TIFFs with alpha cause exceptions (with partial solution) #682

bernhardf-ro opened this issue May 31, 2022 · 3 comments

Comments

@bernhardf-ro
Copy link
Contributor

The attached TIFFs use Lab colors and one extra sample for unassociated alpha.
Both cause exceptions in TIFFImageReader.normalizeColor() in line 2251 or 2335 for 8 and 16 bits per channel respectively.
In both cases changing the step of the surrounding for-loop (line 2243 and 2327 respectively) from 3 to 4 fixes the issue.
So I assume the step of the for-loops in that method must include the extras samples of the image being read.
Please see the attachment.

for (int i = 0; i < data.length; i += 3) {
// Unsigned scaled form 0...100
float LStar = (data[i] & 0xff) * 100f / 255.0f;
float aStar;
float bStar;
if (photometricInterpretation == TIFFExtension.PHOTOMETRIC_CIELAB) {
// -128...127
aStar = data[i + 1];

for (int i = 0; i < data.length; i += 3) {
// Unsigned scaled form 0...100
float LStar = (data[i] & 0xffff) * 100.0f / scaleL;
float aStar;
float bStar;
if (photometricInterpretation == TIFFExtension.PHOTOMETRIC_CIELAB) {
// -32768...32767
aStar = data[i + 1] / 256f;

@haraldk
Copy link
Owner

haraldk commented May 31, 2022

Thanks! I'll look into it!

haraldk added a commit that referenced this issue Jun 3, 2022
@haraldk
Copy link
Owner

haraldk commented Jun 3, 2022

Thanks for the sampel files and investigation! Should be fixed now in master.

@haraldk haraldk closed this as completed Jun 3, 2022
@bernhardf-ro
Copy link
Contributor Author

Tried master in our integration and can confirm the fix.

haraldk added a commit that referenced this issue Aug 19, 2022
(cherry picked from commit 91493c5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants