This commit is contained in:
student_2333 2024-11-06 02:22:54 +08:00
parent 1f21034b4c
commit 929f649e9c
No known key found for this signature in database
GPG Key ID: 665F083BEC56F2A6

View File

@ -108,11 +108,10 @@ def get_avg_duration(image: Img.Image) -> float:
if not getattr(image, "is_animated", False):
return 0
total_duration = 0
n_frames = getattr(image, "n_frames", 1)
for i in range(n_frames):
image.seek(i)
total_duration += image.info.get("duration", 20)
return total_duration / n_frames / 1000
frames = list(ImageSequence.Iterator(image))
for frame in frames:
total_duration += frame.info.get("duration", 20)
return total_duration / len(frames) / 1000
@repack_saver(PilImageFrameSource)