aspose-svg-net 26.1.0
Aspose.SVG for Python via .NET enables creating, editing, rendering, and converting SVGs to formats like PNG, PDF, and more, excelling in image vectorization. Perfect for developing SVG tools.
Requires Python: <3.14,>=3.5
Keywords: Aspose, Aspose.SVG, Aspose.Total, Python, Component, Conholdate, Conholdate.Total, convert, converter, vectorization, vectorizer, vectorize, encoding, base64, css, DOM, dom-manipulation, image, JPEG, Library, Linux, macOS, Microsoft, mvc, net-standard, netcore, netstandard, to PDF, PNG, rotate, security, Standard, svg, svg-to-gif, svg-to-jpeg, svg-to-pdf, svg-to-png, svg-to-tiff, svg-to-xps, png-to-svg, jpg-to-svg, VisualStudio, XPath, XPS, SVG, Windows, Vector Graphics, line, Bezier Curves, Cubic, Glyphs, Paths, Text, Scaling, Rotation, Skewing, Fill, Dots, Bitmap, HTML, Filters, Gaussian, Shadow, Lighting Effects, Color, Linear, Radial

# Process & Manipulate SVG via Python API

<!--- banner links to [Temporary License](https://purchase.aspose.com/temporary-license) -->
[![banner](https://products.aspose.com/svg/images/aspose_svg-for-python-banner-TL.png)](https://purchase.aspose.com/temporary-license)

[Product Page](https://products.aspose.com/svg/python-net/) | [Docs](https://docs.aspose.com/svg/python-net/) | [Demos](https://products.aspose.app/svg/applications) | [API Reference](https://reference.aspose.com/svg/) | [Examples](https://github.com/aspose-svg/) | [Blog](https://blog.aspose.com/categories/aspose.svg-product-family/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/svg) 

[Aspose.SVG for Python via .NET](https://products.aspose.com/svg/python-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](https://docs.fileformat.com/page-description-language/svg/)     | Scalable Vector Graphics Format      | ✔️    | ✔️    |
| [SVGZ](https://docs.fileformat.com/image/svgz/)    | Compressed version of SVG            | ✔️    | ✔️    |
| [PDF](https://docs.fileformat.com/pdf/)     | Portable Document Format             |      | ✔️    |
| [XPS](https://docs.fileformat.com/page-description-language/xps/)     | XML Paper Specification              |      | ✔️    |
| [TIFF](https://docs.fileformat.com/image/tiff/)    | Tagged Image File Format             |      | ✔️    |
| [BMP](https://docs.fileformat.com/image/bmp/)     | Bitmap Image File Format             |      | ✔️    |
| [PNG](https://docs.fileformat.com/image/png/)     | Portable Network Graphics            |      | ✔️    |
| [JPEG](https://docs.fileformat.com/image/jpeg/)    | Joint Photographic Expert Group      |      | ✔️    |
| [GIF](https://docs.fileformat.com/image/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](https://github.com/aspose-svg/) or [Aspose.SVG for Python via .NET Documentation](https://docs.aspose.com/svg/python-net/) 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:

```python
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](https://docs.aspose.com/svg/python-net/create-svg-file/)

## 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!

```python
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](https://docs.aspose.com/svg/python-net/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!

```python
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](https://docs.aspose.com/svg/python-net/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:

```python
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](https://docs.aspose.com/svg/python-net/vectorize-images/)

[Product Page](https://products.aspose.com/svg/python-net/) | [Docs](https://docs.aspose.com/svg/python-net/) | [Demos](https://products.aspose.app/svg/applications) | [API Reference](https://reference.aspose.com/svg/python-net/) | [Examples](https://github.com/aspose-svg/) | [Blog](https://blog.aspose.com/categories/aspose.svg-product-family/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/svg) | [Temporary License](https://purchase.aspose.com/temporary-license)