MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / export_to_gif

Function export_to_gif

app.py:65–84  ·  view source on GitHub ↗

Export a list of frames to a GIF. Args: - frames (list): List of frames (as numpy arrays or PIL Image objects). - output_gif_path (str): Path to save the output GIF. - duration_ms (int): Duration of each frame in milliseconds.

(frames, output_gif_path, fps)

Source from the content-addressed store, hash-verified

63
64
65def export_to_gif(frames, output_gif_path, fps):
66 """
67 Export a list of frames to a GIF.
68
69 Args:
70 - frames (list): List of frames (as numpy arrays or PIL Image objects).
71 - output_gif_path (str): Path to save the output GIF.
72 - duration_ms (int): Duration of each frame in milliseconds.
73
74 """
75 # Convert numpy arrays to PIL Images if needed
76 pil_frames = [Image.fromarray(frame) if isinstance(
77 frame, np.ndarray) else frame for frame in frames]
78
79 pil_frames[0].save(output_gif_path.replace('.mp4', '.gif'),
80 format='GIF',
81 append_images=pil_frames[1:],
82 save_all=True,
83 duration=125,
84 loop=0)
85
86
87def generate(

Callers 1

generateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected