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.
This commit is contained in:
John Cupitt 2021-11-26 11:10:29 +00:00
parent edf63dfeeb
commit e0bb8e5d58
3 changed files with 13 additions and 6 deletions

View File

@ -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]

View File

@ -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

View File

@ -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 );