Last week I needed to email a signed contract — a 47MB PDF stuffed with scanned pages. My first instinct was to open SmallPDF. Then I stopped. This was a legal document with my name, address, and signature on every page. Why was I about to upload it to a server I don’t control?
I’ve been building and shipping software for years, and I still catch myself reaching for a cloud tool when a way to compress PDF Mac locally is already sitting right here. PDF compression is one of those cases where going local isn’t just possible — it’s better. Faster, more controllable, and your documents never leave your machine.
Here’s how I handle it, and why you probably should too.
- Why You Should Stop Uploading PDFs to Online Compressors
- Method 1: macOS Preview — The Two-Click Option
- Method 2: Ghostscript — The Power Tool You Probably Already Have
- What Most People Miss: You’re Already Paying for Ghostscript
- Batch Compression: Handling Multiple Files
- Automator Quick Action: Right-Click to Compress
- Fine-Tuning: When Presets Aren’t Enough
- Honest Assessment: What Works and What Doesn’t
- Frequently Asked Questions
Why You Should Stop Uploading PDFs to Online Compressors
Let me be direct: every time you drag a PDF into SmallPDF, iLovePDF, or any web-based compressor, that file hits someone else’s server. Most of these services claim they delete your file after processing. Some even promise encryption in transit.
But “promise” is doing a lot of heavy lifting there.
If you’re compressing a vacation photo PDF, fine. But if it’s a tax return, a signed contract, medical records, or a business proposal with proprietary data — you’ve just made a privacy decision without thinking about it. Under regulations like GDPR or Korea’s PIPA, uploading personal documents to third-party servers without consideration is increasingly a compliance question, not just a preference.
The good news: macOS has everything you need built in, or one brew install away.
Method 1: macOS Preview — The Two-Click Option
Preview is the simplest approach and works fine for basic compression. No installation needed.
- Open your PDF in Preview.
- Go to File → Export…
- In the Quartz Filter dropdown, select Reduce File Size.
- Save.
That’s it. For a scan-heavy PDF, I’ve seen this cut file size by 60-70%.
⚠️ Watch out: Preview’s “Reduce File Size” filter is aggressive with image quality. It downsamples images significantly, which can make scanned documents blurry and nearly unreadable. For text-heavy scans, this is often too much. For quick compression of image-light PDFs, it works fine.
There’s no way to adjust the compression level in Preview’s built-in filter. It’s all-or-nothing. If you need more control — and you usually do — that’s where Ghostscript comes in.
Method 2: Ghostscript — The Power Tool You Probably Already Have
Ghostscript is a free, open-source interpreter for PDF and PostScript files. It’s been around since 1988. Many commercial PDF tools — including some you’ve paid for — use Ghostscript under the hood.
Installing Ghostscript
If you have Homebrew (and if you’re a developer on a Mac, you should):
brew install ghostscript
Verify the installation:
gs --version
You should see version 10.x or later.
The Core Command
Here’s the command I use most often:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \ -dPDFSETTINGS=/ebook \ -dNOPAUSE -dBATCH -dQUIET \ -sOutputFile=compressed.pdf original.pdf
Let me break down what each flag does — because blindly copying commands without understanding them is how you get burned.
| Flag | What It Does |
|---|---|
-sDEVICE=pdfwrite | Tells Ghostscript to output a PDF (not PostScript or another format) |
-dCompatibilityLevel=1.4 | Targets PDF 1.4 spec — works with virtually every PDF reader out there |
-dPDFSETTINGS=/ebook | Preset balancing quality and file size (150 DPI images) |
-dNOPAUSE | Don’t pause between pages |
-dBATCH | Exit after processing (don’t drop into interactive mode) |
-dQUIET | Suppress routine output messages |
-sOutputFile=compressed.pdf | Output filename |
original.pdf | Input filename |
Understanding -dPDFSETTINGS Presets
This is where the real control lives. Ghostscript provides five built-in presets:
| Preset | Image DPI | Best For | Typical Reduction |
|---|---|---|---|
/screen | 72 DPI | Screen-only viewing, maximum compression | 70-90% |
/ebook | 150 DPI | Email attachments, general sharing | 50-70% |
/printer | 300 DPI | Desktop printing | 20-40% |
/prepress | 300 DPI | High-quality print production | 10-20% |
/default | Varies | Middle ground, no specific optimization | 30-50% |
Pro tip: For most everyday use — emailing documents, uploading to portals, sharing via chat — /ebook at 150 DPI is the sweet spot. Text stays crisp. Images are clear enough for on-screen reading. File sizes drop dramatically.
I use /screen only when I need the absolute smallest file and don’t care about image quality (like compressing a text-heavy report where the images are decorative). I use /printer when someone specifically needs to print the document.
What Most People Miss: You’re Already Paying for Ghostscript
Here’s something that surprised me when I first dug into this: many of the “premium” PDF compression tools — desktop apps charging $30-50 — are essentially graphical wrappers around Ghostscript. They add a drag-and-drop interface, maybe a progress bar, and call it a product.
I’m not knocking those developers. A good GUI has value. But if you’re comfortable with a terminal — and if you’re reading this blog, you probably are — you’re paying for something you can do in one command.
This extends beyond compression. Ghostscript can merge PDFs, split them, extract pages, convert to images, add watermarks, and linearize for web viewing. It’s an entire PDF toolkit hiding behind a cryptic name.
The real insight isn’t “Ghostscript is free.” It’s that the tools you already have are more capable than the tools you think you need. I’ve seen the same pattern with FFmpeg for video, ImageMagick for images, and curl for API testing. Developers keep reaching for cloud services when battle-tested CLI tools are one command away.
Batch Compression: Handling Multiple Files
If you’ve got a folder of PDFs to compress — say, a stack of scanned receipts — a simple shell loop handles it:
mkdir -p compressed
for f in *.pdf; do
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \
-dNOPAUSE -dBATCH -dQUIET \
-sOutputFile="compressed/${f}" "$f"
done
This creates a compressed/ directory and processes every PDF in the current folder. Original files stay untouched.
Pro tip: Want to see how much space you saved? Add this after the loop:
echo "Original: $(du -sh *.pdf | tail -1)" echo "Compressed: $(du -sh compressed/ | tail -1)"
For more advanced workflows, you could wrap this in an Automator action or a Shortcuts workflow on macOS, so you can right-click any PDF in Finder and compress it without opening Terminal.
Automator Quick Action: Right-Click to Compress
If you want the convenience of a GUI without sacrificing privacy, create a macOS Quick Action:
- Open Automator → New → Quick Action.
- Set “Workflow receives current” to PDF files in Finder.
- Add a Run Shell Script action.
- Set “Pass input” to as arguments.
- Paste this script:
for f in "$@"; do
dir=$(dirname "$f")
base=$(basename "$f" .pdf)
/opt/homebrew/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \
-dNOPAUSE -dBATCH -dQUIET \
-sOutputFile="${dir}/${base}_compressed.pdf" "$f"
done
- Save it as “Compress PDF (Local).”
Now you can right-click any PDF in Finder, go to Quick Actions → Compress PDF (Local), and get a compressed copy without ever opening Terminal or a browser.
⚠️ Watch out: Use the full path to gs — that’s /opt/homebrew/bin/gs for Apple Silicon Macs or /usr/local/bin/gs for Intel Macs. Automator doesn’t always inherit your shell’s PATH.
Fine-Tuning: When Presets Aren’t Enough
Sometimes the presets are too aggressive or too gentle. You can override specific settings:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \ -dColorImageResolution=200 \ -dGrayImageResolution=200 \ -dMonoImageResolution=300 \ -dColorImageDownsampleType=/Bicubic \ -dNOPAUSE -dBATCH -dQUIET \ -sOutputFile=custom_compressed.pdf original.pdf
This gives you 200 DPI for color and grayscale images (a step up from /ebook‘s 150) while keeping monochrome images at 300 DPI for sharp text in scanned documents. Bicubic downsampling produces smoother results than the default.
You can also strip metadata if privacy is your primary concern:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 \ -dPDFSETTINGS=/ebook \ -dNOPAUSE -dBATCH -dQUIET \ -dFastWebView=true \ -sOutputFile=stripped.pdf original.pdf
This won’t remove all metadata (for that, you’d pair it with exiftool or qpdf), but it cleans up a fair amount during the rewrite process.
Honest Assessment: What Works and What Doesn’t
What works great:
- Ghostscript handles image-heavy PDFs brilliantly. Scanned documents, photo-embedded reports, and presentations with lots of graphics see the biggest reductions.
- The command is fast. A 50MB PDF typically compresses in under 5 seconds on an M-series Mac.
- Batch processing is trivial — something web tools make painful or paywalled.
What doesn’t work as well:
- PDFs that are already optimized won’t shrink much. If your PDF is mostly vector graphics and text, Ghostscript might only shave off 5-10%.
- Very old or malformed PDFs can occasionally cause errors. I’ve hit this maybe twice in years, and re-saving from Preview first usually fixes it.
- The quality presets are opaque if you don’t read the docs. The names (
/screen,/ebook) don’t immediately tell you what DPI they target.
What I’d do differently: If I were starting over, I’d set up the Automator Quick Action on day one and never think about it again. The initial setup takes 5 minutes and saves you from ever reaching for a web tool.
Frequently Asked Questions
Is Ghostscript safe to install via Homebrew?
Yes. Ghostscript is an open-source project maintained by Artifex Software since 1988. It’s one of the most established tools in the open-source ecosystem, and Homebrew pulls from the official, verified source.
How much can I compress a PDF with Ghostscript?
It depends on the content. Scan-heavy PDFs (like contracts or signed documents) often compress by 60-80% with the /ebook preset. Text-only PDFs with minimal images might only shrink by 10-20%.
Does Ghostscript preserve hyperlinks and bookmarks?
In most cases, yes. The pdfwrite device preserves PDF structure including links and bookmarks. However, heavily interactive PDFs with form fields or JavaScript may lose some functionality. Always test with a copy first.
Can I use this on Linux or Windows too?
Absolutely. Ghostscript is cross-platform. On Ubuntu/Debian, install with sudo apt install ghostscript. On Windows, grab the installer from the official Artifex site. The gs command and all flags work identically.



