From be2100be7b02c09d840442e4d259150c0919c553 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Fri, 6 May 2016 09:07:00 -0700 Subject: [PATCH] Skip tests that require libtiff if it is not installed, fixes #1866 --- Tests/test_file_libtiff.py | 15 +++++++++++++++ Tests/test_tiff_ifdrational.py | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 83d347239..e899ab930 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -489,6 +489,21 @@ class TestFileLibTiff(LibTiffTestCase): im.save(out, format='TIFF') TiffImagePlugin.WRITE_LIBTIFF = False + def test_page_number_x_0(self): + # Issue 973 + # Test TIFF with tag 297 (Page Number) having value of 0 0. + # The first number is the current page number. + # The second is the total number of pages, zero means not available. + outfile = self.tempfile("temp.tif") + # Created by printing a page in Chrome to PDF, then: + # /usr/bin/gs -q -sDEVICE=tiffg3 -sOutputFile=total-pages-zero.tif + # -dNOPAUSE /tmp/test.pdf -c quit + infile = "Tests/images/total-pages-zero.tif" + im = Image.open(infile) + # Should not divide by zero + im.save(outfile) + + if __name__ == '__main__': unittest.main() diff --git a/Tests/test_tiff_ifdrational.py b/Tests/test_tiff_ifdrational.py index c2c58acd5..3a38f2237 100644 --- a/Tests/test_tiff_ifdrational.py +++ b/Tests/test_tiff_ifdrational.py @@ -45,7 +45,11 @@ class Test_IFDRational(PillowTestCase): self.assertTrue(xres and yres) def test_ifd_rational_save(self): - for libtiff in (True, False): + methods = (True, False) + if 'libtiff_encoder' not in dir(Image.core): + methods = (False) + + for libtiff in methods: TiffImagePlugin.WRITE_LIBTIFF = libtiff im = hopper()