Skip to content

Instantly share code, notes, and snippets.

@andreadellacorte
Forked from jduckles/scanned_pdf.sh
Last active January 2, 2021 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreadellacorte/cd45b93c84de1773a742b22e40380e36 to your computer and use it in GitHub Desktop.
Save andreadellacorte/cd45b93c84de1773a742b22e40380e36 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Make a PDF look scanned.
# Extracted from https://github.com/baicunko/scanyourpdf and modified for smaller output files (compression lower density).
# Project requires ImageMagick and GhostScript. This will do the trick on Ubuntu:
# sudo apt-get install ghostscript
# sudo apt-get install imagemagick
# This should work on macOS with Homebrew:
# brew install ghostscript
# brew install imagemagick
# If you're getting a PDF security error see https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion
INPUT_FILE=$1
convert -density 150 ${INPUT_FILE} -colorspace 'gray' +noise Gaussian -rotate 0.5 -depth 2 scanned_${INPUT_FILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment