Skip to content

Commit 014a7e5

Browse files
committed
Simplified code
1 parent 9096240 commit 014a7e5

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Tests/test_file_jxl_alpha.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .helper import assert_image_similar_tofile, skip_unless_feature
66

7-
pytestmark = [skip_unless_feature("jpegxl")]
7+
pytestmark = skip_unless_feature("jpegxl")
88

99

1010
def test_read_rgba() -> None:

Tests/test_file_jxl_animated.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .helper import assert_image_equal, skip_unless_feature
88

9-
pytestmark = [skip_unless_feature("jpegxl")]
9+
pytestmark = skip_unless_feature("jpegxl")
1010

1111

1212
def test_n_frames() -> None:
@@ -27,7 +27,7 @@ def test_float_duration() -> None:
2727
assert im.info["duration"] == 70
2828

2929

30-
def test_seeking() -> None:
30+
def test_seek() -> None:
3131
"""
3232
Open an animated jxl file, and then try seeking through frames in reverse-order,
3333
verifying the durations are correct.
@@ -42,9 +42,7 @@ def test_seeking() -> None:
4242
total_dur = 0
4343
for frame in reversed(range(im1.n_frames)):
4444
im1.seek(frame)
45-
im1.load()
4645
im2.seek(frame)
47-
im2.load()
4846

4947
assert_image_equal(im1.convert("RGB"), im2.convert("RGB"))
5048

Tests/test_file_jxl_metadata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from .helper import skip_unless_feature
1010

11-
pytestmark = [skip_unless_feature("jpegxl")]
11+
pytestmark = skip_unless_feature("jpegxl")
1212

1313
ElementTree: ModuleType | None
1414
try:
@@ -33,8 +33,8 @@ def test_read_exif_metadata() -> None:
3333

3434
exif = im.getexif()
3535

36-
# Camera make
37-
assert exif[271] == "Canon"
36+
# Camera make
37+
assert exif[271] == "Canon"
3838

3939
with Image.open("Tests/images/flower.jpg") as im_jpeg:
4040
expected_exif = im_jpeg.info["exif"]
@@ -49,7 +49,7 @@ def test_read_exif_metadata_without_prefix() -> None:
4949
assert im.info["exif"][:6] != b"Exif\x00\x00"
5050

5151
exif = im.getexif()
52-
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
52+
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
5353

5454

5555
def test_read_icc_profile() -> None:

src/PIL/JpegXlImagePlugin.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
## Future idea:
17-
## it's not known how many frames does animated image have
17+
## it's not known how many frames an animated image has
1818
## by default, _jxl_decoder_new will iterate over all frames without decoding them
1919
## then libjxl decoder is rewinded and we're ready to decode frame by frame
2020
## if OPEN_COUNTS_FRAMES is False, n_frames will be None until the last frame is decoded
@@ -74,8 +74,7 @@ def _open(self) -> None:
7474

7575
self._rewind()
7676

77-
def _get_next(self) -> tuple[bytes, float, float, bool]:
78-
77+
def _get_next(self) -> tuple[bytes, float, float]:
7978
# Get next frame
8079
next_frame = self._decoder.get_next()
8180
self.__physical_frame += 1
@@ -95,7 +94,7 @@ def _get_next(self) -> tuple[bytes, float, float, bool]:
9594
timestamp = self.__timestamp
9695
self.__timestamp += duration
9796

98-
return data, timestamp, duration, is_last
97+
return data, timestamp, duration
9998

10099
def _rewind(self, hard: bool = False) -> None:
101100
if hard:
@@ -125,7 +124,7 @@ def load(self) -> Image.core.PixelAccess | None:
125124
if self.__loaded != self.__logical_frame:
126125
self._seek(self.__logical_frame)
127126

128-
data, timestamp, duration, is_last = self._get_next()
127+
data, timestamp, duration = self._get_next()
129128
self.info["timestamp"] = timestamp
130129
self.info["duration"] = duration
131130
self.__loaded = self.__logical_frame

0 commit comments

Comments
 (0)