Saturday, 30 October 2021

How to render SVG image to PNG file in Python?

So I want to render SVG from python code having target resolution WxH (having SVG text as str, like this that I generate dynamically):

<svg width="200" height="200" viewBox="0 0 220 220"
     xmlns="http://www.w3.org/2000/svg">
  <filter id="displacementFilter">
    <feTurbulence type="turbulence" baseFrequency="0.05"
        numOctaves="2" result="turbulence"/>
    <feDisplacementMap in2="turbulence" in="SourceGraphic"
        scale="50" xChannelSelector="R" yChannelSelector="G"/>
  </filter>

  <circle cx="100" cy="100" r="100"
      style="filter: url(#displacementFilter)"/>
</svg>

into a png image. How to do such a thing in Python?



from How to render SVG image to PNG file in Python?

No comments:

Post a Comment