Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
https://github.com/jqqqqqqqqqq/UnifiedMessageRelay/blob/c920d005714a33fbd50594ef8013ce7ec2f3b240/src/Core/UMRFile.py#L141
License:
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,
)