From e0bb8e5d5834a360ea4e52a4081632efc3dc937b Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 26 Nov 2021 11:10:29 +0000 Subject: [PATCH] make exif resunit optional and default to inch Some images don't set the exif resolution unit. We were ignoring exif resolution in this case, but that's not correct, it's supposed to default to inch. See https://web.archive.org/web/20190624045241if_/http://www.cipa.jp:80/std/documents/e/DC-008-Translation-2019-E.pdf for the full spec. --- ChangeLog | 3 +++ configure.ac | 6 +++--- libvips/foreign/exif.c | 10 +++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08e71bd9..4a21631d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +26/11/21 started 8.12.2 +- make exif resuint optional and default to inch + 21/11/21 started 8.12.1 - fix insert [chregu] diff --git a/configure.ac b/configure.ac index d3a1d693..3ae21afb 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # also update the version number in the m4 macros below -AC_INIT([vips], [8.12.1], [vipsip@jiscmail.ac.uk]) +AC_INIT([vips], [8.12.2], [vipsip@jiscmail.ac.uk]) # required for gobject-introspection AC_PREREQ([2.69]) @@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4]) # user-visible library versioning m4_define([vips_major_version], [8]) m4_define([vips_minor_version], [12]) -m4_define([vips_micro_version], [1]) +m4_define([vips_micro_version], [2]) m4_define([vips_version], [vips_major_version.vips_minor_version.vips_micro_version]) @@ -41,7 +41,7 @@ VIPS_LIBS="" # binary interface changed: increment current, reset revision to 0 # binary interface changes backwards compatible?: increment age # binary interface changes not backwards compatible?: reset age to 0 -LIBRARY_REVISION=1 +LIBRARY_REVISION=2 LIBRARY_CURRENT=56 LIBRARY_AGE=14 diff --git a/libvips/foreign/exif.c b/libvips/foreign/exif.c index 12e40292..e7d08d6f 100644 --- a/libvips/foreign/exif.c +++ b/libvips/foreign/exif.c @@ -416,11 +416,15 @@ vips_image_resolution_from_exif( VipsImage *image, ExifData *ed ) */ if( vips_exif_entry_get_double( ed, 0, EXIF_TAG_X_RESOLUTION, &xres ) || vips_exif_entry_get_double( ed, - 0, EXIF_TAG_Y_RESOLUTION, &yres ) || - vips_exif_entry_get_int( ed, - 0, EXIF_TAG_RESOLUTION_UNIT, &unit ) ) + 0, EXIF_TAG_Y_RESOLUTION, &yres ) ) return( -1 ); + /* resuint is optional and defaults to inch. + */ + unit = 2; + (void) vips_exif_entry_get_int( ed, + 0, EXIF_TAG_RESOLUTION_UNIT, &unit ); + #ifdef DEBUG printf( "vips_image_resolution_from_exif: seen exif tags " "xres = %g, yres = %g, unit = %d\n", xres, yres, unit );