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

Convert animated svg into a png sequence #313

Open
qo4on opened this issue Feb 15, 2023 · 2 comments
Open

Convert animated svg into a png sequence #313

qo4on opened this issue Feb 15, 2023 · 2 comments

Comments

@qo4on
Copy link

qo4on commented Feb 15, 2023

I didn't manage to convert this animated svg into a png sequence. Is it possible
anim

@stuaxo
Copy link
Collaborator

stuaxo commented Feb 15, 2023

Yes, though pycairo is a thing that outputs svgs rather than inputs them.
You need a higher level library that can load the SVGs (that may be a library that renders using cairo).

What did you try ?

OT: The SVG itself is quite pleasing / mesmerising to look at.

@qo4on
Copy link
Author

qo4on commented Feb 15, 2023

I tried this

import rsvg

width = 200
height = 200

svg = rsvg.Handle('anim.svg')
unscaled_width = svg.props.width
unscaled_height = svg.props.height

svg_surface = cairo.SVGSurface(None, width, height)
svg_context = cairo.Context(svg_surface)
svg_context.save()
svg_context.scale(width/unscaled_width, height/unscaled_height)
svg.render_cairo(svg_context)
svg_context.restore()

svg_surface.write_to_png('cool.png')

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

2 participants