SVG Conversion in Python
Convert SVG to PDF, XPS, and various image formats, including JPEG, PNG, BMP, TIFF, and GIF, either online or using a Python library.
How to Convert SVG in Python
SVG (Scalable Vector Graphics) is an XML-based image format designed for two-dimensional graphics and primarily intended for the web. SVG’s outstanding feature is its unrivaled ability to scale to any size without losing quality. Although all modern browsers support SVG, and it seems ideal for the web, some restrictions still exist, which sometimes require SVG conversion to other formats.
Aspose.SVG for Python via .NET API simplifies the conversion process for developers. The Converter class provides easy and convenient conversion of SVG files to popular formats, making it an effective solution.
Online SVG Converter
You can convert SVG files in real time using Aspose.SVG for Python via .NET API. The following Python example demonstrates how to convert an SVG document. Simply load an SVG file from your local file system or a URL, select the output format, and run the example. You will receive the result as a separate file immediately. Try it right now!
import aspose from aspose.svg import * from aspose.svg.converters import * from aspose.svg.drawing.skiasharp import * from aspose.svg.saving import * # Register the SkiaSharp drawing extension for rendering Configuration.set_extension(SkiaModule()) # Load an SVG document from a file with SVGDocument("{{input lower}}") as document: # Initialize saving options {{#if_output 'PDF'}} options = PdfSaveOptions() {{/if_output}} {{#if_output 'XPS'}} options = XpsSaveOptions() {{/if_output}} {{#if_output 'BMP' 'JPG' 'GIF' 'PNG' 'TIFF'}} options = ImageSaveOptions() {{/if_output}} # Convert the SVG document to {{output upper}} Converter.convert_svg(document, options, "result.{{output lower}}")
Installing Aspose.SVG for Python via .NET library
Aspose.SVG for Python via .NET is a powerful on-premise class library designed for seamless SVG file operations without needing additional software. It enables you to create, edit, optimize, and convert SVG files. Aspose.SVG for Python via .NET is currently supported on Windows for developing applications with Python 3.6 or later. It allows you to build both 32-bit and 64-bit Python applications. Support for Linux and macOS is planned for future releases.
Installing Aspose.SVG for Python via .NET through PyPI :
Install Aspose.SVG for Python via .NET
pip install aspose-svg-net
For more details about Python library installation, please refer to Aspose.SVG Documentation .
Other Supported Conversions
You can convert SVG files to other formats, including some of the following: