/install file-compression
File Compression
Compress files with Python-first workflows and Node.js fallback workflows.
Supported File Types
- PDF:
.pdf - Image:
.jpg,.jpeg,.png,.webp
What This Skill Can Do
- Compress PDF with preset quality levels.
- Compress image with quality/resize/format controls.
- Switch backend automatically when dependencies are missing.
- Detect bad compression results and retry with better strategy.
Installation Spec (Before Running)
Required binaries:
python3(recommended>= 3.8)nodegs(Ghostscript, required for PDF Ghostscript paths)
Python install spec:
python3 -m pip install -r {baseDir}/requirements.txt
Node install spec:
cd {baseDir}
npm install
Ghostscript install examples:
- macOS:
brew install ghostscript - Ubuntu/Debian:
sudo apt-get update && sudo apt-get install -y ghostscript
Safety note:
- Explain to the user before each install command that third-party packages are being installed.
- If installation fails, report the failing command and switch to available fallback backend.
CLI Options Cheat Sheet
PDF (scripts/compress_pdf.py):
--preset screen|ebook|printer|prepress--strategy auto|ghostscript|pikepdf--remove-metadata--no-linearize--overwrite
PDF Node (scripts/compress_pdf_node.mjs):
--preset screen|ebook|printer|prepress
Image (scripts/compress_image.py):
--quality \x3C1-100>--format keep|jpeg|png|webp--max-width \x3Cn>--max-height \x3Cn>--strategy auto|pillow|node--overwrite
Image Node (scripts/compress_image_node.mjs):
--quality \x3C1-100>--format keep|jpeg|png|webp--max-width \x3Cn>--max-height \x3Cn>
Example Set (Python + Node)
PDF default:
python {baseDir}/scripts/compress_pdf.py in.pdf out.pdf
PDF aggressive:
python {baseDir}/scripts/compress_pdf.py in.pdf out.pdf --preset screen --strategy ghostscript
PDF with pikepdf:
python {baseDir}/scripts/compress_pdf.py in.pdf out.pdf --strategy pikepdf --remove-metadata
PDF via Node:
node {baseDir}/scripts/compress_pdf_node.mjs in.pdf out.pdf --preset ebook
Image default:
python {baseDir}/scripts/compress_image.py in.jpg out.jpg --quality 75
Image convert + resize:
python {baseDir}/scripts/compress_image.py in.png out.webp --format webp --quality 72 --max-width 1920
Image force Node backend:
python {baseDir}/scripts/compress_image.py in.jpg out.jpg --strategy node --quality 70
Image direct Node:
node {baseDir}/scripts/compress_image_node.mjs in.jpg out.jpg --quality 70 --max-width 1600
Environment and Fallback
Check and install in this order:
- Python:
python3 --version(fallback:python --version) - Node:
node --version - Ghostscript:
gs --version(required for PDF Ghostscript paths) - Python deps when needed:
pip install pikepdfpip install pillow
- Node deps when needed:
npm install
Fallback policy:
- PDF:
ghostscript->pikepdf->node-ghostscript - Image:
pillow->node-sharp
If python3.8+ is unavailable, try python3.11/3.10/3.9/3.8; if still blocked, use Node flow when possible.
Execution Transparency
Always communicate each step:
- Tell user what you are checking or running.
- Show the exact command before execution.
- For slow steps (
pip install,npm install, large Ghostscript jobs), say you are waiting. - After each step, report result and next action.
Bad Result Recovery
When output_size >= input_size, do not stop:
- Report exact from/to numbers and compression ratio.
- Explain likely cause:
- PDF: already optimized, scanned-image content, metadata overhead, unsuitable preset.
- Image: unsuitable format conversion, quality too high, small-file overhead.
- Retry with alternate strategy:
- PDF:
ebook -> screen, then switch backend. - Image: lower quality, switch backend, convert to
webp, optionally resize.
- PDF:
- Return the best attempt and state which command produced it.
Agent Response Contract
After every compression task, always return:
- Output absolute path.
from \x3Cbefore_size> to \x3Cafter_size>.saved \x3Cdelta_size> (\x3Cratio>%).- Backend used.
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install file-compression - After installation, invoke the skill by name or use
/file-compression - Provide required inputs per the skill's parameter spec and get structured output
What is File Compression?
Compress files to reduce storage and transfer size. Use this skill when users ask to shrink PDFs or images, optimize upload/share size, or balance quality an... It is an AI Agent Skill for Claude Code / OpenClaw, with 461 downloads so far.
How do I install File Compression?
Run "/install file-compression" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is File Compression free?
Yes, File Compression is completely free (open-source). You can download, install and use it at no cost.
Which platforms does File Compression support?
File Compression is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created File Compression?
It is built and maintained by HeXavi8 (@hexavi8); the current version is v1.0.1.