support exif res unit "none"

well why would you want that, but it seems some images use it
This commit is contained in:
John Cupitt 2014-09-09 12:18:21 +01:00
parent d085351f0f
commit 6269c852cc
3 changed files with 23 additions and 3 deletions

View File

@ -1,6 +1,7 @@
8/9/14 started 7.40.8
- fix configure on rhel6 [Lovell]
- mono <-> rgb converters were not handling extra bands, thanks James
- support jpeg resunit "none"
21/8/14 started 7.40.7
- width and height were swapped in matlab load

View File

@ -57,6 +57,8 @@
* - null-terminate exif strings, thanks Mike
* 24/2/14
* - don't write to our input buffer, thanks Lovell
* 9/9/14
* - support "none" as a resolution unit
*/
/*
@ -547,6 +549,13 @@ res_from_exif( VipsImage *im, ExifData *ed )
#endif /*DEBUG*/
switch( unit ) {
case 1:
/* No unit ... just pass the fields straight to vips.
*/
vips_image_set_string( im,
VIPS_META_RESOLUTION_UNIT, "none" );
break;
case 2:
/* In inches.
*/

View File

@ -63,6 +63,8 @@
* - add "strip" option to remove all metadata
* 13/11/13
* - add a "no_subsample" option to disable chroma subsample
* 9/9/14
* - support "none" as a resolution unit
*/
/*
@ -460,11 +462,19 @@ set_exif_resolution( ExifData *ed, VipsImage *im )
*/
unit = 2;
if( vips_image_get_typeof( im, VIPS_META_RESOLUTION_UNIT ) &&
!vips_image_get_string( im, VIPS_META_RESOLUTION_UNIT, &p ) &&
vips_isprefix( "cm", p ) )
unit = 3;
!vips_image_get_string( im, VIPS_META_RESOLUTION_UNIT, &p ) ) {
if( vips_isprefix( "cm", p ) )
unit = 3;
else if( vips_isprefix( "none", p ) )
unit = 1;
}
switch( unit ) {
case 1:
xres = im->Xres;
yres = im->Yres;
break;
case 2:
xres = im->Xres * 25.4;
yres = im->Yres * 25.4;