From 0012cefc2517dd4041bb7deff756fd937f972e25 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 1 Jun 2016 08:59:44 +0100 Subject: [PATCH] improve orientation fetch we were generating some annoying messages --- TODO | 24 ------------------------ libvips/conversion/autorot.c | 3 ++- libvips/foreign/tiff2vips.c | 1 + libvips/foreign/vips2jpeg.c | 3 ++- libvips/foreign/vips2tiff.c | 5 +++-- 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/TODO b/TODO index 7a98ec42..3c4b0b0a 100644 --- a/TODO +++ b/TODO @@ -7,30 +7,6 @@ try other files in test/images -- try - - http://www.camerafv5.com/files/photos/raw1/rope.dng - $ vips colourspace rope.dng 3.tif[compression=jpeg,Q=90,tile,tile-width=512,tile-height=512] srgb - - tries to save a 16-bit image? - - hangs 50% of the time, the other 50 it fails with a 16-bit error - - save a 16-bit image to tiff with jpg compression ... should it autoconvert? - - tiff should use convert for save in jpeg mode if jpeg compression is enabled - -- try - - $ vipsthumbnail ~/pics/*.jpg - vips warning: vips_image_get: field "orientation" not found - vips_image_get: field "orientation" not found - vips_image_get: field "orientation" not found - vips_image_get: field "orientation" not found - ... - - ugly! - - try adding a coz progress point to vipsthumbnail's main loop see diff --git a/libvips/conversion/autorot.c b/libvips/conversion/autorot.c index 942deb6e..0a700010 100644 --- a/libvips/conversion/autorot.c +++ b/libvips/conversion/autorot.c @@ -76,7 +76,8 @@ vips_autorot_get_angle( VipsImage *im ) int orientation; VipsAngle angle; - if( vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) + if( !vips_image_get_typeof( im, VIPS_META_ORIENTATION ) || + vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) orientation = 1; switch( orientation ) { diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index fbb7d750..222adc80 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -2051,6 +2051,7 @@ vips__tiff_read_header_orientation( ReadTiff *rtiff, VipsImage *out ) int orientation; if( rtiff->autorotate && + vips_image_get_typeof( out, VIPS_META_ORIENTATION ) && !vips_image_get_int( out, VIPS_META_ORIENTATION, &orientation ) ) { if( orientation == 3 || diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index 60702b25..91c703ed 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -543,7 +543,8 @@ set_exif_orientation( ExifData *ed, VipsImage *im ) /* We set the tag, even if it's been deleted, since it's a required * field. */ - if( vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) + if( !vips_image_get_typeof( im, VIPS_META_ORIENTATION ) || + vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) orientation = 1; VIPS_DEBUG_MSG( "set_exif_orientation: %d\n", orientation ); diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c index 224a6411..9c35b421 100644 --- a/libvips/foreign/vips2tiff.c +++ b/libvips/foreign/vips2tiff.c @@ -585,8 +585,9 @@ write_tiff_header( Write *write, Layer *layer ) write_embed_imagedescription( write, tif ) ) return( -1 ); - if( !vips_image_get_int( write->im, - VIPS_META_ORIENTATION, &orientation ) ) + if( vips_image_get_typeof( write->im, VIPS_META_ORIENTATION ) && + !vips_image_get_int( write->im, + VIPS_META_ORIENTATION, &orientation ) ) TIFFSetField( tif, TIFFTAG_ORIENTATION, orientation ); /* And colour fields.