From a16c0c0d7810c8c7212959b48ec57203f46a9f05 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 23 Mar 2021 18:50:39 +0000 Subject: [PATCH] set mct more carefully --- libvips/foreign/jp2ksave.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libvips/foreign/jp2ksave.c b/libvips/foreign/jp2ksave.c index 62b78c04..9559ce1a 100644 --- a/libvips/foreign/jp2ksave.c +++ b/libvips/foreign/jp2ksave.c @@ -37,9 +37,6 @@ */ /* TODO - * - * - we will have 0.5 pixels if the image width or height is odd and chroma - * subsampling is on ... this will cause at least read out of bounds. * * - could support tiff-like depth parameter * @@ -624,14 +621,9 @@ vips_foreign_save_jp2k_build( VipsObject *object ) break; } - if( jp2k->downsample ) { + if( jp2k->downsample ) jp2k->save_as_ycc = TRUE; - /* MCT does not work with subsample. - */ - jp2k->parameters.tcp_mct = FALSE; - } - /* CIELAB etc. do not seem to be well documented. */ switch( save->ready->Type ) { @@ -717,7 +709,8 @@ vips_foreign_save_jp2k_build( VipsObject *object ) /* Makes three band images smaller, somehow. */ - jp2k->parameters.tcp_mct = save->ready->Bands == 3 ? 1 : 0; + jp2k->parameters.tcp_mct = + (save->ready->Bands == 3 && !jp2k->downsample) ? 1 : 0; /* Lossy mode. */