From 95d619add541d58e432509e8b9082be268ad7b45 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 30 Jun 2015 18:29:29 -0700 Subject: [PATCH] libtiff's rational precision is limited to C floats. --- Tests/test_file_libtiff.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 80626c378..145719b18 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1,6 +1,7 @@ from __future__ import print_function from helper import unittest, PillowTestCase, hopper, py3 +from ctypes import c_float import io import itertools import os @@ -138,10 +139,23 @@ class TestFileLibTiff(LibTiffTestCase): loaded.tag.legacy_api = legacy_api reloaded = loaded.tag.named() - for tag, value in itertools.chain(reloaded.items(), original.items()): + for tag, value in itertools.chain(reloaded.items(), + original.items()): if tag not in ignored: val = original[tag] - self.assertEqual(val, value, msg="%s didn't roundtrip" % tag) + if tag.endswith('Resolution'): + if legacy_api: + self.assertEqual( + c_float(val[0][0] / val[0][1]).value, + c_float(value[0][0] / value[0][1]).value, + msg="%s didn't roundtrip" % tag) + else: + self.assertEqual( + c_float(val).value, c_float(value).value, + msg="%s didn't roundtrip" % tag) + else: + self.assertEqual( + val, value, msg="%s didn't roundtrip" % tag) def test_g3_compression(self): i = Image.open('Tests/images/hopper_g4_500.tif')