diff --git a/Tests/images/op_index.qoi b/Tests/images/op_index.qoi new file mode 100644 index 000000000..e626aafe6 Binary files /dev/null and b/Tests/images/op_index.qoi differ diff --git a/Tests/test_file_qoi.py b/Tests/test_file_qoi.py index fd4b981ce..7ce1da209 100644 --- a/Tests/test_file_qoi.py +++ b/Tests/test_file_qoi.py @@ -28,3 +28,9 @@ def test_invalid_file() -> None: with pytest.raises(SyntaxError): QoiImagePlugin.QoiImageFile(invalid_file) + + +def test_op_index() -> None: + # QOI_OP_INDEX as the first chunk + with Image.open("Tests/images/op_index.qoi") as im: + assert im.getpixel((0, 0)) == (0, 0, 0, 0) diff --git a/src/PIL/QoiImagePlugin.py b/src/PIL/QoiImagePlugin.py index df552243e..75070abd7 100644 --- a/src/PIL/QoiImagePlugin.py +++ b/src/PIL/QoiImagePlugin.py @@ -51,7 +51,7 @@ class QoiDecoder(ImageFile.PyDecoder): assert self.fd is not None self._previously_seen_pixels = {} - self._add_to_previous_pixels(bytearray((0, 0, 0, 255))) + self._previous_pixel = bytearray((0, 0, 0, 255)) data = bytearray() bands = Image.getmodebands(self.mode)