Skip to content

Gif support? #71

Answered by GuardKenzie
ixenion asked this question in Q&A
Discussion options

You must be logged in to vote

Hiya! GIF support is not a part of the Chafa API. The command line application renders gifs by parsing its frames and using the API to render them as images. I threw together some code that achieves similar results, but could probably be significantly optimized:

✏️ Code
import chafa
from PIL import Image
from pathlib import Path
import time

DIR = Path(__file__).parent

frames = []

# We extract all the frames from the gif and wrap them in chafa.Frame objects
with Image.open(DIR / "frieren.gif") as animation:
    animation.seek(0)

    total_frames = animation.n_frames
    
    width     = animation.width
    height    = animation.height
    rowstride = width * 3          # We convert ea…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by GuardKenzie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants