Last active
March 8, 2026 20:14
-
-
Save premek/0f3714b1a14a1c92f61c9c9c67f491c3 to your computer and use it in GitHub Desktop.
make an image look like it was scanned
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
| # separate pdf pages | |
| convert -density 400 -colorspace gray doc.pdf page-%0d.png | |
| # alternative if convert fails (result does not look the same as original) | |
| # pdftoppm -gray doc.pdf page -png | |
| # use gimp to insert the signature at the right place at the right page, remove unnecessary pages etc | |
| # scan | |
| for F in page*png; 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 "$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