My code is:
Code: Select all
from wand.image import Image
import StringIO
import os
print os.environ['MAGICK_HOME']
svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" xml:space="preserve" height="241" width="386"><g xmlns="http://www.w3.org/2000/svg" fill="none" stroke="none" stroke-width="none" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="sans-serif" font-weight="normal" font-size="12" text-anchor="start" mix-blend-mode="normal"><path d="M165.2135,102.5625c0,-8.99478 7.29171,-16.2865 16.2865,-16.2865c8.99478,0 16.2865,7.29171 16.2865,16.2865c0,8.99478 -7.29171,16.2865 -16.2865,16.2865c-8.99478,0 -16.2865,-7.29171 -16.2865,-16.2865z" fill="#808080" stroke="#ffff00" stroke-width="3" opacity="0.3"/></g></svg>'
st = StringIO.StringIO(svg)
st.seek(0)
with Image(filename='C:/Users/Sandeep/temp/test.svg', format='svg') as img:
img.format='png'
img.save(filename="C:/Users/Sandeep/temp/s.png")
with Image(file=st, format='svg') as img:
img.format='png'
img.save(filename="C:/Users/Sandeep/temp/t.png")
Thanks