Turn a positive rubber-stamp image into a laser-ready depth map with support ramps, for depth engraving on xTool (and similar) laser engravers.
| Input positive | Output depth map |
|---|---|
![]() |
![]() |
To laser-engrave a rubber stamp you need the artwork inverted (the ink areas stay at full height while everything else is cut away) and mirrored (so the stamp prints the right way around). That part is easy.
The hard part is that thin features — letter strokes, fine lines, dots — become tall, skinny posts of soft rubber. Without support they flex under stamping pressure, print badly, and eventually tear off. Commercially made stamps solve this with shoulders: sloped ramps that widen each feature toward its base. xTool Creative Space's depth engraving mode will happily follow a grayscale depth map, but it has no notion of ramps and can't generate them itself.
stamp-maker closes that gap. It takes your artwork as you'd see it printed
(dark ink on a light background) and produces a grayscale depth map where
every raised feature is skirted by a properly sloped shoulder:
- Threshold the input into a crisp ink mask (anti-aliased edges are fine). Images with an alpha channel are composited over white first, so transparent backgrounds just work.
- Mirror horizontally.
- Distance transform: an exact Euclidean distance transform (Felzenszwalb–Huttenlocher) computes each pixel's distance to the nearest feature, so shoulders follow every outline at a constant width — including the inside of counters and between close features.
- Ramp mapping: distance is mapped through a selectable profile into an 8-bit grayscale depth value. Beyond the ramp width the depth is capped at a flat, full-depth floor.
In the output, white = full stamp height (untouched rubber) and black = full engrave depth, matching xTool's depth-mode convention.
With Rust installed (rustup.rs):
cargo install --path .
or run straight from a checkout with cargo run --release --.
stamp-maker input.png -o depth.png [OPTIONS]
Typical invocation for a 300 DPI positive engraved 1.5 mm deep:
stamp-maker stamp.png -o stamp-depth.png --dpi 300 --depth 1.5 --angle 35 --profile concave
| Option | Default | Meaning |
|---|---|---|
--dpi <DPI> |
300 | Resolution of the input image. Match the resolution you'll use in xTool Creative Space, or the physical ramp width will be off. |
--depth <MM> |
1.5 | How deep the laser will cut the open areas. Only used to size the ramps — the actual cut depth is set in your laser software. |
--angle <DEG> |
35 | Shoulder angle, measured from vertical. 0 = straight walls (no ramp). Larger angles give wider, more supportive shoulders. |
--profile <P> |
linear |
Ramp cross-section shape — see below. |
--threshold <0-255> |
128 | Pixels darker than this count as ink (with --from-alpha: pixels at least this opaque). |
--from-alpha |
Mask on the alpha channel instead of luminance (opaque = ink). Use for artwork of any color drawn on a transparent background. | |
--no-flip |
Skip the horizontal mirror (e.g. if your artwork is already mirrored). | |
--white-deep |
Invert output polarity so white = deepest cut, if your engraver expects the opposite mapping. |
The horizontal ramp width is depth × tan(angle) and is printed after each
run so you can sanity-check it — e.g. 1.5 mm deep at 35° gives a 1.05 mm
shoulder.
| Profile | Cross-section |
|---|---|
linear |
Straight slope from face edge to full depth. Simple and predictable. |
concave |
Steep at the face, flaring out at the base — the classic commercial stamp shoulder. Keeps the printed edge crisp while giving the widest base support. |
convex |
Gentle at the face, steepening toward the base. |
scurve |
Smooth ease-in/ease-out between face and floor. |
The concave profile at 45°:
- Verify polarity on scrap first. This tool assumes xTool depth mode cuts
black deepest. If your first test engraves the face away instead of the
background, re-run with
--white-deep. - Keep DPI consistent between this tool and your laser software. The
ramps are sized in pixels from
--dpi; importing the PNG at a different resolution scales the shoulders too. - Laser rubber engraves with lots of debris — use air assist and clean the stamp (soapy water and a soft brush) before mounting.
- Very small text may need a wider shoulder (
--angle 45or more) or a slightly shallower--depthto survive.
cargo test
Unit tests cover the distance transform, ramp geometry, mirroring, polarity, alpha handling, and profile math.
MIT


