From f0521d4b5d8ecfbf74bffb581ab2cc3d48c56f37 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 27 May 2016 16:53:25 +0100 Subject: [PATCH] all done! a few more tests though --- ChangeLog | 2 ++ TODO | 8 +------- libvips/foreign/tiff2vips.c | 2 +- libvips/foreign/vips2jpeg.c | 2 +- test/test_foreign.py | 20 ++++++++++++++++---- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64b4a1e2..b9c1ede7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ - better python detection and build [Felix Bünemann] - max-alpha defaults to 65535 for RGB16/GREY16 - added radsave_buffer [Henri Chain] +- support tiff orientation tag +- autorotate option for tiff load 18/5/16 started 8.3.2 - more robust vips image reading diff --git a/TODO b/TODO index ca19eac7..fc52478a 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,8 @@ - save a 16-bit image to tiff with jpg compression ... should it autoconvert? -- try - - vips copy orientation-test.jpg x.tif - vips copy x.tif x.jpg - - orientation tag not preserved for tif->jpg - - add a set of tests for orientation + test autorotate flags on tiff and jpeg see https://github.com/jcupitt/libvips/issues/243 diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 6600b2e3..fbb7d750 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -197,8 +197,8 @@ */ /* - */ #define DEBUG + */ #ifdef HAVE_CONFIG_H #include diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index a32e71aa..60702b25 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -543,7 +543,7 @@ set_exif_orientation( ExifData *ed, VipsImage *im ) /* We set the tag, even if it's been deleted, since it's a required * field. */ - if( !vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) + if( vips_image_get_int( im, VIPS_META_ORIENTATION, &orientation ) ) orientation = 1; VIPS_DEBUG_MSG( "set_exif_orientation: %d\n", orientation ); diff --git a/test/test_foreign.py b/test/test_foreign.py index 24756f13..86030d84 100755 --- a/test/test_foreign.py +++ b/test/test_foreign.py @@ -167,7 +167,7 @@ class TestForeign(unittest.TestCase): have_exif = False x = Vips.Image.new_from_file(self.jpeg_file) try: - # our test image does have this field + # our test image has this field y = x.get_value("exif-ifd0-Orientation") have_exif = True except: @@ -177,11 +177,11 @@ class TestForeign(unittest.TestCase): # we need a copy of the image to set the new metadata on # otherwise we get caching problems x = x.copy() - x.set_value("exif-ifd0-Orientation", "2") + x.set_value("orientation", 2) x.write_to_file("test.jpg") x = Vips.Image.new_from_file("test.jpg") - y = x.get_value("exif-ifd0-Orientation") - self.assertEqual(y[0], "2") + y = x.get_value("orientation") + self.assertEqual(y, 2) os.unlink("test.jpg") @@ -240,6 +240,18 @@ class TestForeign(unittest.TestCase): self.save_load_file("test-10.tif", "[tile,tile-width=256]", self.colour, 10) + # we need a copy of the image to set the new metadata on + # otherwise we get caching problems + x = Vips.Image.new_from_file(self.tiff_file) + x = x.copy() + x.set_value("orientation", 2) + x.write_to_file("test.tif") + x = Vips.Image.new_from_file("test.tif") + y = x.get_value("orientation") + self.assertEqual(y, 2) + + os.unlink("test.tif") + def test_magickload(self): x = Vips.type_find("VipsForeign", "magickload") if not x.is_instantiatable():