Convert Raster Image to SVG
Convert Raster Image to SVG
Using Aspose.Imaging for .NET, developers can convert Raster image to SVG. This article shows how to export/convert Raster format file to SVG formats with Aspose.Imaging. Using Aspose.Imaging for .NET you can load image of any format and than you can set various properties using SvgImage class and save the image. The following code snippet shows you how to convert SVG to PNG image.
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.ImageOptions; | |
using System.IO; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (Image image = Image.Load(dataDir + "template.png")) | |
{ | |
SvgOptions svgOptions = new SvgOptions(); | |
SvgRasterizationOptions svgRasterizationOptions = new SvgRasterizationOptions(); | |
svgOptions.VectorRasterizationOptions = svgRasterizationOptions; | |
svgOptions.VectorRasterizationOptions.PageWidth = image.Width; | |
svgOptions.VectorRasterizationOptions.PageHeight = image.Height; | |
image.Save(dataDir + "result.svg", svgOptions); | |
} | |
File.Delete(dataDir + "result.svg"); |