There is a specific feeling that comes with uploading a PDF to a free compressor website. You land on a page plastered with ads, you drag your file into a dotted rectangle, a progress bar crawls, and somewhere between "processing" and "download your file," you remember what's in that document. A client contract. A tax return. Your kid's medical records.
You just sent that to a server you know nothing about.
I kept doing it for years. Everybody does. You google "free PDF compressor," you pick whatever ranks first, you upload, you download, you move on with your day. The file gets smaller, the task gets done, and you try not to think about the fact that ilovepdf.com just processed your entire document on their infrastructure. They say they delete it within two hours. Maybe they do.
But here's what changed for me. I use a coding agent every day. Claude Code, specifically. And at some point I realized that compressing a PDF is just a shell command. The agent already knows how to run shell commands. So instead of opening a browser and uploading my file to a stranger's server, I type one sentence:
"Compress this PDF for email."
The agent figures out the rest. It runs Ghostscript locally, picks the right quality preset, compresses the file, and tells me the result. The original file stays untouched. Nothing leaves my machine.
That's it. That's the whole post, almost. But let me show you what's actually happening under the hood, because it's simpler than you'd expect.
The command
Here is the exact Ghostscript command that does the work:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dQUIET -sOutputFile="report-compressed.pdf" "report.pdf"
On Windows, the command is gswin64c instead of gs. A coding agent handles this automatically, but if you are running the command manually, use the right one for your system.
That /ebook preset is the one I use most. It targets 150 DPI, which is plenty for anything you're emailing or sharing on screen. A 12MB PDF typically drops to around 2MB. Over 80% smaller.
There are four presets, and they do what the names suggest:
-
/screenis 72 DPI. Smallest possible file. Fine for on-screen viewing, rough for print. -
/ebookis 150 DPI. This is the sweet spot for most things. Email attachments, shared docs, anything that doesn't get printed. -
/printeris 300 DPI. High quality. Use this when someone is actually going to print the document. -
/prepressis 300 DPI with color preservation. Archival grade. You probably don't need this unless you're in publishing.
The original file is never overwritten. You always get a new file with whatever name you specify in the output flag. If you mess up the preset choice, just run it again with a different one.
You don't need to remember any of this
This is the part that matters more than the command itself.
If you're using a coding agent, whether that's Claude Code, Codex, OpenCode, or anything else that runs shell commands, you don't need to memorize flags. You don't need to bookmark this page. You just talk to the agent.
"Compress report.pdf for email."
"Make this PDF smaller, keep it readable."
"Shrink all the PDFs in this folder, printer quality."
The agent knows what Ghostscript is. It knows the presets. It picks the right one based on what you said. If Ghostscript isn't installed yet, it can tell you how to install it (or just install it for you, depending on your setup).
The point is that you stop being the person who translates intent into commands. The agent handles that translation. You stay at the level of what you actually want.
Why this is better than the website
It's not just faster, though it is faster. The real difference is where your file goes.
When you use ilovepdf.com or smallpdf.com or any of the dozen sites that rank for "free pdf compressor," your document travels to their servers. The compression happens on their infrastructure. They claim GDPR compliance and encrypted transfers and automatic deletion. Fine. I'm sure most of them are legitimate operations run by reasonable people.
But think about what people actually upload to these sites. Tax documents. Contracts with client names and dollar amounts. Medical records. NDAs. Insurance paperwork. The kind of stuff you'd never email to a stranger, but you'll casually upload to a website you found thirty seconds ago because it had a friendly blue interface.
With a coding agent running Ghostscript, the file never leaves your machine. The compression happens in a local process. There is no upload, no server, no two-hour deletion policy to trust. Your document stays on your disk, where it was before, just smaller.
That is not a convenience improvement. It is a privacy improvement.
Installing Ghostscript
Ghostscript is free, open source, and has been around for decades. It runs on everything. Installation takes one command:
macOS:
brew install ghostscript
Linux (Debian/Ubuntu):
sudo apt install ghostscript
Windows:
winget install -e --id ArtifexSoftware.GhostScript
If you already have a coding agent set up, ask it to install Ghostscript for you. It can handle that too.
What I actually built
I kept running into the same pattern. Not just with PDFs, but with image conversion, video cropping, file cleanup, batch renaming. These are all tasks where I'd either open a heavy application or go to some random website, when the reality is that they're all just shell commands underneath.
So I built a set of skills for coding agents. Six of them: PDF operations, image conversion, video processing, audio normalization, file operations, and automation workflows. They're not code. They're structured instructions that tell the agent how to handle these tasks with good defaults, safety checks, and the right flags. The kind of thing where you say "compress this" and it just works, no googling, no flag hunting, no uploading to strangers.
I packaged them into a utility skills pack on my Patreon alongside the ComfyUI workflows I sell there. Or you can just use the Ghostscript command from this post. It works fine on its own. The skill just saves you from having to remember the flags every time.
Top comments (0)