Created
May 9, 2023 03:06
-
-
Save themactep/75e58479f7e761f7b10cfafbc5542895 to your computer and use it in GitHub Desktop.
thumbnailer for .stl files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# .STL files thumbnailer | |
# 2022, Paul Philippov, [email protected] | |
set -euo pipefail | |
OS=$(command -v openscad || command -v openscad-nightly) | |
IFS=$'\n\t' | |
FOO=$(basename "$1") | |
TMPFILE="/tmp/stl2png_$FOO.scad" | |
echo "import(\"$1\");" > "$TMPFILE" | |
$OS -o "$2.png" -D "\$fn=128" --autocenter --viewall \ | |
--colorscheme="Cornfield" -q "$TMPFILE" | |
rm "$TMPFILE" | |
mogrify -fuzz "1%" -transparent "#ffffe5" -trim +repage -resize "$3x$3>" \ | |
-gravity center -background transparent -extent "$3x$3" "$2.png" | |
mv "$2.png" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment