API Documentation


Methods

vectorize

version: V2 Method: vectorize

This API endpoint converts a raster image (PNG, JPEG) to vector image (SVG format).

See usage examples for more information.

Input

  • Send image data using HTTP POST (simple binary body)
  • Optionally you can pass several URL arguments (?colors=16&mins=10&...) to optimize vector result, see arguments below

Output
  • HTTP response body contains SVG image source code
  • Several image details (width, height, colors) are included in the response HTTP headers, see entries starting with "X-".


Arguments


  • colors = 32 (optional) number of colors
    possible value: 2, 4, 8, 12, 16, 24, 32 (default)
  • blur = 0 (optional) smoothing factor around each color patch
    possible value: 0-30%, default: 0%
  • tolerance = 2 (optional) factor which is used to automatically merge similar colors in the layers list
    possible value: 0-100%, default: 2%
  • mins = 2 (optional) size of speckles which will be ignored during vectorization
    possible value: 0-10000px2, default: 2px2
  • layersort = 1 (optional) algorithm number used for sorting the color layers
    possible value: 1, 2, 3, 4, default: 1

    Order:
    4 by color (desc)
    3 by color
    1 by area
    2 by area (desc)
  • bgmode = 2 (optional) algorithm for background overlapping
    possible value: 1, 2, 3 default: 2

    Background:
    0 none
    1 blur
    2 merge



Responses


Vectorization Successful

HTTP status code 200.

Information: Response header entry "X-quota" contains your number of available API calls. Need a higher quota? Contact us.

Vectorization Failed

For description of error codes see https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Example:
HTTP/1.1 417 Expectation Failed: Expect header is not supported, disable it: curl -H 'Expect:' ...


Example Usage


You can test our API from shell: (without API key)
$ curl -H 'Expect:' --data-binary "@exampleimage.png" "https://www.vectorizer.io/api/v2/vectorize" -v

You can test our API from shell: (with your API key)
$ curl -H 'x-api-key: your API key here' -H 'Expect:' --data-binary "@exampleimage.png" "https://www.vectorizer.io/api/v2/vectorize" -v

Example with URL arguments:
$ curl -H 'x-api-key: your API key here' -H 'Expect:' --data-binary "@exampleimage.png" "https://www.vectorizer.io/api/v2/vectorize?colors=16&mins=10" -v

Output:
* Connected to www.vectorizer.io port 443 (#0)
> POST /api/v2/vectorize HTTP/1.1
> Host: www.vectorizer.io:443
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 82289
> Content-Type: application/x-www-form-urlencoded
>
} [16384 bytes data]
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< X-quota: 10
< X-Powered-By: www.vectorizer.io
< X-colors: 16
< X-blur: 0
< X-bgmode: 2
< X-tolerance: 20
< X-mins: 5
< X-width: 240
< X-height: 240
< X-hash: d2971e867f47f606b0a0a56d4ec9a4f7
< X-edges: none
< X-layers: cb_a_dfg_e_n_i_h_mjk_l
< Cache-Control: private, no-store, no-cache, must-revalidate
< Pragma: no-cache
< Content-Type: image/svg+xml
< Transfer-Encoding: chunked
< Date: Sun, 1 Sep 2018 10:05:00 GMT
<
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="240px" height="240px" viewBox="0 0 2400 2400" preserveAspectRatio="xMidYMid meet">
<g id="layer101" fill="#cc0505" stroke="none">
...
</svg>