This content originally appeared on DEV Community and was authored by Burak Can Kahraman
Are you tired of scanning images and trying to shrink them under 25 mbs just so you can send them via email ? Look no further, I am here to save you from this trouble. (that kinda rhymed.)
This basic shell script uses ghostscript to compress your scanned pdfs significantly. Just yesterday I scanned 100 pages of documents and it was over 90 mbs. I searched for a way to compress them under 25 mbs and voila. Here I was with only 6 mbs of pdfs. Much wow. Such compression.
Why we need it,
- Fast.
- Ez.
- No need to go online. Especially no need to upload company top-secret documents to any website you see on the Internet.
- Possible huge compression without notable loss.
Command usage:
./shrinkpdf.sh in.pdf out.pdf
Don't forget to install ghostscript.
If you are in a situation exactly like me where there are 100 pdf files under one folder that you want to compress altogether, a simple for loop will suffice.
import os
import subprocess
import sys
infolder = sys.argv[1]
outfolder = "compressed_" + infolder
os.mkdir(outfolder)
for f in os.listdir(infolder):
subprocess.run(["./shrinkpdf.sh", os.path.join(infolder, f), os.path.join(outfolder, f)])
Run this python script,
python shrink.py pdfs/
and all of your pdfs will be put under compressed_pdfs/.
http://www.alfredklomp.com/programming/shrinkpdf/
All the relevant details and more, inside. I humbly wanted to let you know such a useful tool exists.
This content originally appeared on DEV Community and was authored by Burak Can Kahraman
Burak Can Kahraman | Sciencx (2021-05-25T14:41:23+00:00) Want to compress your pdf files ?. Retrieved from https://www.scien.cx/2021/05/25/want-to-compress-your-pdf-files/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.