Skip to content

Instantly share code, notes, and snippets.

@captainpete
Created May 6, 2014 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captainpete/4647b408dc157eb1f22f to your computer and use it in GitHub Desktop.
Save captainpete/4647b408dc157eb1f22f to your computer and use it in GitHub Desktop.
Whiteboard ImageMagick zsh function
# Whiteboard photo cleanup script
# inspired by https://gist.github.com/lelandbatey/8677901
# converts an image to png, extracts strokes, traces etc.
whiteboard() {
convert "$1" "$1.converted.png"
echo "Converted"
convert "$1.converted.png" \
-morphology Convolve DoG:15,100,0 \
-negate -normalize -blur 0x1 -channel RBG \
-level 60%,95%,0.1 \
"$1.cleaned.png"
echo "Cleaned"
autotrace \
--dpi 1024 \
--line-threshold 0.1 \
--color-count 16 \
--corner-always-threshold 60 \
--line-reversion-threshold 0.1 \
--width-weight-factor 0.1 \
--despeckle-level 10 \
--despeckle-tightness 5 \
--preserve-width \
--remove-adjacent-corners \
--output-format svg \
--output-file "$1.cleaned.svg" \
"$1.cleaned.png"
pngcrush -ow -q "$1.cleaned.png"
echo "SVG traced"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment