diff --git a/ChangeLog b/ChangeLog index 3c99096a..3bc532e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ 31/8/19 started 8.8.3 - revert sharpen restoring the input colourspace +- xres/yres tiffsave params were in pixels/cm [f--f] 9/7/19 started 8.8.2 - better early shutdown in readers diff --git a/libvips/convolution/sharpen.c b/libvips/convolution/sharpen.c index 795299a6..72b0a509 100644 --- a/libvips/convolution/sharpen.c +++ b/libvips/convolution/sharpen.c @@ -41,7 +41,6 @@ * - move to defaults suitable for screen output * 28/8/19 * - fix sigma 0.5 case (thanks 2h4dl) - * - restore input colourspace */ /* diff --git a/libvips/foreign/tiffsave.c b/libvips/foreign/tiffsave.c index b1e45d85..341193cc 100644 --- a/libvips/foreign/tiffsave.c +++ b/libvips/foreign/tiffsave.c @@ -17,6 +17,8 @@ * 8/7/19 * - add webp and zstd support * - add @level and @lossless + * 4/9/18 [f--f] + * - xres/yres params were in pixels/cm */ /* @@ -142,16 +144,22 @@ vips_foreign_save_tiff_build( VipsObject *object ) build( object ) ) return( -1 ); - /* Default xres/yres to the values from the image. + /* Default xres/yres to the values from the image. This is always + * pixels/mm. */ if( !vips_object_argument_isset( object, "xres" ) ) - tiff->xres = save->ready->Xres * 10.0; + tiff->xres = save->ready->Xres; if( !vips_object_argument_isset( object, "yres" ) ) - tiff->yres = save->ready->Yres * 10.0; + tiff->yres = save->ready->Yres; + + /* We default to pixels/cm. + */ + tiff->xres *= 10.0; + tiff->yres *= 10.0; /* resunit param overrides resunit metadata. */ - if( !vips_object_argument_isset( object, "resunit" ) && + if( vips_object_argument_isset( object, "resunit" ) && vips_image_get_typeof( save->ready, VIPS_META_RESOLUTION_UNIT ) && !vips_image_get_string( save->ready, diff --git a/test/test-suite/test_foreign.py b/test/test-suite/test_foreign.py index 6856418c..6af9654a 100644 --- a/test/test-suite/test_foreign.py +++ b/test/test-suite/test_foreign.py @@ -321,6 +321,24 @@ class TestForeign: assert x1.width == x2.height assert x1.height == x2.width + filename = temp_filename(self.tempdir, '.tif') + x = pyvips.Image.new_from_file(TIF_FILE) + x = x.copy() + x.write_to_file(filename, xres=100, yres=200, resunit="cm") + x1 = pyvips.Image.new_from_file(filename) + assert x1.get("resolution-unit") == "cm" + assert x1.xres == 100 + assert x1.yres == 200 + + filename = temp_filename(self.tempdir, '.tif') + x = pyvips.Image.new_from_file(TIF_FILE) + x = x.copy() + x.write_to_file(filename, xres=100, yres=200, resunit="inch") + x1 = pyvips.Image.new_from_file(filename) + assert x1.get("resolution-unit") == "in" + assert x1.xres == 100 + assert x1.yres == 200 + # OME support in 8.5 x = pyvips.Image.new_from_file(OME_FILE) assert x.width == 439