Convert SVG to BMP
Contents
[
Hide
]
Convert SVG to BMP
Using Aspose.Imaging for Python via .NET, developers can convert SVG to BMP format. This topic explains the approach to load existing SVG and convert it to BMP using BmpOptions and SvgRasterizationOptions.
Below provided sample code demonstrate how to convert SVG to BMP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aspose.pycore as aspycore | |
from aspose.imaging import Image | |
from aspose.imaging.imageoptions import BmpOptions, SvgRasterizationOptions | |
import os | |
if 'TEMPLATE_DIR' in os.environ: | |
templates_folder = os.environ['TEMPLATE_DIR'] | |
else: | |
templates_folder = r"C:\Users\USER\Downloads\templates" | |
delete_output = 'SAVE_OUTPUT' not in os.environ | |
data_dir = templates_folder | |
with Image.load(os.path.join(data_dir, "template.svg")) as image: | |
options = BmpOptions() | |
svg_options = SvgRasterizationOptions() | |
svg_options.page_width = 100.0 | |
svg_options.page_height = 200.0 | |
options.vector_rasterization_options = svg_options | |
image.save(os.path.join(data_dir, "result.bmp"), options) | |
if delete_output: | |
os.remove(os.path.join(data_dir, "result.bmp")) |