Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open 1 bit EPS in mode 1 #6499

Merged
merged 1 commit into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Tests/images/1.eps
Binary file not shown.
5 changes: 5 additions & 0 deletions Tests/test_file_eps.py
Expand Up @@ -146,6 +146,11 @@ def test_bytesio_object():
assert_image_similar(img, image1_scale1_compare, 5)


def test_1_mode():
with Image.open("Tests/images/1.eps") as im:
assert im.mode == "1"


def test_image_mode_not_supported(tmp_path):
im = hopper("RGBA")
tmpfile = str(tmp_path / "temp.eps")
Expand Down
13 changes: 8 additions & 5 deletions src/PIL/EpsImagePlugin.py
Expand Up @@ -288,11 +288,14 @@ def _open(self):
# Encoded bitmapped image.
x, y, bi, mo = s[11:].split(None, 7)[:4]

if int(bi) != 8:
break
try:
self.mode = self.mode_map[int(mo)]
except ValueError:
if int(bi) == 1:
self.mode = "1"
elif int(bi) == 8:
try:
self.mode = self.mode_map[int(mo)]
except ValueError:
break
else:
break

self._size = int(x), int(y)
Expand Down