diff --git a/Tests/images/1.eps b/Tests/images/1.eps new file mode 100644 index 00000000000..727dc9b7f04 Binary files /dev/null and b/Tests/images/1.eps differ diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 1790f4f7701..766c5064920 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -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") diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index 3b782d6b353..0e434c5c0ea 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -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)