[Python] Get dimensions - or proportions - of an SVG file with CairoSVG

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using CairoSVG successfully in my Python project - md2pptx.

    It converts SVG to PNG and that is then scaled to fit a space on the relevant PowerPoint slide.

    It would be better to scale the SVG file on conversion rather than subsequently. But I don't kno3w the proportions (or dimensions) of the SVG file.

    Yes, I could parse the XML in my own code - but it's better not to.

    CairoSVG appears to have an internal method for getting this information - but not an externalised one.

    How can I use CairoSVG in Python 3 to get the proportions or dimensions?

    Continue reading...

Compartilhe esta Página