Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active April 17, 2024 12:20
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vielhuber/0fe2fda73262ef495a4a91bb835a1d2b to your computer and use it in GitHub Desktop.
Save vielhuber/0fe2fda73262ef495a4a91bb835a1d2b to your computer and use it in GitHub Desktop.
ImageMagick: Increase pdf scan contrast and sharpening #tools
convert -density 150 input.pdf -brightness-contrast 5x25 -sharpen 0x1 output.pdf
convert -density 300 input.pdf -colorspace gray -normalize -level 50%,51% -sharpen 0x1 output.pdf
convert -density 300 input.pdf -colorspace gray -normalize -level 25%,26% -sharpen 0x1 output.pdf
convert -density 300 input.pdf -colorspace gray -normalize -modulate 150 -sharpen 0x1 output.pdf
convert -density 300 input.pdf -contrast -contrast -contrast -contrast -sharpen 0x1 output.pdf
convert -density 300 input.pdf -contrast-stretch 15% -sharpen 0x.5 output.pdf
find . -name '*.pdf' -type f -exec convert -density 150 {} -brightness-contrast 5x25 -sharpen 0x.5 {}_new.pdf \;
@munim
Copy link

munim commented Jul 25, 2023

I had a bulk of unprocessed scanned of documents. I used the following which worked really great for me with a 72.3% file size reduction:

convert -density 300 input.pdf -normalize -sharpen 0x2 -compress jpeg -quality 70 output.pdf

@vielhuber
Copy link
Author

I had a bulk of unprocessed scanned of documents. I used the following which worked really great for me with a 72.3% file size reduction:

convert -density 300 input.pdf -normalize -sharpen 0x2 -compress jpeg -quality 70 output.pdf

Thanks, will try that also out.

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