Skip to content

Instantly share code, notes, and snippets.

@MiniCodeMonkey
Last active November 14, 2024 11:40
Show Gist options
  • Save MiniCodeMonkey/a1306e54898ba0260a81 to your computer and use it in GitHub Desktop.
Save MiniCodeMonkey/a1306e54898ba0260a81 to your computer and use it in GitHub Desktop.
PNG to 3d object for 3d printing
#!/bin/sh
for f in *.png
do
filename=${f%.*}
echo "Processing $filename"
# png -> bmp
convert $filename.png -normalize -fx 'a==0 ? white : u' $filename.bmp
# trace bitmap to eps
potrace $filename.bmp -o $filename.eps
# eps -> dxf
pstoedit -dt -f "dxf: -polyaslines -mm" $filename.eps $filename.dxf
# extrude vector image to 3d model with openscad
openscad -o $filename.stl -D "image=\"$filename.dxf\"" generate.scad
done
linear_extrude(height = 2, center = true, convexity = 10)
import(file = image);
@bablokb
Copy link

bablokb commented Jun 6, 2024

This basically works, but my dimensions are wrong. Do I need to scale the input files to a specific resolution for this to work correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment