diff --git a/Tests/images/op_index.qoi b/Tests/images/op_index.qoi new file mode 100644 index 00000000000..e626aafe6a4 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 fd4b981ce93..7ce1da2099d 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 df552243e37..75070abd740 100644 --- a/src/PIL/QoiImagePlugin.py +++ b/src/PIL/QoiImagePlugin.py @@ -51,7 +51,7 @@ def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int 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)