Compress a PDF to an exact size
The upload form says 200 KB maximum and rejects your 34 MB scan. Most compressors offer "low, medium, high" and a shrug. compress takes the number itself: give it a hard target and it works down a quality ladder until the file fits, or tells you plainly that it can't.
Local and free. Part of the open source pdfblah CLI; nothing is uploaded. Your 34 MB of payslips and IDs never leave your machine on their way to 200 KB.
What it actually does
- Only the images change. They are downscaled to what the page can show and re-encoded in place. Text and vector content stay untouched: still selectable, still razor sharp at any zoom. No page is turned into a photo of itself.
- Each attempt starts from the original. The ladder never recompresses a recompression, so quality degrades in one honest step, not compounding artifacts.
- A miss is a real answer. If even the floor setting can't reach the target, the report names the smallest achievable size, and that best effort is on disk so you can decide.
- Nothing is replaced blind. An image is only swapped when the new encoding is genuinely smaller, and images carrying transparency are left alone.
How to do it
pip install "pdfblah[app]"
# the portal says 200 KB
pdfblah compress in.pdf -o out.pdf --target 200kb
# no hard cap, just smaller (150 dpi, quality 75)
pdfblah compress in.pdf -o out.pdf
# choose the trade-off yourself
pdfblah compress in.pdf -o out.pdf --dpi 100 --quality 60 --grayscale
A real run: compressed: 11870 KB -> 150 KB (98.7% smaller, images at 100 dpi / q55,
1 recompressed, 0 kept). On a miss you get smallest achievable with the text layer
kept is 412 KB (target 200 KB) instead of a silently broken file.
Make it a right-click on your Mac
One command installs a Finder Quick Action called Shrink PDF:
curl -fsSL https://pdfblah.com/compress-mac.sh | sh
Select PDFs, right-click, Quick Actions → Shrink PDF. Smaller copies
land in ~/Downloads/compressed as name-small.pdf.
Tips
- Targets are honest bytes:
--target 200kb,--target 1.5mb, or plain bytes. - Text-only PDFs are usually small already; if one is huge, the bloat is elsewhere. tidy drops junk pages, and
pdfblah optimizesqueezes the structure. - Scans compress dramatically (they are all image); crisp digital documents barely budge, because there is nothing lossy to trade away. That is the tool refusing to lie to you.
- For the absolute minimum on a scan, Clean scan with
--bilevelproduces tiny pure black-and-white files.