From 4ba6373357143ad3683ade7b696abc527148eef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Angel=20S=C3=A1nchez?= Date: Fri, 21 Jun 2019 14:14:40 +0200 Subject: [PATCH] correctly parse labQ with extra channels --- libvips/foreign/tiff2vips.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 760a5d11..a54c28ce 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -756,6 +756,7 @@ rtiff_labpack_line( Rtiff *rtiff, VipsPel *q, VipsPel *p, int n, void *dummy ) float pf[3]; int x; + int i; for( x = 0; x < n; x++ ) { pf[0] = p[0] * 100.0f / 255.0f; @@ -764,7 +765,10 @@ rtiff_labpack_line( Rtiff *rtiff, VipsPel *q, VipsPel *p, int n, void *dummy ) vips__Lab2LabQ_vec(q, pf, 1); - q += 4; + for (i = 3; i < samples_per_pixel; i++) + q[i+1] = p[i]; + + q += samples_per_pixel+1; p += samples_per_pixel; } } @@ -779,7 +783,7 @@ rtiff_parse_labpack( Rtiff *rtiff, VipsImage *out ) rtiff_check_interpretation( rtiff, PHOTOMETRIC_CIELAB ) ) return( -1 ); - out->Bands = 4; + out->Bands = rtiff->header.samples_per_pixel + 1; out->BandFmt = VIPS_FORMAT_UCHAR; out->Coding = VIPS_CODING_LABQ; out->Type = VIPS_INTERPRETATION_LAB;