Install
openclaw skills install file-compressionCompress 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 and size. Supports PDF compression and image compression with Python-first workflows plus Node.js fallback when Python dependencies are unavailable.
openclaw skills install file-compressionCompress files with Python-first workflows and Node.js fallback workflows.
.pdf.jpg, .jpeg, .png, .webpRequired 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:
brew install ghostscriptsudo apt-get update && sudo apt-get install -y ghostscriptSafety note:
PDF (scripts/compress_pdf.py):
--preset screen|ebook|printer|prepress--strategy auto|ghostscript|pikepdf--remove-metadata--no-linearize--overwritePDF Node (scripts/compress_pdf_node.mjs):
--preset screen|ebook|printer|prepressImage (scripts/compress_image.py):
--quality <1-100>--format keep|jpeg|png|webp--max-width <n>--max-height <n>--strategy auto|pillow|node--overwriteImage Node (scripts/compress_image_node.mjs):
--quality <1-100>--format keep|jpeg|png|webp--max-width <n>--max-height <n>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
Check and install in this order:
python3 --version (fallback: python --version)node --versiongs --version (required for PDF Ghostscript paths)pip install pikepdfpip install pillownpm installFallback policy:
ghostscript -> pikepdf -> node-ghostscriptpillow -> node-sharpIf python3.8+ is unavailable, try python3.11/3.10/3.9/3.8; if still blocked, use Node flow when possible.
Always communicate each step:
pip install, npm install, large Ghostscript jobs), say you are waiting.When output_size >= input_size, do not stop:
ebook -> screen, then switch backend.webp, optionally resize.After every compression task, always return:
from <before_size> to <after_size>.saved <delta_size> (<ratio>%).