From 18f79ab328ecddcdf3b3b0e7db3fea9e67485e45 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 9 Apr 2008 22:09:10 +0000 Subject: [PATCH] stuff --- ChangeLog | 1 + TODO | 2 ++ include/vips/meta.h | 1 + libsrc/conversion/im_tiff2vips.c | 10 ++++++++-- libsrc/conversion/im_vips2tiff.c | 26 +++++++++++++++++++++++--- libsrc/{dummy.cc => dummy2.cc} | 0 po/en_GB.gmo | Bin 362 -> 452 bytes 7 files changed, 35 insertions(+), 5 deletions(-) rename libsrc/{dummy.cc => dummy2.cc} (100%) diff --git a/ChangeLog b/ChangeLog index bdbbc720..dc5e9d36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ - push Magick cflags earlier in the include order to make it easier to pick GraphicsMagick over ImageMagick (thanks Mikhail) - fix the en_GB translation +- use meta to preserve resunit between tiff load and save 25/1/08 started 7.14.0 - bump all version numbers for new stable diff --git a/TODO b/TODO index 54c52f7c..ffe921bd 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ save as a tiff with res_inch sets 10 pixels / inch ... wrong! +- test, backport to 7.14 + - should check for gettext in configure? see https://sourceforge.net/tracker/index.php?func=detail&aid=1836080&group_id=100050&atid=626186 diff --git a/include/vips/meta.h b/include/vips/meta.h index a300609a..5469e963 100644 --- a/include/vips/meta.h +++ b/include/vips/meta.h @@ -39,6 +39,7 @@ extern "C" { #define IM_META_EXIF_NAME "exif-data" #define IM_META_ICC_NAME "icc-profile-data" #define IM_META_XML "xml-header" +#define IM_META_RESOLUTION_UNIT "resolution-unit" /* Types we add for meta fields. */ diff --git a/libsrc/conversion/im_tiff2vips.c b/libsrc/conversion/im_tiff2vips.c index 9e0b546a..abeb7c39 100644 --- a/libsrc/conversion/im_tiff2vips.c +++ b/libsrc/conversion/im_tiff2vips.c @@ -97,6 +97,8 @@ * - removed 'broken' read option * 18/7/07 Andrey Kiselev * - remove "b" option on TIFFOpen() + * 9/4/08 + * - set IM_META_RESOLUTION_UNIT */ /* @@ -915,6 +917,8 @@ parse_resolution( TIFF *tiff, IMAGE *out ) */ x /= 10.0 * 2.54; y /= 10.0 * 2.54; + im_meta_set_string( out, + IM_META_RESOLUTION_UNIT, "in" ); break; case RESUNIT_CENTIMETER: @@ -922,6 +926,8 @@ parse_resolution( TIFF *tiff, IMAGE *out ) */ x /= 10.0; y /= 10.0; + im_meta_set_string( out, + IM_META_RESOLUTION_UNIT, "cm" ); break; default: @@ -931,8 +937,8 @@ parse_resolution( TIFF *tiff, IMAGE *out ) } } else { - im_warning( "im_tiff2vips: no resolution information for " - "TIFF image \"%s\" -- defaulting to 1 pixel per mm", + im_warn( "im_tiff2vips", _( "no resolution information for " + "TIFF image \"%s\" -- defaulting to 1 pixel per mm" ), TIFFFileName( tiff ) ); x = 1.0; y = 1.0; diff --git a/libsrc/conversion/im_vips2tiff.c b/libsrc/conversion/im_vips2tiff.c index fd39e50c..71397f04 100644 --- a/libsrc/conversion/im_vips2tiff.c +++ b/libsrc/conversion/im_vips2tiff.c @@ -100,6 +100,8 @@ * - use tiff error handler from im_tiff2vips.c * 27/2/08 * - don't try to copy icc profiles when building pyramids (thanks Joe) + * 9/4/08 + * - use IM_META_RESOLUTION_UNIT to set default resunit */ /* @@ -1193,11 +1195,19 @@ make_tiff_write( IMAGE *im, const char *filename ) tw->embed = 0; tw->icc_profile = NULL; - /* Output resolution settings default to VIPS-alike. + /* Output resolution settings ... default to VIPS-alike. */ tw->resunit = RESUNIT_CENTIMETER; tw->xres = im->Xres * 10; tw->yres = im->Yres * 10; + if( im_meta_get_string( im, IM_META_RESOLUTION_UNIT, &p ) && + strcmp( p, "in" ) ) { + tw->resunit = RESUNIT_INCH; + tw->xres /= 2.54; + tw->yres /= 2.54; + // do I need this? + g_free( p ); + } /* Parse mode string. */ @@ -1313,10 +1323,20 @@ make_tiff_write( IMAGE *im, const char *filename ) } } if( (q = im_getnextoption( &p )) ) { - if( im_isprefix( "res_cm", q ) ) + if( im_isprefix( "res_cm", q ) ) { + if( tw->resunit == RESUNIT_INCH ) { + tw->xres /= 2.54; + tw->yres /= 2.54; + } tw->resunit = RESUNIT_CENTIMETER; - else if( im_isprefix( "res_inch", q ) ) + } + else if( im_isprefix( "res_inch", q ) ) { + if( tw->resunit == RESUNIT_CENTIMETER ) { + tw->xres *= 2.54; + tw->yres *= 2.54; + } tw->resunit = RESUNIT_INCH; + } else { im_error( "im_vips2tiff", _( "unknown resolution unit " "\"%s\"\nshould be one of \"res_cm\" or " diff --git a/libsrc/dummy.cc b/libsrc/dummy2.cc similarity index 100% rename from libsrc/dummy.cc rename to libsrc/dummy2.cc diff --git a/po/en_GB.gmo b/po/en_GB.gmo index 9bf7ae926fe92b8086c9e6c328b7d4a0562bd27b..f5e464eac96536fe3a38b461b10b78a2bc49a57f 100644 GIT binary patch delta 298 zcmaFGbcDJ7o)F7a1|VPtVi_Pd0b*7l_5orLNC09UAWj5gNg&PxVj)Hbh7KUj3&gX5 zY$+hU5=a9P*c>3mzyu;dASp3LAvr%MzbH4cfT1+6xU`@kzo;Y?DyUIhkeHmRpqj!E zP?VpQnp~pmnW7t(T2!2wpJ$~|mRV4&V6JCqqGvQQPu#*n*T6*Az*51`)XLOc+rZGk zfGfaXHz>6%6Qo?%C9x#cO2Np$0A1b0y%GWnHm<&oo<0taE-pc?!NGPD-_~lvoK}j} KZKXwUw*de}mqt1O delta 224 zcmX}izls7e5XW)6r$&td&n~