Skip to content

Instantly share code, notes, and snippets.

@premek
Last active June 21, 2023 21:36
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 premek/0f3714b1a14a1c92f61c9c9c67f491c3 to your computer and use it in GitHub Desktop.
Save premek/0f3714b1a14a1c92f61c9c9c67f491c3 to your computer and use it in GitHub Desktop.
make an image look like it was scanned
# separate pdf pages
convert -density 400 doc.pdf page-%0d.jpg
# use gimp to insert the signature at the right place at the right page, remove unnecessary pages etc
# scan
for F in page*jpg; do
convert -resize 1800x1800 -density 95 -flatten "$F" -rotate "0.$(( ( RANDOM % 2 ) + 3 ))" +repage -attenuate "0.$(( ( RANDOM % 8 ) + 20 ))" +noise Gaussian -quality 85 -compress JPEG -colorspace gray "$F-scanned.jpg"
done
# combine the pages into a pdf
convert *scanned.jpg scan.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment