Skip to content

Instantly share code, notes, and snippets.

View sancelot's full-sized avatar

Stéphane ANCELOT sancelot

  • France
View GitHub Profile
@MartijnBraam
MartijnBraam / whiteboard.sh
Last active August 13, 2022 17:37
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..."