Skip to content

Instantly share code, notes, and snippets.

@rittme
Last active March 24, 2025 02:57
Show Gist options
  • Select an option

  • Save rittme/7554bca1e62cb25df44389c69df20b33 to your computer and use it in GitHub Desktop.

Select an option

Save rittme/7554bca1e62cb25df44389c69df20b33 to your computer and use it in GitHub Desktop.
Make image look like it was scanned
# Best one
convert -density 200 INPUT.pdf -rotate 0.3 +noise Multiplicative -format pdf -quality 85 -compress JPEG -colorspace gray OUTPUT.pdf
# A few other options
convert -density 130 input.pdf -rotate 0.2 -attenuate 0.25 +noise Laplacian -colorspace Gray output.pdf
convert -density 150 input.pdf -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Laplacian -sharpen 0x1.0 -colorspace Gray output.pdf
convert -density 150 input.pdf -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Gaussian -sharpen 0x1.0 -colorspace Gray output.pdf
convert -density 150 input.pdf -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Gaussian -attenuate 0.03 +noise Laplacian -sharpen 0x1.0 -colorspace Gray output.pdf
convert -density 150 input.pdf -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Multiplicative -attenuate 0.03 +noise Laplacian -colorspace Gray output.pdf
convert -density 150 input.pdf -rotate "$([ $((RANDOM % 2)) -eq 1 ] && echo -)0.$(($RANDOM % 4 + 5))" -attenuate 0.4 +noise Multiplicative -attenuate 0.03 +noise Laplacian -sharpen 0x1.0 -colorspace Gray output.pdf
convert -density 130 input.pdf -rotate 0.2 -attenuate 0.2 +noise Laplacian -colorspace Gray output.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment