Image to DXF Converter
Trace a picture into a DXF with closed outlines at the real width you type, in mm or inches. For laser cutters, CNC and CAD. Your picture stays on your device.
https://flxcode.com/image-to-dxf/
or drop it here, or paste with Ctrl+V
PNG, JPG, WebP, GIF, BMP or AVIF. It never leaves this device.
Pixels darker than this become shapes. Lower it if too much is cut out.
Up to this many. Each color becomes its own layer.
Higher drops more tiny shapes.
Blurs rough edges before tracing. Rounds sharp corners.
How closely straight pieces follow a curve.
-
Outline tracing only. A thick line becomes a shape with two edges, not one center line (no single-stroke tracing). A photo needs strong contrast to give clean shapes.
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it. What this tool keeps and sends.
Problem or idea? Email us
Quick start
- Choose a picture: PNG, JPG, WebP, GIF, BMP or AVIF. A GIF uses its first frame.
- Keep "Black and white". Move Threshold until the red paths in the preview follow the shapes you want to cut.
- Type the width you need and pick mm or inches. The height follows the picture.
- Check the numbers under the preview, then press Download DXF.
What this DXF is, and what it is not
The DXF holds outlines. Each shape in your picture becomes one closed polyline, and each hole inside a shape is its own closed polyline. That is what a laser or CNC program wants: a loop it can cut along.
It traces outlines only. A thick black line becomes a shape with two edges, because there is no single center line in the tracer. If you need a one-stroke line for a pen plotter or an engraver, this is the wrong tool. The picture also has to have strong contrast: a drawing, a logo or a silhouette works, a busy photo does not.
Worked examples
These pictures are made in code with known shapes, and turned into DXF by the same engine as the tool above, when this page was built. The numbers are what the tool gives you.
A badge, 80 x 80 px: a blue disc (brightness 87 of 255) with a white disc inside it, and an orange 8 x 8 px square (brightness 156) in the corner, on white. Width set to 100 mm. Only the threshold changes:
| Threshold | Invert | Polylines | Points | Size |
|---|---|---|---|---|
| 60 | no | 0 | 0 | nothing to cut |
| 128 | no | 2 | 80 | 100 mm by 99.87 mm |
| 170 | no | 3 | 84 | 100 mm by 100 mm |
| 128 | yes | 3 | 84 | 100 mm by 100 mm |
At 60 no pixel is dark enough (the darkest is 87), so there is nothing to cut. At 128 the blue ring is dark and the orange square is not: the ring gives 2 polylines, its outer edge and the hole in the middle. At 170 the orange square (156) is dark too, so there are 3. With Invert the light areas are cut instead: the white background, which the orange square melts into, with the outer edge of the ring as a hole, and the white disc inside the ring. That is 3 polylines.
- Threshold 128
- Threshold 170
- Threshold 128, invert
Curve accuracy
A black disc, 400 px across, on white, set to 100 mm wide. That is 0.25 mm per pixel. Every row is one polyline; only the accuracy changes:
| Accuracy | Largest gap | Points |
|---|---|---|
| fine | 0.02 mm | 102 |
| normal | 0.05 mm | 79 |
| coarse | 0.2 mm | 59 |
A tighter gap needs more points, so the file grows. Fine is 1.7 times the points of coarse here. Normal, 0.05 mm, is the default.
Units in the file
The same badge at three widths. The file says which unit it uses in the $INSUNITS header (4 = mm, 1 = inches), and every coordinate is in that unit.
| You type | $INSUNITS | Shape width in the file | Same in mm |
|---|---|---|---|
| 100 mm | 4 | 100 mm | 100 |
| 4 inches | 1 | 4 in | 101.6 |
| 10 inches | 1 | 10 in | 254 |
4 inches is 101.6 mm, so a program that reads this file as mm would show 4 where you wanted 101.6. That is the "tiny DXF" problem.
One layer per color
The same badge in "Colours as layers", 100 mm wide. The white that fills the border is left out, so it is not cut.
| Layer | Color index | Polylines |
|---|---|---|
COLOR_1D5FC2 | 5 | 2 |
COLOR_F08C14 | 2 | 1 |
The blue ring gives 2 polylines (outside and hole) and the orange square gives 1. The color index is only a hint, the nearest of the 9 basic colors. The exact color stays in the layer name.
The start of the black and white DXF of this badge, 5.45 KB in all:
0
SECTION
2
HEADER
9
$ACADVER
1
AC1009
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
... How the picture becomes a DXF
Each pixel gets a brightness. A pixel darker than the Threshold counts as part of a shape, the rest is background. Transparent pixels are never shapes. The tool finds the border of every shape and every hole, and straight runs stay straight while bends are fitted as curves.
DXF has no curve we can count on every program reading, so each curve is cut into short straight pieces. Curve accuracy is how far a piece may stray from the true curve. The result is scaled so the width equals what you typed. The y axis is flipped, because pictures count down and CAD counts up, and the lower left corner of the shapes sits at 0,0.
Numbers this uses
- Brightness = 0.299 red + 0.587 green + 0.114 blue, from 0 to 255. Threshold 1 to 255, start at 128. A pixel is a shape when it is darker than the threshold (lighter, with Invert).
- Transparency: alpha below 128 of 255 is empty and never a shape.
- Speck removal 0 to 5 drops outlines shorter than 0, 4, 10, 24, 48, 96 edge points (about their perimeter in pixels).
- Curve accuracy: fine 0.02 mm, normal 0.05 mm, coarse 0.2 mm (0.0008, 0.002 and 0.0079 in). It is the largest gap between a curve and its straight pieces, whatever the unit you pick.
- Size: width from 0.1 to 100000 mm or 0.005 to 4000 in. 1 in = 25.4 mm. Coordinates are written with 4 decimals in mm and 6 in inches.
- The longer side of the picture is traced at 1000 px at most; a bigger picture is scaled down first. The DXF still has the width you set.
- Colors mode: 2 to 16 colors, one layer per color named COLOR_ and the hex code. The layer color index is the nearest of the 9 basic AutoCAD colors, because the R12 format has no true color.
- File: DXF version R12 (AC1009), POLYLINE and VERTEX entities, closed flag set. Header has $INSUNITS (4 = mm, 1 = inches) and $MEASUREMENT.
- Tracer: imagetracerjs 1.2.6 by András Jankovics, public domain (Unlicense). We use its shape finding and write the DXF ourselves.
Privacy
The picture is traced in your browser and is not uploaded or stored. Units, mode and slider settings can go in the share link; the width you type, the picture and its name never do. The tool counts events without cookies, such as "DXF saved", and never a file name, size or point count (details). Licences: Open source used on this site.
FAQ
How do I convert an image to DXF?
Choose the picture, move Threshold until the red preview paths follow what you want to cut, type the width and pick the unit, then press Download DXF. The tracing happens in your browser, so there is no upload.
Will the DXF have the right size?
Yes, as long as the unit matches. The width you type is the width of the shapes in mm or inches, and the height follows the picture. Untick "Measure the width on the shapes" if you want the whole picture, margins included, to be that wide.
Why is my DXF tiny or huge when I open it?
Almost always a unit mix-up. A file in mm read as inches looks 25.4 times too big, and a file in inches read as mm looks 25.4 times too small. The file says which unit it uses, but some programs ignore that and ask you, or assume one. Check the unit in the import box.
Can it trace a center line for engraving or a pen plotter?
No. It traces outlines only. A line drawn with a thick pen becomes a thin shape with an edge on each side. Single-stroke or center-line tracing needs a different method that thins lines to one pixel first, and this tool does not do that.
Can I get one layer per color?
Yes. Switch to "Colours as layers". Each color gets its own layer, named COLOR_ and its hex code, so a laser program can give each one a different cut or engrave setting. The color on the layer is the nearest of 9 basic colors, as the R12 format allows nothing more exact.
Which DXF version is it, and what opens it?
R12 (AC1009), the oldest version in common use. R12 is the format most DXF readers support, but we have only tested the output with the ezdxf library, whose audit reports no errors on it. We have not opened it in LightBurn, Inkscape, LibreCAD, Fusion or AutoCAD, so try it in yours.
More from FLXCode
- PNG to DXF ConverterTurn a PNG logo or stencil into a DXF for laser cutting or CNC. Set the size in mm or inches. Nothing is uploaded.
- Image to SVG ConverterTrace a PNG, JPG, WebP or GIF into an SVG. Tune colors, smoothing and detail. Nothing is uploaded.
- PNG to SVG ConverterTrace a PNG logo or icon into an SVG you can scale to any size. Choose the colors. Nothing is uploaded.
- STL ViewerOpen an STL or OBJ file, turn it around, and see its size, volume and filament weight. The file stays on your device.