Convert PPM Images to AutoCAD Slides or DXB Files
Old CAD workflows sometimes need a bitmap traced into a drawing, and ppmtoacad bridges that gap. It turns a PPM image into an AutoCAD slide or a binary drawing interchange file that AutoCAD imports with DXBIN. The examples use the Netpbm ppmtoacad installed here, package version 2:11.05.02-1.1build1. Allow about ten minutes for a basic conversion once the PPM is ready.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need a readable PPM and enough free space for the output, which can be surprisingly large, particularly for a DXB file or a slide made with -poly. None of this needs elevated privileges; do not reach for sudo unless file permissions genuinely require it.
1. Check the installed command
Confirm you have the executable you expect and note the package version:
$ command -v ppmtoacad
/usr/bin/ppmtoacad
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1
$ ppmtoacad -help
ppmtoacad: Use 'man ppmtoacad' for help.
The local manual describes ppmtoacad as reading PPM from a named file or standard input, and writing an AutoCAD slide by default. -dxb switches it to a binary database import instead.
Checkpoint
If command -v finds nothing, install Netpbm through your normal package manager before continuing. Do not grab a binary from an untrusted download.
2. Create a slide from a PPM
Use shell redirection to pick the output filename; the input stays untouched:
$ ppmtoacad /path/to/image.ppm > image.sld
$ printf 'exit status: %s\n' "$?"
exit status: 0
$ file image.sld
image.sld: data
A successful run can still produce a file file only identifies as generic data, slide files are not something that utility necessarily recognises. What matters is a zero exit status, a non-empty destination and a sensible size. Load the slide in AutoCAD through its normal slide-viewing workflow.
The default background is AutoCAD colour number 0, normally black. Pixels whose nearest AutoCAD colour matches the background get discarded, shrinking the output. If your display uses a white background, use the documented shortcut:
$ ppmtoacad -white /path/to/image.ppm > image-white.sld
$ test -s image-white.sld && echo 'slide written'
slide written
-white is equivalent to -background 7. You can also give another palette number directly, for example -background 1, it refers to AutoCAD's standard 256-colour palette, not an RGB value.
3. Produce a DXB import instead
Choose -dxb when the destination workflow needs a binary drawing database import:
$ ppmtoacad -dxb /path/to/image.ppm > image.dxb
$ test -s image.dxb && echo 'DXB file written'
DXB file written
After import with AutoCAD's DXBIN command, the result becomes part of the drawing database, viewable and editable like any other geometry. The converter represents runs of identical pixels as separate objects, which can make a DXB drawing very large, though it also makes zooming and tracing over a bitmap genuinely practical.
Keep the source PPM until the import has been checked. The command never alters the input, but the redirect operator can truncate an existing destination before ppmtoacad even starts.
4. Preserve an existing output safely
Warning
> destroys the previous contents of its destination immediately. Convert to a temporary name, check it, then replace the old file:
$ ppmtoacad -dxb /path/to/image.ppm > image.dxb.new
$ test -s image.dxb.new
$ mv image.dxb.new image.dxb
If conversion fails, the old image.dxb stays exactly where it was. Remove the incomplete temporary file with rm -- image.dxb.new once you have confirmed it is the right file. If you have already replaced something and need recovery, restore from your normal backup, there is no general undo for a shell redirect.
5. Match the image geometry
PPM normally describes square pixels. If your source uses non-square pixels, pass the ratio of pixel width to pixel height with -aspect. For a 320 by 200 VGA or MCGA image, the manual gives this example:
$ ppmtoacad -aspect 0.8333 /path/to/vga-image.ppm > vga-image.sld
This corrects the generated slide or DXB geometry so the displayed pixels come out square. It does not resize the PPM, and it will not repair a genuinely wrong image width or height, work out the ratio from the source format rather than guessing.
For a less colourful result, -8 restricts output to eight RGB shades. That can suit a simple diagram, but it throws away colour information, so check the result visually before using it as a tracing reference.
6. Use polygons only when they help
Without -dxb, each source row normally becomes a line in the slide. Add -poly to render pixels as filled polygons instead:
$ ppmtoacad -poly /path/to/image.ppm > image-polygons.sld
$ test -s image-polygons.sld && echo 'polygon slide written'
polygon slide written
Polygons can make pixels expand cleanly on a higher-resolution display instead of showing as isolated lines. The trade-off is a larger file and slower display, so use this for a deliberate viewing reason, not as a general quality setting. The manual also warns that run consolidation is not true raster-to-vector conversion, it does not optimise thin diagonal lines.
7. Diagnose a result that looks wrong
Check the input first, without changing it:
$ test -r /path/to/image.ppm && echo 'input is readable'
$ file /path/to/image.ppm
If the command reports a PPM parsing error, validate the image with another Netpbm reader such as pamfile if it is installed. If the AutoCAD image is too large, try the default slide mode, choose an appropriate background, or simplify the source, large output is normal for detailed images, DXB mode and polygon slides alike.
If colours look poor, remember AutoCAD has a fixed 256-colour palette: an image with many nearly identical colours cannot all be represented accurately, and an eight-colour display will show even less. These are format limits, not evidence the PPM was resized.
Options may be abbreviated to their shortest unique prefix, but full names read more clearly in scripts, keep them full for anything that will be reviewed or reused. The command also accepts standard Netpbm options such as -quiet, use them only once you have confirmed the conversion actually works.
Done means
- Version checked: the installed Netpbm version and the input PPM were confirmed.
- Output written: a non-empty slide or DXB file was produced with a zero exit status.
- Options used deliberately:
-dxb,-poly,-white,-aspector-8was applied only for its stated effect. - Source protected: the original PPM was kept, and any existing output was protected from accidental truncation.
- Verified in AutoCAD: the generated file was checked in the intended workflow before source or backup was removed.