← 返回 Skills 市场
hexavi8

File Compression

作者 HeXavi8 · GitHub ↗ · v1.0.1
cross-platform ✓ 安全检测通过
461
总下载
2
收藏
3
当前安装
2
版本数
在 OpenClaw 中安装
/install 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...
使用说明 (SKILL.md)

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)
  • node
  • gs (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:

  1. Python: python3 --version (fallback: python --version)
  2. Node: node --version
  3. Ghostscript: gs --version (required for PDF Ghostscript paths)
  4. Python deps when needed:
    • pip install pikepdf
    • pip install pillow
  5. 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:

  1. Tell user what you are checking or running.
  2. Show the exact command before execution.
  3. For slow steps (pip install, npm install, large Ghostscript jobs), say you are waiting.
  4. After each step, report result and next action.

Bad Result Recovery

When output_size >= input_size, do not stop:

  1. Report exact from/to numbers and compression ratio.
  2. Explain likely cause:
    • PDF: already optimized, scanned-image content, metadata overhead, unsuitable preset.
    • Image: unsuitable format conversion, quality too high, small-file overhead.
  3. Retry with alternate strategy:
    • PDF: ebook -> screen, then switch backend.
    • Image: lower quality, switch backend, convert to webp, optionally resize.
  4. Return the best attempt and state which command produced it.

Agent Response Contract

After every compression task, always return:

  1. Output absolute path.
  2. from \x3Cbefore_size> to \x3Cafter_size>.
  3. saved \x3Cdelta_size> (\x3Cratio>%).
  4. Backend used.
安全使用建议
This skill appears to do exactly what it says: compress PDFs/images locally using Ghostscript, pikepdf/Pillow, and Sharp as a Node fallback. Before installing or running: (1) Confirm you trust the PyPI and npm packages listed (pikepdf, pillow, sharp) because 'pip install' and 'npm install' can run package install/build scripts; review package source or lock versions if concerned. (2) Ensure Ghostscript is installed from your OS package manager. (3) The metadata's 'primary credential: python' is meaningless for operation and can be ignored. (4) The scripts operate on files you point them at—avoid running on sensitive system files or giving the skill paths to secrets. If you want extra caution, run the install and scripts in a sandbox/container or inspect the included files (they are small and readable) before executing.
功能分析
Type: OpenClaw Skill Name: file-compression Version: 1.0.1 The OpenClaw AgentSkills bundle for file compression is benign. The `SKILL.md` explicitly instructs the AI agent to be transparent about installations and command executions, which is a strong positive security indicator against prompt injection. All Python and Node.js scripts use safe methods for executing external binaries (`subprocess.run` with lists of arguments in Python, `child_process.spawn` with an array of arguments in Node.js), preventing shell injection vulnerabilities. Dependencies are standard for image and PDF processing, and there is no evidence of data exfiltration, persistence mechanisms, or malicious intent.
能力评估
Purpose & Capability
Name/description match the actual behavior: scripts implement PDF and image compression using Ghostscript, pikepdf, Pillow, and Sharp. Required binaries (python3, node, gs) and included dependencies are appropriate for the stated purpose. Minor inconsistency: metadata/registry lists a 'primary credential' as 'python' (and SKILL.md shows primaryEnv: 'python'), which is not a standard credential name and is unnecessary for this skill.
Instruction Scope
SKILL.md instructions are narrowly scoped to checking/installing dependencies and running the included compression scripts. The scripts operate on user-supplied input/output paths, create temporary dirs, and call local binaries; they do not reference unrelated system paths, secrets, or external network endpoints. The instructions explicitly require telling the user before running installs and showing commands, improving transparency.
Install Mechanism
There is no automatic arbitrary download/install from unknown hosts; dependencies are standard PyPI (requirements.txt) and npm (package.json) packages and system Ghostscript. The skill asks the agent to run 'pip install -r requirements.txt' and 'npm install', which is a normal, low-risk install pattern. Note: npm packages (and some Python packages) may execute code during install via lifecycle/build scripts—this is a normal supply-chain risk to be aware of.
Credentials
The skill declares no required environment variables and requests only local binaries, which is proportionate. The only oddity is the 'primary credential'/'primaryEnv' set to 'python'—there are no credentials needed for compression and no env vars used by the scripts; this metadata entry appears unnecessary or mis-specified.
Persistence & Privilege
The skill is not always-enabled and does not request permanent system/agent configuration changes. It runs as a user-invoked tool and does not modify other skills or global settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install file-compression
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /file-compression 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
- Added requirements.txt to specify Python dependencies. - Enhanced SKILL.md with a metadata block declaring required binaries and packages. - Added explicit installation instructions for Python, Node, and Ghostscript. - Included safety notes for install commands and guidance on handling installation failures. - Existing CLI options, fallback logic, and reporting contract remain unchanged.
v1.0.0
Initial release of file-compression skill: - Compresses PDFs and images to reduce storage and transfer size. - Python-first workflows with automatic Node.js fallback when dependencies are missing. - Supports PDF compression (with quality presets) and image compression (quality, resize, format controls). - Automatically retries with alternate strategies if compression results are not optimal. - Provides clear execution steps, environment checks, and detailed result reporting after each task.
元数据
Slug file-compression
版本 1.0.1
许可证
累计安装 3
当前安装数 3
历史版本数 2
常见问题

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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 461 次。

如何安装 File Compression?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install file-compression」即可一键安装,无需额外配置。

File Compression 是免费的吗?

是的,File Compression 完全免费(开源免费),可自由下载、安装和使用。

File Compression 支持哪些平台?

File Compression 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 File Compression?

由 HeXavi8(@hexavi8)开发并维护,当前版本 v1.0.1。

💬 留言讨论