Skip to content

Commit

Permalink
Merge pull request #643 from jacebrowning/scale-duration
Browse files Browse the repository at this point in the history
Scale GIF duration based on the numbers of frames rendered
  • Loading branch information
jacebrowning committed Oct 6, 2021
2 parents a092f2e + 24fd035 commit 5395f54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion app/utils/images.py
Expand Up @@ -192,7 +192,6 @@ def render_animation(
source = Image.open(template.get_image(style="animated"))
total = getattr(source, "n_frames", 1)
modulus = max(1, round(total / settings.MAXIMUM_FRAMES, 1))
duration = source.info.get("duration", 100) * modulus
if size[0] and size[0] <= settings.PREVIEW_SIZE[0] and not settings.DEBUG:
watermark = ""

Expand Down Expand Up @@ -255,6 +254,9 @@ def render_animation(

frames.append(image)

ratio = len(frames) / total
duration = source.info.get("duration", 100) / ratio

return frames, duration


Expand Down

0 comments on commit 5395f54

Please sign in to comment.