1
from __future__ import annotations
5
from PIL import Image, ImagePalette
7
from .helper import assert_image_similar, hopper, skip_unless_feature
9
MicImagePlugin = pytest.importorskip(
10
"PIL.MicImagePlugin", reason="olefile not installed"
12
pytestmark = skip_unless_feature("libtiff")
13
TEST_FILE = "Tests/images/hopper.mic"
16
def test_sanity() -> None:
17
with Image.open(TEST_FILE) as im:
19
assert im.mode == "RGBA"
20
assert im.size == (128, 128)
21
assert im.format == "MIC"
24
lut = ImagePalette.make_gamma_lut(1 / 2.2)
25
im = Image.merge("RGBA", [chan.point(lut) for chan in im.split()])
28
assert_image_similar(im, im2, 10)
31
def test_n_frames() -> None:
32
with Image.open(TEST_FILE) as im:
33
assert im.n_frames == 1
36
def test_is_animated() -> None:
37
with Image.open(TEST_FILE) as im:
38
assert not im.is_animated
41
def test_tell() -> None:
42
with Image.open(TEST_FILE) as im:
46
def test_seek() -> None:
47
with Image.open(TEST_FILE) as im:
51
with pytest.raises(EOFError):
56
def test_close() -> None:
57
with Image.open(TEST_FILE) as im:
59
assert im.ole.fp.closed
61
im = Image.open(TEST_FILE)
63
assert im.ole.fp.closed
66
def test_invalid_file() -> None:
68
invalid_file = "Tests/images/flower.jpg"
69
with pytest.raises(SyntaxError):
70
MicImagePlugin.MicImageFile(invalid_file)
73
ole_file = "Tests/images/test-ole-file.doc"
74
with pytest.raises(SyntaxError):
75
MicImagePlugin.MicImageFile(ole_file)