add some more tests for the tiff saver

This commit is contained in:
John Cupitt 2015-02-17 15:04:15 +00:00
parent ed5c90175a
commit 53c53006a6
2 changed files with 26 additions and 0 deletions

2
TODO
View File

@ -1,5 +1,7 @@
- add more tests for the tiff writer
- rerun vips-bench .. have we changed the timing there at all?

View File

@ -3,6 +3,7 @@
from __future__ import division
import unittest
import math
import os
#import logging
#logging.basicConfig(level = logging.DEBUG)
@ -75,6 +76,20 @@ class TestForeign(unittest.TestCase):
max_diff = (im - x).abs().max()
self.assertEqual(max_diff, 0)
def save_load_file(self, filename, options, im, thresh):
# yuk!
# but we can't set format parameters for Vips.Image.new_temp_file()
im.write_to_file(filename + options)
x = Vips.Image.new_from_file(filename)
self.assertEqual(im.width, x.width)
self.assertEqual(im.height, x.height)
self.assertEqual(im.bands, x.bands)
max_diff = (im - x).abs().max()
self.assertTrue(max_diff <= thresh)
x = None
os.unlink(filename)
def test_jpeg(self):
if not Vips.type_find("VipsForeign", "jpegload"):
print("no jpeg support in this vips, skipping test")
@ -129,6 +144,15 @@ class TestForeign(unittest.TestCase):
self.save_load("%s.tif", self.colour)
self.save_load("%s.tif", self.cmyk)
self.save_load_file("test.tif", "[tile]", self.colour, 0)
self.save_load_file("test.tif", "[tile,pyramid]", self.colour, 0)
self.save_load_file("test.tif",
"[tile,pyramid,compression=jpeg]", self.colour, 0)
self.save_load_file("test.tif", "[bigtiff]", self.colour, 0)
self.save_load_file("test.tif", "[compression=jpeg]", self.colour, 10)
self.save_load_file("test.tif",
"[tile,tile-width=256]", self.colour, 10)
def test_magickload(self):
if not Vips.type_find("VipsForeign", "magickload"):
print("no magick support in this vips, skipping test")