mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Added state methods to allow pickling of IFDRational
This commit is contained in:
parent
537cd7a82e
commit
b78cf8cd75
|
@ -146,7 +146,8 @@ class TestFileTiff:
|
|||
"Tests/images/hopper_float_dpi_" + str(resolutionUnit) + ".tif"
|
||||
) as im:
|
||||
assert im.tag_v2.get(RESOLUTION_UNIT) == resolutionUnit
|
||||
assert im.info["dpi"] == (dpi, dpi)
|
||||
for reloaded_dpi in im.info["dpi"]:
|
||||
assert float(reloaded_dpi) == dpi
|
||||
|
||||
def test_save_float_dpi(self, tmp_path):
|
||||
outfile = str(tmp_path / "temp.tif")
|
||||
|
@ -154,7 +155,8 @@ class TestFileTiff:
|
|||
im.save(outfile, dpi=(72.2, 72.2))
|
||||
|
||||
with Image.open(outfile) as reloaded:
|
||||
assert reloaded.info["dpi"] == (72.2, 72.2)
|
||||
for dpi in reloaded.info["dpi"]:
|
||||
assert float(dpi) == 72.2
|
||||
|
||||
def test_save_setting_missing_resolution(self):
|
||||
b = BytesIO()
|
||||
|
|
|
@ -358,6 +358,16 @@ class IFDRational(Rational):
|
|||
other = other._val
|
||||
return self._val == other
|
||||
|
||||
def __getstate__(self):
|
||||
return [self._val, self._numerator, self._denominator]
|
||||
|
||||
def __setstate__(self, state):
|
||||
IFDRational.__init__(self, 0)
|
||||
_val, _numerator, _denominator = state
|
||||
self._val = _val
|
||||
self._numerator = _numerator
|
||||
self._denominator = _denominator
|
||||
|
||||
def _delegate(op):
|
||||
def delegate(self, *args):
|
||||
return getattr(self._val, op)(*args)
|
||||
|
|
Loading…
Reference in New Issue
Block a user