pdf-compressor
Skill8 starsChanged 44 days agoMITView on GitHub
Automatically compress PDF files when they are too large for processing. Use this skill when (1) a PDF file exceeds 10MB and needs compression for efficient processing, (2) user explicitly requests PDF compression, (3) reading a PDF fails with a file size error, or (4) a PDF exceeds the 32MB API limit. Compresses using Ghostscript while maintaining acceptable quality.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- gaoxin492/pdf-compressortheir own version, first seen Mar 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- gaoxin492/pdf-compressor★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository19 other files it gives its agents.
- claude-design-to-open-designSkill
- claude-htmlSkill
- memory-keeperSkill
- obsidian-excalidrawSkill
- paper-insertSkill
- paper-summary-simpleSkill
- paper-summarySkill
- pdf-e2cSkill
- pdf-figure-extractorSkill
- project-summarySkill
- speak-humanSkill
- statusline-buddySkill
- video-downloadSkill
- video-localizeSkill
- video-subtitle-extractorSkill
- vln-feedSkill
- vln-instructionSkill
- vln-paper-insertSkill
- xiaohongshuSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Use the bundled compression script:
- Distinctive: line 58
After compression, use the compressed PDF for the original task.
- Distinctive: line 166
Check if PDF is corrupted
- Distinctive: line 186
Check if Ghostscript is installed
- Very specific: line 188
Ensure gswin64c.exe or gswin32c.exe is in PATH
- Distinctive: line 196
Use higher quality level (screen → ebook → printer)
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PDF Compressor
Automatically compress large PDF files to enable processing or reduce file size.
When This Skill Triggers
This skill automatically activates when:
- Large PDF detected - PDF file exceeds 10MB
- User requests compression - User says "compress this PDF", "this PDF is too large", etc.
- Read failure - Attempting to read a PDF fails with file size error
- API limit - PDF exceeds 32MB (Claude API hard limit)
Compression Workflow
Step 1: Check file size
import os
file_size_mb = os.path.getsize('file.pdf') / (1024 * 1024)
if file_size_mb > 10:
# Trigger compressionStep 2: Run compression script
Use the bundled compression script:
python scripts/compress_pdf.py <input.pdf> -q ebookQuality levels:
screen- 72 dpi, smallest size (use for very large files >100MB)ebook- 150 dpi, balanced (default, recommended)printer- 300 dpi, high quality (minimal compression)prepress- 300 dpi, print-ready (minimal compression)
Options:
-o <output.pdf>- Save to different file (default: overwrite original)--no-backup- Don't backup original file
Step 3: Verify compression
The script outputs:
- Original file size
- Compressed file size
- Compression ratio (% reduction)
- Output file path
Step 4: Proceed with compressed file
After compression, use the compressed PDF for the original task.
Usage Examples
Example 1: Automatic compression on large file
User: "Please analyze this PDF report.pdf"
[File is 25MB]
1. Check size: 25MB > 10MB threshold
2. Compress: python scripts/compress_pdf.py report.pdf -q ebook
3. Result: Compressed from 25MB to 8MB (68% reduction)
4. Proceed: Read and analyze the compressed report.pdfExample 2: User requests compression
User: "This PDF is too big, can you compress it?"
1. Run: python scripts/compress_pdf.py document.pdf -q ebook
2. Report results to userExample 3: API limit exceeded
User: "Extract text from this 40MB PDF"
[Exceeds 32MB API limit]
1. Compress aggressively: python scripts/compress_pdf.py file.pdf -q screen
2. If still too large, inform user and suggest manual compression
3. Otherwise proceed with compressed fileScript Reference
compress_pdf.py
Python script that uses Ghostscript for PDF compression.
Requirements:
- Ghostscript must be installed on the system
- Script automatically detects Ghostscript location
Installation check:
from scripts.compress_pdf import PDFCompressor
compressor = PDFCompressor()
if not compressor.is_available():
# Ghostscript not found
# Provide installation instructionsProgrammatic usage:
from scripts.compress_pdf import PDFCompressor
compressor = PDFCompressor()
result = compressor.compress(
input_path='large.pdf',
output_path=None, # None = overwrite
quality='ebook', # screen/ebook/printer/prepress
backup=True # Backup before overwrite
)
if result['success']:
print(f"Compressed: {result['compression_ratio']}% reduction")
print(f"New size: {result['compressed_size_mb']} MB")
else:
print(f"Error: {result['error']}")Compression Guidelines
When to compress
- Always - File > 32MB (API limit)
- Recommended - File > 10MB (performance optimization)
- Optional - File < 10MB (only if user requests)
Quality selection
- File > 100MB → Use
screenquality (aggressive compression) - File 10-100MB → Use
ebookquality (balanced, default) - File < 10MB → Use
printerorprepress(minimal compression)
Compression expectations
Typical compression ratios:
- Scanned documents - 60-80% reduction
- Image-heavy PDFs - 50-70% reduction
- Text-only PDFs - 30-50% reduction
- Already compressed - 10-20% reduction (limited gains)
Handling edge cases
Ghostscript not installed:
- Inform user and provide installation instructions
- Windows: https://ghostscript.com/releases/gsdnld.html
- Mac:
brew install ghostscript - Linux:
sudo apt-get install ghostscript
Compression fails:
- Try lower quality level (ebook → screen)
- Check if PDF is corrupted
- Suggest manual compression tools
File still too large after compression:
- Inform user of the limitation
- Suggest splitting PDF or extracting specific pages
- Recommend external compression services
Implementation Notes
- Always backup - Original file is backed up before overwriting (unless
--no-backup) - Lossless for text - Text content remains readable at all quality levels
- Images affected - Lower quality levels reduce image resolution
- Speed - Compression time ~1-2 seconds per MB (varies by complexity)
- Path handling - Script handles spaces and special characters in filenames
- Error handling - Script validates Ghostscript availability and file existence
Troubleshooting
Script fails to find Ghostscript on Windows:
- Check if Ghostscript is installed
- Manually specify path if in non-standard location
- Ensure
gswin64c.exeorgswin32c.exeis in PATH
Compressed file is larger than original:
- Original was already optimized
- Try different quality level
- PDF may have compression-resistant content
Compression too aggressive:
- Use higher quality level (screen → ebook → printer)
- Images will be sharper but file size larger
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

