Image Vectorization – Vectorize an image with Cloud SDK
Contents
[
HideShow
]
Image Vectorization
Aspose.HTML Cloud supports the vectorization of the following image formats: PNG, JPEG, BMP, TIFF, and GIF. By using our image vectorization API, you can convert your raster images into scalable vector graphics, preserving their quality and making them suitable for high-resolution displays and prints. Whether you’re working with photos, logos, or illustrations, our API ensures precise and efficient vectorization, integrating seamlessly into your workflow.
Image Vectorization is the process of converting raster images, composed of pixels, into vector graphics, composed of paths defined by mathematical equations. This conversion enables images to be scaled infinitely without losing quality, making them ideal for various applications such as graphic design, printing, and digital artwork.
The article explains how to vectorize images using our API and client SDKs in a set of code examples. SDKs are available in PHP, C++, Python, C#, Ruby, Java, Android, Swift, and Node.js. We will consider various scenarios of how to vectorize an image:
Vectorizing a local raster image file and saving the result in your local file system. In this scenario, we will explore both image vectorizations with default parameters and with explicitly specified parameters.
Vectorizing raster images in cloud storage with default vectorization parameters.
Examples of Image Vectorization
A common use case for our API functions is image processing and vectorization. The API enables you to retrieve a raster image (such as PNG, JPG, JPEG, TIFF, GIF, or BMP) from storage by its name or from a local file on your drive, convert it to a vector format, and save it back to storage or your local drive. The following code examples demonstrate how to vectorize an image using various SDKs and cURL for different scenarios.
Vectorize an Image with Default Save Options
Here’s an example of vectorizing a local raster image file and saving the result to the local file system using default vectorization options.
Vectorization Options
Our API provides several options to fine-tune the vectorization process. Below is a description of the available vectorization options:
ErrorThreshold: The acceptable error threshold for the vectorization process. This value controls the accuracy of the vectorization. A lower value results in higher accuracy but may require more processing time. Default value is 30.
MaxIterations: The maximum number of iterations allowed during the vectorization process. This setting limits the processing time and complexity. Default value is 30.
ColorLimit: The maximum number of colors allowed in the vectorized output. This option helps control the complexity and size of the resulting vector file. Default value is 25.
LineWidth: The width of the lines in the resulting vector image. This setting controls the visual appearance of the vectorized output. Default value is 1.
Convert PNG to SVG – Vectorize PNG in C#
Here is a C# example of how to use these options to vectorize PNG and save the result as an SVG file:
1// Initialize SDK API
2var api =new HtmlApi("CLIENT_ID","CLIENT_SECRET").VectorizationApi; 3var options =new VectorizationOptions
4{ 5 ErrorThreshold =30, 6 MaxIterations =30, 7 ColorLimit =25, 8 LineWidth =1 9};1011// Convert PNG to SVG
12var result = await api.VectorizeAsync("input.png","output.svg", options);
This example demonstrates how to initialize the API with client credentials, set the vectorization options, and convert PNG to SVG using the specified options.
Vectorize PNG with Vectorization Options – cURL Example
Below is an example of how to use cURL to vectorize an image with specified options:
The
Available SDKs article introduces you to Aspose.HTML Cloud’s ability to use SDKs in various programming languages, such as C#, Java, Python, Ruby, PHP, Node.js, Swift, Android, and C++.
The
SDK Conversion Options article describes a set of classes that represent options for converting a source HTML-based document to PDF, XPS, and image.
Aspose.HTML Cloud API you can call directly from your browser by accessing the
API Reference.
You can try a free online
PNG to SVG Converter that swiftly converts PNG to SVG with high quality. Just upload your files, convert them, and get the result in a few seconds!
Free online
Image Vectorizer quickly and efficiently converts your raster images to vector SVG format. Using this application, you can apply a set of options to get the perfect result. Save your time and use this free Image Vectorizer to get all the benefits of vector graphics!