You drew a sprite at 16 by 16, one pixel at a time. Now you need it as a vector: an icon that scales in a browser, a sticker file, a cut file. You run it through Image Trace or any tracer on default settings, and the squares come back as rounded blobs.
People have been asking about this on Graphic Design Stack Exchange since at least 2015. One asker (17,043 views) had tried Illustrator's trace and found it "seems to do a rough job". Another (15,127 views) listed exactly what they wanted: "Pixel by pixel conversion, no tracing", semi-transparent pixels kept, and a command line for batches if possible.
Pixel art is a special case. A tracer is built to guess the smooth shape behind jagged pixels, but in pixel art the jagged pixels are the shape. Below are three ways to get a vector out of it, including ours, tested on the same file, and where each one breaks.
The test file
Everything here was measured on 30 November 2026 on one file, a 16×16 sprite drawn pixel by pixel:
148 opaque pixels in four colours (outline #1a1c2c, red
#b13e53, shadow #5d275d, highlight #f4f4f4) on a transparent background. Then the versions
people actually get sent: the same sprite on white, the same sprite scaled up 8× with
nearest-neighbour (128×128, which is how pixel art is usually posted), and that 8× file saved as a
JPEG at quality 85.
Every SVG was rendered back and compared with the source colour by colour, not judged by eye.
What a general tracer does to 16 pixels
potrace is the classic open-source tracer and a good stand-in for "a tracer on default settings". It traces a single colour per run, so we gave it the sprite's silhouette: all 148 pixels in black.
![]()
- Defaults, 16 px source: one closed curve of four Bézier segments. A rounded square. Rendered at 128 px, 948 of 16,384 pixels came out wrong.
-a 0(corners never smoothed), 16 px source: straight lines, but an octagon (784 pixels wrong). potrace still fits the best polygon through the staircase, and at this size the best polygon cuts every corner.- Defaults, on the 8× upscale: the staircase came back exactly, 0 pixels wrong.
The third result is the trick one answer on the 2016 question suggests for Illustrator: scale the art up a lot first so the tracer sees big squares. It worked here. What it doesn't do is colour: potrace works in black and white, so a four-colour sprite means splitting it into four masks, tracing each, and stacking the results yourself.
A plain pixel-to-rectangle script
The other route from those threads is no tracing at all: write one <rect> per pixel. It's about
twenty lines of Python with Pillow (below), and the most upvoted answer on the 2015 question does a version
of it by modifying pixel2svg. Ours wrote 148 rectangles in 8,471 bytes. Every pixel is a rectangle
in its exact colour, nothing merged or guessed, and it keeps alpha: a shadow row at 50% opacity
came out as fill-opacity="0.498" and rendered identical to the source on white. That last part
is something the next section's tool doesn't do.
It has one problem you can see in the cover picture. At sizes that aren't a whole multiple of the
pixel grid (we tried 117 px and 200 px wide in Chromium), each edge two rectangles share is
anti-aliased once per rectangle and a little background shows through. At 117 px, 1,157 pixels in
the middle of flat colour areas came out lighter than they should. That's the faint grid on the
left of the cover. A third question,
white borders between boxes
(1,362 views), shows the same thing: the asker's exported rectangles sat edge to edge at fractional
coordinates (x="671.94" width="10.03", the next one at 681.97), and the export still had white
lines around every pixel.
There is a fix for browsers: shape-rendering="crispEdges" on the <svg> element. With it, the
same file at 117 px had no stray pixels inside flat areas. It's a rendering hint, though, so it
helps where the file is displayed by something that honours it, and does nothing for a cutter or
an editor that opens the paths.
Our pixel preset: merged squares, exact colours
Vectorize has a preset for this case, pixel on the command line
and Pixel art in the web app. It keeps the squares, but it merges same-coloured pixels that share
an edge into one shape.
| 16×16 source, measured 2026-11-30 | preset | what the SVG holds | pixels that differ |
|---|---|---|---|
| transparent PNG | pixel |
22 straight-edged paths, whole-number coordinates, the 4 exact colours, 1,422 bytes | 0 of 256 |
| same sprite on white | pixel |
23 paths (the white ground is one more) | 0 of 256 |
| same sprite on white | pixel --transparent |
22 paths, no ground | 0 of 256 |
| transparent PNG | logo (the default) |
12 paths, 14 curve segments, 9 gradient fills | not pixel art any more |
The 97 red pixels are 4 shapes, not 97 rectangles, so there are no edges inside the red area to anti-alias. Rendered at 117 px and 200 px in Chromium, nothing inside a flat area was off. Where different colours meet, the browser still blends the boundary, as it does with any vector art.
One thing to know if you cut the result: pixels that touch only at a corner stay separate shapes. In the file we measured, the 36 outline pixels came out as 16 separate outline paths, joined only at corner points.
And don't leave it on the default preset. logo treats a 16-pixel sprite like a blurry logo: it
enlarges the image, smooths edges into curves and fills areas with gradients. Right for a logo
grabbed from a web page, wrong here.
Scaled up 8×: still exact
| 128×128 nearest-neighbour PNG on white, measured 2026-11-30 | preset | result | pixels that differ |
|---|---|---|---|
pixel |
23 paths, every coordinate a multiple of 8 | 0 of 16,384 | |
logo |
8 paths, coordinates on half pixels | 5 of 16,384 |
The 8× upscale gave the same 23 shapes as the native file, 8 units per cell. logo gets close on a
clean upscale but lands edges half a pixel off the grid.
The JPEG is where it goes wrong
The 8× sprite saved as a JPEG measured 419 distinct colours in it, against 5 in the PNG. The pixel
preset keeps that colour noise faithfully:
| JPEG q85, 128×128, measured 2026-11-30 | result | ink colours exact? | pixels off, by shape* |
|---|---|---|---|
-p pixel |
611 paths, 32 colours, 42,351 bytes | none | 4 |
-p pixel --colors 5 |
44 paths, 5 colours | none: the outline came back #2f1321, not #1a1c2c |
260 |
-p pixel --palette (4 inks + white) |
25 paths, the 5 exact colours | yes | 5 |
-p pixel --palette (4 inks, no white) |
25 paths, 4 colours | the white ground was painted #f4f4f4 |
6,917 (the ground) |
*after mapping each traced colour to the nearest source colour, so this column counts wrong shapes,
not slightly wrong shades. The --palette rows are compared as they are.
So the shapes survive the JPEG and the colours don't. In the run we measured, capping the count with --colors 5 gave five
colours, and every one of the 9,472 ink pixels had the wrong hex. Naming the colours with --palette
fixed it, as long as the background was in the list. Leave the white out and the ground gets painted
in the nearest colour you did list.
The cleanest result came from undoing the upscale first. Shrinking the JPEG back to one pixel per
cell (convert in.jpg -filter box -resize 16x16! cell.png) averages each 8×8 block. Traced with the
same five-colour palette, that measured 23 paths and 0 of 256 pixels different, the same file as the
original PNG. You need to know the cell size, and the grid has to start at the image's corner. A
screenshot with a stray border won't line up.
If you can get the original PNG, ask for it. It saves all of the above.
Where ours loses: semi-transparent pixels
The 2015 asker's caveat was alpha. We added a shadow row at 50% opacity, then at 60%:
| shadow row | pixel preset |
per-pixel script |
|---|---|---|
| 50% opaque | dropped (8 pixels missing) | kept, fill-opacity="0.498" |
| 60% opaque | drawn fully opaque | kept, fill-opacity="0.6" |
Our output has no opacity attribute at either level. Each pixel is drawn solid or left out. If your
art depends on partial transparency (soft shadows, anti-aliased edges you want kept as they are),
use the per-pixel script and add crispEdges.
Which one to use
- Hard-edged sprite, a few flat colours, you want a clean file: the
pixelpreset. Exact colours, few shapes, no seams inside flat areas. - Partial transparency matters: one rectangle per pixel with
fill-opacity, plusshape-rendering="crispEdges"for display. - Single-colour art and you already use potrace: upscale it 8× or more with nearest-neighbour first. On the 16 px original it gives you the blob.
- You want the sprite smoothed, not kept square: Inkscape's Trace Bitmap has a Pixel art tab built on libdepixelize (the Kopf–Lischinski algorithm). It turns pixel art into smooth curves, or with its Voronoi output reshapes cells so diagonal neighbours can share an edge, per Inkscape's tutorial. Different goal from ours, and the tutorial notes the algorithm ignores the alpha channel.
Reproduce it
npm i -g @dudko.dev/vectorize-cli
vectorize sprite16.png -p pixel -f svg -o sprite.svg
vectorize sprite-on-white.png -p pixel --transparent -f svg -o sprite.svg
vectorize sprite-8x.jpg -p pixel --palette '#1a1c2c,#b13e53,#f4f4f4,#5d275d,#ffffff' -f svg -o sprite.svg
grep -c '<path' sprite.svg
grep -oE 'fill="[^"]*"' sprite.svg | sort | uniq -c
# potrace, black and white: silhouette at native size, then on an 8x upscale
convert sprite16.png -alpha extract -negate sil16.pbm
potrace -s sil16.pbm -o blob.svg
convert sil16.pbm -filter point -resize 800% sil128.pbm
potrace -s sil128.pbm -o squares.svg
And the per-pixel script, if partial alpha is what you need:
# rects.py in.png out.svg (pip install pillow)
import sys
from PIL import Image
img = Image.open(sys.argv[1]).convert("RGBA")
w, h = img.size
out = [f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w} {h}" '
f'width="{w}" height="{h}" shape-rendering="crispEdges">']
for y in range(h):
for x in range(w):
r, g, b, a = img.getpixel((x, y))
if a == 0:
continue
op = "" if a == 255 else f' fill-opacity="{round(a / 255, 3)}"'
out.append(f'<rect x="{x}" y="{y}" width="1" height="1" fill="#{r:02x}{g:02x}{b:02x}"{op}/>')
out.append("</svg>")
open(sys.argv[2], "w").write("\n".join(out) + "\n")
The web app is at https://vectorize.dudko.dev/app/, where the preset is called Pixel art. These numbers are tuned outputs and may move in later releases.
The command-line tool is free for non-commercial use under PolyForm Noncommercial 1.0.0. Using it in a business needs a licence: https://vectorize.dudko.dev/licence/.
