Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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