Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
MIT (Unified Message Relay)
AGPL 3.0 (Python Lottie)
"""
# Import only upon calling the method due to added binary dependencies
# (libcairo)
from lottie.exporters.cairo import export_png
from lottie.exporters.gif import _png_gif_prepare
start = int(animation.in_point)
end = int(animation.out_point)
frames = []
for i in range(start, end+1, skip_frames):
file = BytesIO()
export_png(animation, file, i, dpi)
file.seek(0)
frames.append(_png_gif_prepare(Image.open(file)))
duration = 1000 / animation.frame_rate * (1 + skip_frames) / 2
frames[0].save(
fp,
format='GIF',
append_images=frames[1:],
save_all=True,
duration=duration,
loop=0,
transparency=255,
disposal=2,
)