Image Vectorization – Vectorize an image with Cloud SDK

Image Vectorization

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.

Our API 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.

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:

Convert PNG to SVG – Vectorize PNG in C#

Here is a C# example of how to use these options in C# 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            };
11// 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:

 1curl -X POST -v \
 2    "" \
 3    -d '{
 4          "InputPath": "/input.png",
 5          "OutputFile": "output.svg",
 6          "Options": {
 7              "error_threshold": 30,
 8              "max_iterations": 30,
 9              "colors_limit": 25,
10              "line_width": 1
11          }
12        }' \
13    -H "Content-Type: application/json" \
14    -H "Authorization: Bearer <JWT_token>"

See Also