Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Vectorization is the process of converting raster images into vector graphics, which utilize elements such as Bezier curves, splines, and lines. The process includes at least color quantization, detection of boundaries of single-color shapes, and their approximation by Bezier curves or polygons, as well as improvement of path quality through noise reduction. The result is saved in a vector image format, such as an SVG file.
Aspose.SVG for .NET provides two powerful approaches to convert raster images to SVG format via vectorization:
This article covers the basic concepts and practical examples for converting raster images such as JPG, PNG, BMP, TIFF, GIF, and ICO to SVG using the Converter.ConvertImageToSVG() methods.
To learn more about how to convert images to vector graphics using ImageVectorization API, refer to the Image and Text Vectorization chapter. You will find a description of the image vectorization process, the use of vectorization algorithms and parameters, as well as C# examples of using the Vectorize() methods.
Converting raster images to SVG enables scalable, resolution-independent graphics that remain sharp at any size, making them ideal for web design and other applications. The following example demonstrates how to convert a raster PNG image to SVG using the ConvertImageToSVG() method:
configuration, imageFile, outputFile) method vectorizes the input image, converting it into a scalable SVG format and saving it to the specified output path.Add the following namespaces:
1using Aspose.Svg;
2using System.IO;
3using Aspose.Svg.Converters;
4using Aspose.Svg.ImageVectorization;C# code for image to SVG conversion:
1// Convert Image to SVG using C#
2
3// Prepare paths for a source image file and output SVG file
4string imageFile = Path.Combine(DataDir, "flower-pink.png");
5string outputFile = Path.Combine(OutputDir, "flower-pink.svg");
6
7// Create a configuration object
8ImageVectorizerConfiguration configuration = new ImageVectorizerConfiguration
9{
10 PathBuilder =
11 new BezierPathBuilder
12 {
13 TraceSmoother = new ImageTraceSmoother(3),
14 ErrorThreshold = 5,
15 MaxIterations = 5
16 },
17 ColorsLimit = 15,
18 LineWidth = 2
19};
20
21// Convert Image to SVG
22Converter.ConvertImageToSVG(configuration, imageFile, outputFile);The figure shows the result of image vectorization: a) original PNG image; b) resulting SVG:

To get optimal results, you can experiment with different configuration options. For example, a lower color limit and higher smoothing create a more abstract and stylized image, while higher accuracy settings preserve more detail at the expense of complexity.
Some properties of the ImageVectorizerConfiguration class:
ColorsLimit – sets the maximum number of colors used to quantize the image. Decreasing its value simplifies the output and reduces the file size.LineWidth – controls the visual thickness of the traced edges.Properties of the BezierPathBuilder class:
TraceSmoother – adjusts the smoothing level for curves and lines.ErrorThreshold and MaxIterations – these parameters affect path accuracy and performance.Aspose.SVG for .NET supports both file-based and stream-based workflows, making it flexible for desktop, web, and service-oriented applications. The following example shows how to apply the
ConvertImageToSVG(configuration, inputStream, outputFile) method for JPG to SVG conversion:
1// Convert raster image JPG to vector SVG using C#
2
3// Prepare input and output
4string imagePath = Path.Combine(DataDir, "tulip.jpg");
5string outputFile = Path.Combine(OutputDir, "tulip.svg");
6
7// Open the image as a FileStream
8using (FileStream inputStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
9{
10 // Create vectorization configuration
11 ImageVectorizerConfiguration configuration = new ImageVectorizerConfiguration
12 {
13 PathBuilder = new BezierPathBuilder
14 {
15 TraceSmoother = new ImageTraceSmoother(1),
16 ErrorThreshold = 10,
17 MaxIterations = 1
18 },
19 ColorsLimit = 30,
20 LineWidth = 1
21 };
22
23 // Perform conversion from image stream to SVG
24 Converter.ConvertImageToSVG(configuration, inputStream, outputFile);
25}
26
27Console.WriteLine("Image converted to SVG successfully.");The figure shows the result of image vectorization: a) original JPG image; b) resulting SVG:

ConvertImageToSVG() methods for the fast image to SVG conversions with a custom setup.See Also
Aspose.SVG offers a Free Online Image to SVG Converter that works on any platform and provides accurate and efficient conversion. Using this application, you can apply a set of options to achieve the perfect result. Save your time and check this free Image to SVG Converter to get all the benefits of vector graphics!
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.