Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/scenarios/image_converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import concurrent.futures
import io
import math
from typing import Any, Iterable, cast

import imageio
Expand Down Expand Up @@ -139,22 +140,25 @@ def func_test_convert_image_and_revert(app: AppInstance) -> bool:
logger.info(
"got GIF with %d frames, metadata %s", actual_frames, gif.get_meta_data()
)
# count frames, should be 2 * 2 (original + reverted)
# count frames, should be 2 * 2 (original + reverted), or -1 if smooth revert is implemented (last frame is not duplicated)
expected_frames = len(images) * (2 if append_reverted else 1)
if actual_frames != expected_frames:
logger.warning("expected %d frames, got %d", expected_frames, actual_frames)
alt_expected_frames = (expected_frames - 1) if append_reverted else expected_frames
if actual_frames != expected_frames and actual_frames != alt_expected_frames:
logger.warning("expected %d or %d frames, got %d", expected_frames, alt_expected_frames, actual_frames)
return False
# reread the GIF file
gif = imageio.get_reader(r.content)
# Loop through the frames and check the durations and shapes
for index, _ in enumerate(cast(Iterable[Any], gif)):
frame_meta = gif.get_meta_data(index=index)
logger.info("frame %d: %s", index, frame_meta)
duration = frame_meta["duration"] // 10
if duration != delay:
logger.warning("frame duration is not %d ms: %d", delay, duration)
# empirically, we found the duration to be specified in ms (although this disagrees with what little documentation we found for the field)
duration = frame_meta["duration"]
Comment thread
tobiasvonarx marked this conversation as resolved.
min_duration = math.floor(delay/10) * 10 # delay converted to cs and floored
max_duration = math.ceil(delay/10) * 10 # delay converted to cs and ceiled
if not min_duration <= duration <= max_duration:
logger.warning("frame duration is not %f ms: %f", delay, duration)
return False

return True


Expand Down