From 2590559e56633f42b50f524a45fdce9732382e69 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 27 May 2016 20:18:25 +0100 Subject: [PATCH] basic tests --- TODO | 4 +--- test/test_foreign.py | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index fc52478a..18fbda99 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ - save a 16-bit image to tiff with jpg compression ... should it autoconvert? -- add a set of tests for orientation - - test autorotate flags on tiff and jpeg +- test autorotate flags on tiff and jpeg see https://github.com/jcupitt/libvips/issues/243 diff --git a/test/test_foreign.py b/test/test_foreign.py index bb23098a..a315547a 100755 --- a/test/test_foreign.py +++ b/test/test_foreign.py @@ -176,15 +176,31 @@ class TestForeign(unittest.TestCase): if have_exif: # 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.jpeg_file) x = x.copy() x.set_value("orientation", 2) x.write_to_file("test.jpg") x = Vips.Image.new_from_file("test.jpg") y = x.get_value("orientation") self.assertEqual(y, 2) - os.unlink("test.jpg") + x = Vips.Image.new_from_file(self.jpeg_file) + x = x.copy() + x.set_value("orientation", 2) + x.write_to_file("test-12.jpg") + + x = Vips.Image.new_from_file("test-12.jpg") + y = x.get_value("orientation") + self.assertEqual(y, 2) + x.remove("orientation") + x.write_to_file("test-13.jpg") + x = Vips.Image.new_from_file("test-13.jpg") + y = x.get_value("orientation") + self.assertEqual(y, 1) + os.unlink("test-12.jpg") + os.unlink("test-13.jpg") + def test_png(self): x = Vips.type_find("VipsForeign", "pngload") if not x.is_instantiatable(): @@ -251,6 +267,24 @@ class TestForeign(unittest.TestCase): self.assertEqual(y, 2) os.unlink("test-11.tif") + # 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-12.tif") + + x = Vips.Image.new_from_file("test-12.tif") + y = x.get_value("orientation") + self.assertEqual(y, 2) + x.remove("orientation") + x.write_to_file("test-13.tif") + x = Vips.Image.new_from_file("test-13.tif") + y = x.get_value("orientation") + self.assertEqual(y, 1) + os.unlink("test-12.tif") + os.unlink("test-13.tif") + def test_magickload(self): x = Vips.type_find("VipsForeign", "magickload") if not x.is_instantiatable():