From 8875e23128affd17a479308c14b7f808b62e0fd4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 10 Sep 2014 09:05:13 +0100 Subject: [PATCH 1/3] fix a setjmp() loop in pngread see https://github.com/jcupitt/libvips/issues/175 stupid setjmp() --- libvips/foreign/vipspng.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libvips/foreign/vipspng.c b/libvips/foreign/vipspng.c index f89bb58d..66f7e396 100644 --- a/libvips/foreign/vipspng.c +++ b/libvips/foreign/vipspng.c @@ -509,6 +509,11 @@ png2vips_generate( VipsRegion *or, read->y_pos += 1; } + /* Turn errors back on. png_read_end() can trigger them too. + */ + if( setjmp( png_jmpbuf( read->pPng ) ) ) + return( -1 ); + /* We need to shut down the reader immediately at the end of read or * we won't detach ready for the next image. */ From 01bd7cad04a0d8704a85fd105143338aa9f9375d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 10 Sep 2014 09:37:13 +0100 Subject: [PATCH 2/3] support GRAY as an input and output ICC space see https://github.com/jcupitt/libvips/issues/176 --- ChangeLog | 2 ++ libvips/colour/icc_transform.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3d2d5c5..d9f8fa9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 8/9/14 started 7.40.9 - support jfif resunit "none" +- support GRAY as an input and output ICC space +- fix a read loop with setjmp() in png read, if the png file is broken 8/9/14 started 7.40.8 - fix configure on rhel6 [Lovell] diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index cc677105..493fafa5 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -26,6 +26,8 @@ * - import and export would segv on very wide images * 12/11/13 * - support XYZ as an alternative PCS + * 10/9/14 + * - support GRAY as an input and output space */ /* @@ -245,6 +247,16 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; + case cmsSigGrayData: + code->input_bands = 1; + code->input_format = + code->in->BandFmt == VIPS_FORMAT_USHORT ? + VIPS_FORMAT_USHORT : VIPS_FORMAT_UCHAR; + icc->in_icc_format = + code->in->BandFmt == VIPS_FORMAT_USHORT ? + TYPE_GRAY_16 : TYPE_GRAY_8; + break; + case cmsSigCmykData: code->input_bands = 4; code->input_format = @@ -266,8 +278,6 @@ vips_icc_build( VipsObject *object ) case cmsSigXYZData: code->input_bands = 3; code->input_format = VIPS_FORMAT_FLOAT; - code->input_interpretation = - VIPS_INTERPRETATION_XYZ; icc->in_icc_format = TYPE_XYZ_16; break; @@ -295,6 +305,20 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; + case cmsSigGrayData: + colour->interpretation = + icc->depth == 8 ? + VIPS_INTERPRETATION_B_W : + VIPS_INTERPRETATION_GREY16; + colour->format = + icc->depth == 8 ? + VIPS_FORMAT_UCHAR : VIPS_FORMAT_USHORT; + colour->bands = 1; + icc->out_icc_format = + icc->depth == 16 ? + TYPE_GRAY_16 : TYPE_GRAY_8; + break; + case cmsSigCmykData: colour->interpretation = VIPS_INTERPRETATION_CMYK; colour->format = From 980adb394aff95d8cc73ce6a835d00e2cb2c10e9 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 10 Sep 2014 09:47:38 +0100 Subject: [PATCH 3/3] oops, GRAY is an lcms2 feature --- libvips/colour/icc_transform.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index 493fafa5..6203f65a 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -247,6 +247,7 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; +#ifdef HAVE_LCMS2 case cmsSigGrayData: code->input_bands = 1; code->input_format = @@ -256,6 +257,7 @@ vips_icc_build( VipsObject *object ) code->in->BandFmt == VIPS_FORMAT_USHORT ? TYPE_GRAY_16 : TYPE_GRAY_8; break; +#endif /*HAVE_LCMS2*/ case cmsSigCmykData: code->input_bands = 4; @@ -305,6 +307,7 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; +#ifdef HAVE_LCMS2 case cmsSigGrayData: colour->interpretation = icc->depth == 8 ? @@ -318,6 +321,7 @@ vips_icc_build( VipsObject *object ) icc->depth == 16 ? TYPE_GRAY_16 : TYPE_GRAY_8; break; +#endif /*HAVE_LCMS2*/ case cmsSigCmykData: colour->interpretation = VIPS_INTERPRETATION_CMYK;