-
Star
(292)
You must be signed in to star a gist -
Fork
(30)
You must be signed in to fork a gist
-
-
Save andyrbell/25c8632e15d17c83a54602f6acde2724 to your computer and use it in GitHub Desktop.
| # use ImageMagick convert | |
| # the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf | |
| convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf |
thank you! I have used some of these commands to build https://oakpdf.com which not only applies scanner effect, but also allows to insert an image of signature or draw a signature.
My observations regarding -density parameter: 200 is good enough in most cases, while 300 gives ultimate quality - but the build time get catastrophically slow..
Great
Thank you!
I used zenity to add graphical input and output prompts:
convert -density 150 "$(zenity --file-selection --title="Select Input File" --file-filter=*[PpDdFf])" -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Multiplicative -attenuate 0.03 +noise Multiplicative -sharpen 0x1.0 -colorspace Gray "$(zenity --file-selection --save --title="Select Output File" --filename ".pdf")"
Can also be found here as a .desktop file, so the script can be started from the starter on Linux machines:
https://gist.github.com/fewaltix/c1437171d16671741aafe146751dbf9f
work
On my ubuntu 20.04 machine this also added the PDF Metadata Tag producer=ImageMagick in the output. You might want to edit that out: https://askubuntu.com/questions/27381/how-to-edit-pdf-metadata-from-command-line
exiftool -Producer="" output.pdf
Using a realistic scanner name instead of the blank string is an exercise left for the reader 😛
If you want each page to be rotated by a different random amount, this worked for me:
magick -density 90 input.pdf -background white -seed 42 -rotate "%[fx:(u*2-1)*0.5]" -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
For those on Windows make sure to install Ghostscript as well or else you'll get errors like