add pdfload tests

This commit is contained in:
John Cupitt 2016-02-08 20:39:39 +00:00
parent 9f566fa4a9
commit 676d35ed74
3 changed files with 28 additions and 1 deletions

2
TODO
View File

@ -1,4 +1,4 @@
- add tests for pdfload, check docs, update c++
- vipsthumbnail needs to know about pdfload
- trim page edges? we often have black now

Binary file not shown.

View File

@ -44,6 +44,7 @@ class TestForeign(unittest.TestCase):
self.exr_file = "images/sample.exr"
self.fits_file = "images/WFPC2u5780205r_c0fx.fits"
self.openslide_file = "images/CMU-1-Small-Region.svs"
self.pdf_file = "images/ISO_12233-reschart.pdf"
self.colour = Vips.Image.jpegload(self.jpeg_file)
self.mono = self.colour.extract_band(1)
@ -336,6 +337,32 @@ class TestForeign(unittest.TestCase):
self.file_loader("openslideload", self.openslide_file, openslide_valid)
def test_pdfload(self):
x = Vips.type_find("VipsForeign", "pdfload")
if not x.is_instantiatable():
print("no pdf support in this vips, skipping test")
return
def pdf_valid(self, im):
a = im(10, 10)
self.assertAlmostEqualObjects(a, [35, 31, 32, 255])
self.assertEqual(im.width, 1133)
self.assertEqual(im.height, 680)
self.assertEqual(im.bands, 4)
self.file_loader("pdfload", self.pdf_file, pdf_valid)
self.buffer_loader("pdfload_buffer", self.pdf_file, pdf_valid)
im = Vips.Image.new_from_file(self.pdf_file)
x = Vips.Image.new_from_file(self.pdf_file, scale = 2)
self.assertLess(abs(im.width * 2 - x.width), 2)
self.assertLess(abs(im.height * 2 - x.height), 2)
im = Vips.Image.new_from_file(self.pdf_file)
x = Vips.Image.new_from_file(self.pdf_file, dpi = 144)
self.assertLess(abs(im.width * 2 - x.width), 2)
self.assertLess(abs(im.height * 2 - x.height), 2)
def test_csv(self):
self.save_load("%s.csv", self.mono)