From 265fb2a825a158c9c0234d14acd0d1d4c8476398 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 12 May 2018 11:05:08 +0100 Subject: [PATCH] improve colourspace guessing in icc icc_transform does a better job of guessing the colourspace of an image -- if the colourspace has not been set (generic multiband), it'll look at the image bands instead and guess from that see https://github.com/jcupitt/libvips/issues/971 --- libvips/colour/icc_transform.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index 67053214..152c2470 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -540,9 +540,31 @@ vips_image_expected_sig( VipsImage *image ) expected_sig = cmsSigYxyData; break; + case VIPS_INTERPRETATION_MULTIBAND: + /* A generic many-band image. Try to guess from the number of + * image bands instead. + */ + switch( image->Bands ) { + case 1: + expected_sig = cmsSigGrayData; + break; + + case 3: + expected_sig = cmsSigRgbData; + break; + + case 4: + expected_sig = cmsSigCmykData; + break; + + default: + expected_sig = -1; + break; + } + break; + case VIPS_INTERPRETATION_LCH: case VIPS_INTERPRETATION_CMC: - case VIPS_INTERPRETATION_MULTIBAND: case VIPS_INTERPRETATION_HISTOGRAM: case VIPS_INTERPRETATION_MATRIX: case VIPS_INTERPRETATION_FOURIER: