Skip to main content

Process & Manipulate SVG via Python API

banner

Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support

Aspose.SVG for Python via .NET is a powerful on-premise class library designed to seamlessly work with SVG files in a wide range of operations without the need for additional SVG manipulation tools. It allows you to create, edit, optimize, and convert SVG. Python API allows you to manipulate documents and elements and provides robust navigation and inspection functionalities, such as XPath queries and CSS selectors. Developers can also vectorize images and texts, apply SVG transformations, filters, gradients, and patterns, and specify colors in different color formats. Aspose.SVG for Python via .NET supports both Windows and Unix platforms, making it perfectly suited for building applications such as SVG editors, converters, mergers, and image vectorizers catering to developers who require extensive SVG processing capabilities.

SVG API Features

Why Choose Aspose.SVG for Python via .NET

  • Cross-Platform Compatibility – Aspose.SVG can be used to develop applications across different operating systems including Windows, Linux, and macOS.
  • Direct Programmatic Access – The Python API provides developers with direct access to the SVG elements and their properties, facilitating precise control over SVG content.
  • Versatile Document Manipulation The Python API enables comprehensive manipulation of SVG files, supporting a wide range of SVG specifications.
  • Extensive Documentation and Examples – Aspose.SVG for Python via .NET provides detailed documentation and guides to help developers understand and use the API effectively, along with code examples for common tasks.

General Features

The following are some popular features of Aspose.SVG for Python via .NET:

  • SVG Document Creation and Loading – Create SVGs from scratch or load them from strings, streams, files, or URLs. Async loading is supported for efficiently handling external resources.
  • SVG Document Editing and Modification – Insert new elements, update existing content, draw shapes, apply colors, and refine paths - all through intuitive Python code that manipulates the DOM.
  • SVG Navigation and Inspection – Navigate the SVG structure and inspect SVG documents using DOM methods, CSS selectors, or XPath queries to locate and work with specific elements.
  • High-Quality Conversion and Rendering – Convert SVG content to PDF, XPS, or image formats such as PNG and JPEG, with advanced rendering controls for resolution, background, and layout.
  • Image and Text Vectorization – Convert raster images into scalable SVG graphics, apply stylized stencil effects, or transform text into path elements.

Supported File Formats

Format Description Load Save
SVG Scalable Vector Graphics Format ✔️ ✔️
SVGZ Compressed version of SVG ✔️ ✔️
PDF Portable Document Format ✔️
XPS XML Paper Specification ✔️
TIFF Tagged Image File Format ✔️
BMP Bitmap Image File Format ✔️
PNG Portable Network Graphics ✔️
JPEG Joint Photographic Expert Group ✔️
GIF Graphical Interchange Format ✔️

Platform Independence

Aspose.SVG for Python via .NET is currently supported on Windows for developing applications where Python 3.6 or later is installed. You can build both 32-bit and 64-bit Python applications. Support for Linux and macOS X is planned for future versions.

Get Started

Ready to give Aspose.SVG for Python via .NET a try?

Simply run pip install aspose-svg-net from the Console to fetch the package. If you already have Aspose.SVG for Python via .NET and want to upgrade the version, please run pip install --upgrade aspose-svg-net to get the latest version.

You can run the following snippets in your environment to see how Aspose.SVG works, or check out the GitHub Repository or Aspose.SVG for Python via .NET Documentation for other common use cases.

Create SVG Using Aspose.SVG for Python via .NET

You can create SVG from a string content using SVGDocument(content, base_uri) constructor:

from aspose.svg import SVGDocument

documentContent = "<svg xmlns='http://www.w3.org/2000/svg'><circle cx='100' cy='100' r='40' stroke='#ff9390' stroke-width='4' fill='#FF7F50' /></svg>";

# Create a new SVG document
document = SVGDocument(documentContent, ".")

# Save the document
document.save("create-svg-from-string.svg")

Source - Create SVG File, Load and Read SVG in Python

Convert SVG to PNG

Aspose.SVG for Python via .NET also allows you to convert SVG to PDF, XPS, PNG, JPEG, TIFF, WEBP, and other file formats. The following snippet demonstrates the conversion from SVG to PNG literally with a single line of code!

from aspose.svg.converters import Converter
from aspose.svg.saving import ImageSaveOptions

# Convert SVG to PNG
Converter.convert_svg("document.svg", ImageSaveOptions(), "result.png")

Source - Convert SVG to PNG

Convert SVG to PDF using PdfSaveOptions

Aspose.SVG for Python via .NET also allows you to convert SVG to PDF, XPS, PNG, JPEG, TIFF, WEBP, and other file formats. The following snippet demonstrates the conversion from SVG to PNG literally with a single line of code!

from aspose.svg import SVGDocument
from aspose.svg.converters import Converter
from aspose.svg.rendering import SizingType
from aspose.svg.drawing import Resolution
from aspose.svg.saving import PdfSaveOptions
from aspose.pydrawing import Color

# Open the SVG file
with SVGDocument("document.svg") as document:

	# Create PDF save options and customize them
	options = PdfSaveOptions()
	options.background_color = Color.from_argb(0, 255, 255, 255)
	options.page_setup.sizing = SizingType.FIT_CONTENT
	options.horizontal_resolution = Resolution.from_dots_per_inch(96.0)
	options.vertical_resolution = Resolution.from_dots_per_inch(96.0)
	options.jpeg_quality = 80

	# Convert SVG to PDF
	Converter.convert_svg(document, options, "document.pdf")

Source - Convert SVG to PDF

Using Python to Vectorize Images

Aspose.SVG for Python via .NET also allows you can convert a raster image to vector graphic using default or custom configuration options. You will be able to apply custom settings to get the best result of the image-to-vector conversion and save the output SVG file to your computer. The following snippet demonstrates the image vectorization:

from aspose.svg.imagevectorization import BezierPathBuilder, ImageTraceSmoother, ImageVectorizer

# Set up Bezier path builder with smoothing and curve-fitting parameters
path_builder = BezierPathBuilder()
path_builder.trace_smoother = ImageTraceSmoother(2)
path_builder.error_threshold = 30.0
path_builder.max_iterations = 30

# Initialize the image vectorizer
vectorizer = ImageVectorizer()
vectorizer.configuration.path_builder = path_builder
vectorizer.configuration.colors_limit = 25
vectorizer.configuration.line_width = 1.0

# Vectorize the image
with vectorizer.vectorize("flower.jpg") as document:
    document.save("flower.svg")

Source - Vectorizing Images

Product Page | Docs | Demos | API Reference | Examples | Blog | Search | Free Support | Temporary License

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aspose_svg_net-26.8.0-py3-none-win_amd64.whl (57.3 MB view details)

Uploaded Python 3Windows x86-64

aspose_svg_net-26.8.0-py3-none-win32.whl (49.9 MB view details)

Uploaded Python 3Windows x86

aspose_svg_net-26.8.0-py3-none-manylinux1_x86_64.whl (78.6 MB view details)

Uploaded Python 3

aspose_svg_net-26.8.0-py3-none-macosx_10_14_x86_64.whl (70.4 MB view details)

Uploaded Python 3macOS 10.14+ x86-64

File details

Details for the file aspose_svg_net-26.8.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for aspose_svg_net-26.8.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d810fe24d0c1fb2fb5c255eb9998b5d82a6c5db65d612f276e4145745667ec8a
MD5 190e8977b78674afaead191f78dd824b
BLAKE2b-256 bb5894946372951a0dd462c56cd0fb9a92e7585df6cc8f7e810213ab09abb207

See more details on using hashes here.

File details

Details for the file aspose_svg_net-26.8.0-py3-none-win32.whl.

File metadata

  • Download URL: aspose_svg_net-26.8.0-py3-none-win32.whl
  • Upload date:
  • Size: 49.9 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.0

File hashes

Hashes for aspose_svg_net-26.8.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 8b8f4b2db9ebf9140205d13d4c0fb0be176d47f4982ebf9fc92c36e11869cd0d
MD5 b12ea89473b09264be71b6a0428c9adc
BLAKE2b-256 d3e1c27dda9838881623a784fa5f52c379deee5ad44ca8258a3bb019435464f5

See more details on using hashes here.

File details

Details for the file aspose_svg_net-26.8.0-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for aspose_svg_net-26.8.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 031463fd2e0a9e601544e926b191a939d85de2e2454c52e3f8549f706c2613a7
MD5 da9a8451bdf5344e168d82bfd631a5e5
BLAKE2b-256 b52d0031b4f2cfcd63bf3d54b3ab6250307bd6dd5c6de603f85f4143da4734ad

See more details on using hashes here.

File details

Details for the file aspose_svg_net-26.8.0-py3-none-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for aspose_svg_net-26.8.0-py3-none-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 33b8da5c791541bcefd1e338128a96bde2a6dacc0df831086971fe101c421d0c
MD5 14e44b248919f3c9820a2a9ddfab38fd
BLAKE2b-256 ca4317567c036c9973c5b636dd7ae6eea03738f1f134b760ab4c6f8bba76ed27

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

26.8.0 This release

4 files

26.7.0

4 files

26.6.0

4 files

26.5.0

4 files

26.4.0

4 files

26.3.0

4 files

26.2.0

4 files

26.1.0

4 files

25.12.0

4 files

25.11.0

4 files

25.10.0

4 files

25.9.0

4 files

25.8.0

3 files

25.7.0

3 files

25.6.0

3 files

25.5.0

3 files

25.4.0

3 files

25.3.0

3 files

25.2.0

3 files

25.1.0

3 files

24.12.1

3 files

24.11.0

3 files

24.10.0

3 files

24.9.0

2 files

24.8.0

2 files

24.7.0

2 files

24.6.0

2 files

24.5.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page