mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-09 14:54:46 +03:00
Added support for reading all Windows 1 formats
This commit is contained in:
parent
505c848c2b
commit
261a7281cc
BIN
Tests/images/ico1both.ico
Normal file
BIN
Tests/images/ico1both.ico
Normal file
Binary file not shown.
BIN
Tests/images/ico1device_dependent.ico
Normal file
BIN
Tests/images/ico1device_dependent.ico
Normal file
Binary file not shown.
|
@ -229,10 +229,20 @@ def test_draw_reloaded(tmp_path):
|
||||||
assert_image_equal_tofile(im, "Tests/images/hopper_draw.ico")
|
assert_image_equal_tofile(im, "Tests/images/hopper_draw.ico")
|
||||||
|
|
||||||
|
|
||||||
def test_ico1_open():
|
@pytest.mark.parametrize(
|
||||||
with Image.open("Tests/images/ico1.ico") as im:
|
"test_image_path",
|
||||||
|
(
|
||||||
|
"Tests/images/ico1device_independent.ico",
|
||||||
|
"Tests/images/ico1device_dependent.ico",
|
||||||
|
"Tests/images/ico1both.ico",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_ico1_open(test_image_path):
|
||||||
|
with Image.open(test_image_path) as im:
|
||||||
assert_image_equal_tofile(im, "Tests/images/ico1.png")
|
assert_image_equal_tofile(im, "Tests/images/ico1.png")
|
||||||
|
|
||||||
|
|
||||||
|
def test_ico1_invalid_file():
|
||||||
with open("Tests/images/flower.jpg", "rb") as fp:
|
with open("Tests/images/flower.jpg", "rb") as fp:
|
||||||
with pytest.raises(SyntaxError):
|
with pytest.raises(SyntaxError):
|
||||||
IcoImagePlugin.Ico1ImageFile(fp)
|
IcoImagePlugin.Ico1ImageFile(fp)
|
||||||
|
|
|
@ -345,7 +345,8 @@ The :py:meth:`~PIL.Image.Image.save` method can take the following keyword argum
|
||||||
ICO1
|
ICO1
|
||||||
^^^^
|
^^^^
|
||||||
|
|
||||||
Pillow also reads and writes device-independent Windows 1.0 icons.
|
Pillow also reads Windows 1.0 icons in all three formats ("Device-Independent",
|
||||||
|
"Device-Dependent" and "Both"), and writes them in "Device-Independent" format.
|
||||||
|
|
||||||
.. versionadded:: 10.1.0
|
.. versionadded:: 10.1.0
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ class IcoImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
|
|
||||||
def _ico1_accept(prefix):
|
def _ico1_accept(prefix):
|
||||||
return prefix[:2] == b"\1\0"
|
return prefix[0] == 1 and prefix[1] in (0, 1, 2)
|
||||||
|
|
||||||
|
|
||||||
class Ico1ImageFile(ImageFile.ImageFile):
|
class Ico1ImageFile(ImageFile.ImageFile):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user