basic tests

This commit is contained in:
John Cupitt 2016-05-27 20:18:25 +01:00
parent 0b646ffcc7
commit 2590559e56
2 changed files with 36 additions and 4 deletions

4
TODO
View File

@ -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

View File

@ -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():