Skip to main content

A package for exporting svg format

Project description

PySVGExport

Python Version Support PyPI Version GitHub license

SVGExport for Python

Idea from svgexport using for nodejs

Install via pip

pip3 install pysvgexport

Usage

1. Command-line
# See instruction
svgexport -h

# Export command example
svgexport -f SVG_FILE_PATH -s SCALE -o OUT_PUT_PNG
2. Inside a Python project
from pysvgexport import SVGExport

svg_data = '''
    <svg xmlns="http://www.w3.org/2000/svg"
         xmlns:xlink="http://www.w3.org/1999/xhtml" width="235.6875px" 
         height="112.37257096319047px" 
         viewBox="0 0 235.6875 112.37257096319047">
        <defs>
            <path d="M 29.050328462552656,81.24213909012583 A 120.43422075282764 
                     120.43422075282764 0&#10;    
                     0  1 206.63717153744733,81.24213909012583 Z" 
                  id="svg-text" />
        </defs>
        <text>
            <textPath xmlns:xlink="http://www.w3.org/1999/xhtml" 
                      xlink:href="#svg-text" lengthAdjust="spacing" 
                      fill="#1ebb6a" method="stretch" 
                      textLength="199.6875" spacing="auto" 
                      xml:space="preserve" 
                      style="font-size: 30px; 
                             letter-spacing: 0px; 
                             font-family: &quot;Aclonica.ttf&quot;;"
            >LALALALA text</textPath>
        </text>
    </svg>
'''
capture_options = {"scale": 20}
output_options = {"omitBackground": True}
svg_exporter = SVGExport(svg_data=svg_data, 
                         capture_options=capture_options, 
                         output_options=output_options)
image = svg_exporter.execute()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysvgexport-1.2.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

pysvgexport-1.2.2-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page