Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Programming question]: Converting SVG to GIF #190

Open
haesleinhuepf opened this issue Dec 26, 2024 · 1 comment
Open

[Programming question]: Converting SVG to GIF #190

haesleinhuepf opened this issue Dec 26, 2024 · 1 comment

Comments

@haesleinhuepf
Copy link
Owner

Is there a way to convert an SVG graphics to GIF or PNG?

git-bob answer

Copy link
Contributor

This message was generated by git-bob (version: 0.17.0, model: claude-3-5-sonnet-20241022, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

Hi there! Yes, you can convert SVG to GIF/PNG using Python. Here's a minimal example using the cairosvg library:

# Install library first:
# pip install cairosvg

import cairosvg

# Convert SVG to PNG
cairosvg.svg2png(url="input.svg", write_to="output.png")

# Convert SVG to GIF 
# (This first creates a PNG and then converts to GIF using PIL)
from PIL import Image
cairosvg.svg2png(url="input.svg", write_to="temp.png")
Image.open("temp.png").save("output.gif")

Just replace "input.svg" with the path to your SVG file. Let me know if you need any clarification!

Best,
git-bob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant