Last active
August 30, 2024 17:06
Convert Image to SVG in Python. For more details: https://kb.aspose.com/imaging/python/convert-image-to-svg-in-python/
This file contains 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.imaging | |
from aspose.imaging import Image | |
from aspose.imaging.fileformats.png import PngImage | |
from aspose.imaging.imageoptions import SvgOptions, SvgRasterizationOptions | |
import os | |
path = "C://" | |
with Image.load(os.path.join(path, "input.png")) as image: | |
svg_options = SvgOptions() | |
svg_rasterization_options = SvgRasterizationOptions() | |
svg_rasterization_options.page_width = float(image.width) | |
svg_rasterization_options.page_height = float(image.height) | |
svg_options.vector_rasterization_options = svg_rasterization_options | |
image.save(os.path.join(path, "result.svg"), svg_options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment