Skip to content

Commit 7f7c27f

Browse files
authored
Start QOI decoding with a zero-initialized array of previously seen pixels (#9008)
2 parents 3eb893f + e65e5be commit 7f7c27f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Tests/images/op_index.qoi

15 Bytes
Binary file not shown.

Tests/test_file_qoi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ def test_invalid_file() -> None:
2828

2929
with pytest.raises(SyntaxError):
3030
QoiImagePlugin.QoiImageFile(invalid_file)
31+
32+
33+
def test_op_index() -> None:
34+
# QOI_OP_INDEX as the first chunk
35+
with Image.open("Tests/images/op_index.qoi") as im:
36+
assert im.getpixel((0, 0)) == (0, 0, 0, 0)

src/PIL/QoiImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int
5151
assert self.fd is not None
5252

5353
self._previously_seen_pixels = {}
54-
self._add_to_previous_pixels(bytearray((0, 0, 0, 255)))
54+
self._previous_pixel = bytearray((0, 0, 0, 255))
5555

5656
data = bytearray()
5757
bands = Image.getmodebands(self.mode)

0 commit comments

Comments
 (0)