mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-02-05 23:09:33 +03:00
Simplified code
This commit is contained in:
parent
9096240a63
commit
762235cd56
|
|
@ -4,7 +4,7 @@ from PIL import Image
|
|||
|
||||
from .helper import assert_image_similar_tofile, skip_unless_feature
|
||||
|
||||
pytestmark = [skip_unless_feature("jpegxl")]
|
||||
pytestmark = skip_unless_feature("jpegxl")
|
||||
|
||||
|
||||
def test_read_rgba() -> None:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from PIL import Image
|
|||
|
||||
from .helper import assert_image_equal, skip_unless_feature
|
||||
|
||||
pytestmark = [skip_unless_feature("jpegxl")]
|
||||
pytestmark = skip_unless_feature("jpegxl")
|
||||
|
||||
|
||||
def test_n_frames() -> None:
|
||||
|
|
@ -27,7 +27,7 @@ def test_float_duration() -> None:
|
|||
assert im.info["duration"] == 70
|
||||
|
||||
|
||||
def test_seeking() -> None:
|
||||
def test_seek() -> None:
|
||||
"""
|
||||
Open an animated jxl file, and then try seeking through frames in reverse-order,
|
||||
verifying the durations are correct.
|
||||
|
|
@ -42,9 +42,7 @@ def test_seeking() -> None:
|
|||
total_dur = 0
|
||||
for frame in reversed(range(im1.n_frames)):
|
||||
im1.seek(frame)
|
||||
im1.load()
|
||||
im2.seek(frame)
|
||||
im2.load()
|
||||
|
||||
assert_image_equal(im1.convert("RGB"), im2.convert("RGB"))
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from PIL import Image, JpegXlImagePlugin
|
|||
|
||||
from .helper import skip_unless_feature
|
||||
|
||||
pytestmark = [skip_unless_feature("jpegxl")]
|
||||
pytestmark = skip_unless_feature("jpegxl")
|
||||
|
||||
ElementTree: ModuleType | None
|
||||
try:
|
||||
|
|
@ -33,8 +33,8 @@ def test_read_exif_metadata() -> None:
|
|||
|
||||
exif = im.getexif()
|
||||
|
||||
# Camera make
|
||||
assert exif[271] == "Canon"
|
||||
# Camera make
|
||||
assert exif[271] == "Canon"
|
||||
|
||||
with Image.open("Tests/images/flower.jpg") as im_jpeg:
|
||||
expected_exif = im_jpeg.info["exif"]
|
||||
|
|
@ -49,7 +49,7 @@ def test_read_exif_metadata_without_prefix() -> None:
|
|||
assert im.info["exif"][:6] != b"Exif\x00\x00"
|
||||
|
||||
exif = im.getexif()
|
||||
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
|
||||
assert exif[305] == "Adobe Photoshop CS6 (Macintosh)"
|
||||
|
||||
|
||||
def test_read_icc_profile() -> None:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ except ImportError:
|
|||
|
||||
|
||||
## Future idea:
|
||||
## it's not known how many frames does animated image have
|
||||
## it's not known how many frames an animated image has
|
||||
## by default, _jxl_decoder_new will iterate over all frames without decoding them
|
||||
## then libjxl decoder is rewinded and we're ready to decode frame by frame
|
||||
## if OPEN_COUNTS_FRAMES is False, n_frames will be None until the last frame is decoded
|
||||
|
|
@ -74,8 +74,7 @@ class JpegXlImageFile(ImageFile.ImageFile):
|
|||
|
||||
self._rewind()
|
||||
|
||||
def _get_next(self) -> tuple[bytes, float, float, bool]:
|
||||
|
||||
def _get_next(self) -> tuple[bytes, float, float]:
|
||||
# Get next frame
|
||||
next_frame = self._decoder.get_next()
|
||||
self.__physical_frame += 1
|
||||
|
|
@ -95,7 +94,7 @@ class JpegXlImageFile(ImageFile.ImageFile):
|
|||
timestamp = self.__timestamp
|
||||
self.__timestamp += duration
|
||||
|
||||
return data, timestamp, duration, is_last
|
||||
return data, timestamp, duration
|
||||
|
||||
def _rewind(self, hard: bool = False) -> None:
|
||||
if hard:
|
||||
|
|
@ -125,9 +124,7 @@ class JpegXlImageFile(ImageFile.ImageFile):
|
|||
if self.__loaded != self.__logical_frame:
|
||||
self._seek(self.__logical_frame)
|
||||
|
||||
data, timestamp, duration, is_last = self._get_next()
|
||||
self.info["timestamp"] = timestamp
|
||||
self.info["duration"] = duration
|
||||
data, self.info["timestamp"], self.info["duration"] = self._get_next()
|
||||
self.__loaded = self.__logical_frame
|
||||
|
||||
# Set tile
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user