mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-23 19:44:13 +03:00
Corrected check for libtiff feature
This commit is contained in:
parent
db21e7de1c
commit
71029803e7
|
@ -3,10 +3,12 @@ from __future__ import annotations
|
||||||
from fractions import Fraction
|
from fractions import Fraction
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from PIL import Image, TiffImagePlugin, features
|
import pytest
|
||||||
|
|
||||||
|
from PIL import Image, TiffImagePlugin
|
||||||
from PIL.TiffImagePlugin import IFDRational
|
from PIL.TiffImagePlugin import IFDRational
|
||||||
|
|
||||||
from .helper import hopper
|
from .helper import hopper, skip_unless_feature
|
||||||
|
|
||||||
|
|
||||||
def _test_equal(num, denom, target) -> None:
|
def _test_equal(num, denom, target) -> None:
|
||||||
|
@ -52,18 +54,17 @@ def test_nonetype() -> None:
|
||||||
assert xres and yres
|
assert xres and yres
|
||||||
|
|
||||||
|
|
||||||
def test_ifd_rational_save(tmp_path: Path) -> None:
|
@pytest.mark.parametrize(
|
||||||
methods = [True]
|
"libtiff", (pytest.param(True, marks=skip_unless_feature("libtiff")), False)
|
||||||
if features.check("libtiff"):
|
)
|
||||||
methods.append(False)
|
def test_ifd_rational_save(tmp_path: Path, libtiff: bool) -> None:
|
||||||
|
im = hopper()
|
||||||
|
out = str(tmp_path / "temp.tiff")
|
||||||
|
res = IFDRational(301, 1)
|
||||||
|
|
||||||
for libtiff in methods:
|
TiffImagePlugin.WRITE_LIBTIFF = libtiff
|
||||||
TiffImagePlugin.WRITE_LIBTIFF = libtiff
|
im.save(out, dpi=(res, res), compression="raw")
|
||||||
|
TiffImagePlugin.WRITE_LIBTIFF = False
|
||||||
|
|
||||||
im = hopper()
|
with Image.open(out) as reloaded:
|
||||||
out = str(tmp_path / "temp.tiff")
|
assert float(IFDRational(301, 1)) == float(reloaded.tag_v2[282])
|
||||||
res = IFDRational(301, 1)
|
|
||||||
im.save(out, dpi=(res, res), compression="raw")
|
|
||||||
|
|
||||||
with Image.open(out) as reloaded:
|
|
||||||
assert float(IFDRational(301, 1)) == float(reloaded.tag_v2[282])
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user