Your traced DXF came out the wrong size. Here's the setting that actually sets it

In a tracer, DXF size comes from DPI, not a width field, and the extents are the artwork, not the image. Measured, with the formula and a size check.

The part was supposed to be 100 mm wide. It comes into the laser software at 180, or at 20, or at something with four decimals that matches nothing you typed.

This is one of the oldest threads on every maker forum. On the LightBurn forum a user exported a 75 mm square that imported into his CAD program as a 1.984375 mm square (January 2024). On Snapmaker's, a drawing designed at about 150 mm in AutoCAD imported into Luban at 20 × 10 mm (2021). On Glowforge's, a class cutting rocket parts found the cut didn't match the dimensions in the file (January 2024).

Most replies in those threads are about the importer's unit setting, and that's often the answer. This article is about the other half, the one that happens before the importer: when the DXF is traced from a picture, what decides how big it is? I'll use our own tracer, Vectorize, because I can measure it, and because it has exactly the trap I'm going to describe.

Three causes, in the order to check them

  1. Units. The file says millimetres and the importer reads inches, or the other way round, or the importer has a bug. A factor of 25.4 (or close to it) is the giveaway.
  2. The wrong sizing control. You asked for a width, and the format you exported doesn't take a width.
  3. Extents measured on the wrong thing. The size you expected was the image; the size you got is the artwork inside it, or the other way round.

The first is the importer's business. The other two are the tracer's.

The test image

A 760 × 300 px PNG: a navy square, a green circle and a red triangle on white, with a margin of white around all three. ImageMagick, so you can rebuild it:

convert -size 760x300 xc:white \
  -fill '#1b3a6b' -draw "rectangle 40,60 260,240" \
  -fill '#2e9e44' -draw "circle 400,150 400,60" \
  -fill '#c8102e' -draw "polygon 560,240 640,60 720,240" \
  plate.png

The shapes run from x = 40 to x = 720, so the artwork is about 680 px wide on a 760 px canvas. Remember that gap; it's cause 3.

Which control sizes which format

Every run below is vectorize plate.png --transparent (no background shape) with the format and the size options in the column header. The target was 100 mm wide.

format no size options --dpi 172.992 --unit mm --width 100
DXF (artwork extents) 180.20 mm 100.00 mm 180.20 mm
EPS (%%BoundingBox, points) 570 × 225 317 × 125 570 × 225
PDF (MediaBox, points) 570 × 225 316.3 × 124.9 570 × 225
SVG (width/height) 760 × 300 760 × 300 100mm × 39.474mm

Read the DXF row. --unit mm --width 100 gave a file identical in size to no options at all. Exit code 0, no warning. That's the trap, and it's ours: the width is accepted and does nothing on DXF, EPS or PDF. Those three are sized by --dpi only. SVG is the mirror image: --width works and --dpi does nothing.

The help text does say --width is an "SVG output width", so it's documented. It's also very easy to skim past when you're in a hurry and the command ran without complaint. The web app says it more plainly next to the field: "PDF/EPS pages and DXF millimetres follow the DPI; width applies to SVG only." The hosted API behaves the same way with dpi, unit and width as query parameters: format=dxf&unit=mm&width=100 came back at 180.20 mm, format=dxf&dpi=172.992 at 100.00 mm.

The formula

DPI scales the drawing linearly from a default of 96. So trace once with no size options, measure the width, and trace again at:

dpi = 96 × measured_mm / wanted_mm

On the test image: 180.20 mm at the default, 100 mm wanted, so 96 × 180.20 / 100 = 172.992. Result: 100.00 × 26.62 mm. For 2 inches (50.8 mm), 96 × 180.20 / 50.8 = 340.535 gave 50.80 mm. The geometry doesn't change between runs; only the scale does.

The web app's DPI field takes whole numbers from 36 to 1200. 173 is close enough: it comes out at 99.995 mm, which displays as 100.00.

Measure the artwork, not the canvas

This is the part that bites even when you use the right control.

Leave out --transparent and the white background is traced as a shape the size of the whole image, on its own COLOR_FFFFFF layer. The DXF then measures 201.08 mm wide, which is just the 760 px canvas at 96 dpi. Plug that into the formula and you get dpi 193.04, and the part comes out at 89.62 mm, not 100. For cutting you want --transparent anyway, so the background isn't a cut path.

With --transparent, the DXF's extents are the artwork's bounding box. That's why you sometimes see "use 25.4 dpi, then 1 px = 1 mm" and get a surprise: on this image --dpi 25.4 gave 681.08 mm, not 760. The shapes are 681 px wide; the white margin isn't in the drawing. That's the number your machine cares about, so it's the right one. It just isn't what the slogan predicts.

EPS and PDF don't work like that. Their page stays the size of the whole canvas even with --transparent: 570 × 225 pt is 201.08 × 79.38 mm. Same for SVG, where --width 100 sets the width of the whole canvas, so the logo inside it is about 89.6 mm. If you're sizing a cut part, measure it in the DXF.

The file also keeps where the artwork sat on the canvas: at 100 mm wide the part starts 5.87 mm from the origin, not at zero. Most laser software places a part by its own bounding box anyway, but if yours imports at the file's coordinates, that's why it isn't in the corner.

Checking a DXF's size without opening CAD

Our DXFs say their units in the header: $INSUNITS is 4, millimetres (AutoCAD 2000 format, AC1015). They don't carry $EXTMIN/$EXTMAX, and every shape is an LWPOLYLINE, so the size can't be grepped out of the header. Walk the vertices instead. A DXF is pairs of lines, a group code then a value; codes 10 and 20 are X and Y:

# dxfsize.py — python3 dxfsize.py part.dxf
import sys

with open(sys.argv[1], encoding="utf-8", errors="replace") as f:
    lines = [line.strip() for line in f]
pairs = list(zip(lines[0::2], lines[1::2]))

xs = [float(v) for code, v in pairs if code == "10"]
ys = [float(v) for code, v in pairs if code == "20"]
units = next((pairs[i + 1][1] for i, (c, v) in enumerate(pairs)
              if c == "9" and v == "$INSUNITS"), "not set")

print(f"{max(xs) - min(xs):.2f} x {max(ys) - min(ys):.2f}  ($INSUNITS {units}; 4 = mm, 1 = in)")
print("layers:", sorted({v for c, v in pairs if c == "8"}))

On the 100 mm file it prints 100.00 x 26.62 ($INSUNITS 4; 4 = mm, 1 = in) and the three colour layers. It reads plain polylines only; a file with arcs, splines or blocks needs a real DXF library. For ours, it's enough.

If that script says 100 mm and millimetres, and the laser software still shows something else, the problem is on the import side: check its DXF unit setting first. I haven't tested every importer against this file, and the Snapmaker thread above is a reminder that importers have scaling bugs of their own (that one also notes Luban adding a 1 mm border on import).

One more thing if the source is a JPEG

Size isn't affected: a JPEG of the same image (quality 70) measured 180.21 mm against 180.20. Layers are. The JPEG came back with four layers instead of three, the extra one a dark edge shade of the navy (COLOR_25375A). --colors 4 (three inks plus the background) brought it back to three. Count the layers before cutting; why the tracer's own colour count isn't a reliable answer is its own article.

The short version

  • DXF, EPS and PDF: size with --dpi. --width is ignored on them, silently.
  • SVG: size with --width. --dpi is ignored there.
  • Trace with --transparent, measure the DXF, then dpi = 96 × measured / wanted.
  • If the DXF says the right size in mm and the import is wrong, look at the importer, not the trace.

What I'd rather the tool did is warn when you pass --width to a format that ignores it, or take a width for DXF directly. Today it does neither, so the two traces and the formula are the workaround.

The CLI and core are licensed PolyForm Noncommercial, with a free trial of under 32 days for evaluation at work; cutting parts for paying customers is commercial use and needs a licence (terms). The same options are on the hosted API and behind the download arrow in the web app. Measured on version 0.7.1.