Ghostscript
$ gs Official Med RiskGhostscript (gs) is Artifex Software's veteran PostScript and PDF engine used to downsample and recompress PDFs (-sDEVICE=pdfwrite), render pages to PNG/TIFF (-sDEVICE=png16m), and merge documents. Automated runs require batch flags (-dNOPAUSE -dBATCH) and -dSAFER sandboxing.
brew install ghostscript Heavy PDF recompression and high-DPI rasterization run locally via gs without transferring large binary blobs over MCP.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Interactive GS> REPL and page-pause prompts occur by default unless -dNOPAUSE -dBATCH are supplied, and there is no structured JSON output.
- Drops into interactive
GS>shell if-dBATCHis omitted - Requires
-dQUIETto suppress banner noise
PostScript execution on untrusted inputs has a historical CVE surface, making -dSAFER mandatory; -sOutputFile= overwrites targets silently.
- Supports
-dSAFERsandbox mode for untrusted PostScript/PDF inputs - Overwrites
-sOutputFilewithout confirmation
Widely packaged on macOS (brew install ghostscript), Linux, and Windows (gswin64c), though the Windows binary name differs.
- Standard
gspackage on macOS/Linux;gswin64c.exeon Windows
Unmatched for PDF downsampling (-dPDFSETTINGS), color-space conversion, and PostScript rendering.
- Supports dozens of output devices including
pdfwriteandpng16m
Official Artifex Software engine (ArtifexSoftware/ghostpdl) actively maintained under AGPL-3.0 and commercial licensing.
- Maintained by Artifex Software since 1988
Comprehensive ReadTheDocs manual, though arcane -d/-s device switches and PostScript stack syntax have a steep learning curve.
- Uses
-sDEVICE=and-dPostScript parameter flags
Security, Auth & Guardrails
None required; operates on local PostScript and PDF files.
AGPL-3.0-or-later open source; proprietary/commercial distribution requires an Artifex commercial license.
# Ghostscript (gs) Agent Rules - Always include `-dNOPAUSE -dBATCH -dSAFER` so `gs` never drops into an interactive `GS>` prompt or exposes unsafe PostScript file operators. - Pass `-dQUIET` (`-q`) and write to a separate `-sOutputFile=` path.
Agent-Ready Command Recipes
Safe Read-Only Queries
gs -dNODISPLAY -dBATCH -q -c "currentsystemparams /Version get == quit"
Queries interpreter parameters cleanly without opening display windows or writing files.
Controlled Writes & Previews
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -dSAFER -sOutputFile=compressed.pdf input.pdf
Re-encodes input.pdf at 150 DPI into compressed.pdf non-interactively with -dSAFER enabled.
Strengths for Agents
- + Industry-standard PDF compression (
-dPDFSETTINGS=/ebookor/screen) and high-DPI rasterization. - + Predictable non-interactive execution once
-dNOPAUSE -dBATCH -dQUIET -dSAFERare standardized.
Caveats & Pitfalls
- ! Omitting
-dBATCHor-dNOPAUSEcausesgsto hang waiting on interactive stdin prompts. - ! AGPL-3.0 license requires commercial licensing from Artifex for proprietary SaaS redistribution.