Skip to content

Instantly share code, notes, and snippets.

@MiniCodeMonkey
Last active April 28, 2024 23:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment