Skip to content

Instantly share code, notes, and snippets.

@MartijnBraam
Last active August 13, 2022 17:37
Show Gist options
  • Save MartijnBraam/b755cd45fb33c37853be to your computer and use it in GitHub Desktop.
Save MartijnBraam/b755cd45fb33c37853be to your computer and use it in GitHub Desktop.
Whiteboard photo to svg script
#!/bin/bash
echo "Running edge detection with imagemagick..."
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "/tmp/whiteboard.png"
echo "Scaling down to 1800px max"
convert /tmp/whiteboard.png -resize 1800x1800 /tmp/whiteboard2.png
echo "Force colors to primaries with imagemagick"
convert /tmp/whiteboard2.png -separate -threshold 50% -combine /tmp/whiteboard3.png
echo "Converting to svg with autotrace..."
autotrace -color-count 4 -output-format svg -despeckle-level 1 -remove-adjacent-corners /tmp/whiteboard3.png > $2.svg
echo "Cleaning up..."
rm /tmp/whiteboard.png
rm /tmp/whiteboard2.png
rm /tmp/whiteboard3.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment