Make a PDF look like it was manually scanned
- Published at
- Updated at
- Reading time
- 1min
I live in Germany, and while many think we have things in order here, we still need to sort out bureaucracy. It's a clu**fu** at best because German officials rely on paper – paper and handwritten signatures.
It can go so far that a scanned document image is preferred over a nice and sharp PDF. I don't own a printer, let alone a scanner, so occasionally, I drag myself to the local copy shop to do official business.
Until now! I've been browsing Hacker News, and the shell script below takes a PDF and makes it look like it's been scanned.
#!/bin/sh
ROTATION=$(shuf -n 1 -e '-' '')$(shuf -n 1 -e $(seq 0.05 .5))
convert -density 150 $1 \
-linear-stretch '1.5%x2%' \
-rotate ${ROTATION} \
-attenuate '0.01' \
+noise Multiplicative \
-colorspace 'gray' $2
Suppose you called the script index
, you can now run the following command...
./index.sh original.pdf scanned.pdf
... to scan your PDFs without a physical scanner.
Side note: the convert
command is part of the imagemagick
tools and wasn't available on my machine. You might have to install it first. A brew install imagemagick
did the trick for me, though.
As Thomas Steiner pointed out; you can reach similar visual effects with modern browser APIs right within your browser.
Join 5.5k readers and learn something new every week with Web Weekly.