Skip to content

Instantly share code, notes, and snippets.

@bre7
Last active November 17, 2023 23:04
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bre7/468e4a73bc7a6b5ae5542c2529fc58a3 to your computer and use it in GitHub Desktop.
Save bre7/468e4a73bc7a6b5ae5542c2529fc58a3 to your computer and use it in GitHub Desktop.
Simulate photo copier / fax / scanner effect using ImageMagick

Solution 1

convert original.pdf -colorspace gray +clone -blur 0x1 +swap -compose divide -composite -linear-stretch 5%x0% -rotate 1.5 fake-scanned.pdf

Colorscan variation:

convert original.pdf +clone -blur 0x1 +swap -compose divide -composite -gamma 0.1 -linear-stretch 5%x0% -rotate 1.5 fake-scanned.pdf

Solution 2

convert $f -colorspace gray \( +clone +noise Random -threshold 99% -negate -blur 0x5 -level 97.5%,97.5% \) -evaluate-sequence min -blur 0xecho $RANDOM %2 +1 | bc` -level 25%,75% -rotate -0.echo $RANDOM %10 +1 | bc -sharpen 0x3.0 -blur 0xecho $RANDOM %2 +1 | bc -level 10%,90% -rotate -0.` echo $RANDOM %10 +1 | bc` -sharpen 0x1.2 -colorspace gray



Credits:

Solution taken from https://tex.stackexchange.com/questions/94523/simulate-a-scanned-paper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment