← Back to Skills Marketplace
wangkf

epub-eink-optimizer

by wangkf · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
212
Downloads
1
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install epub-eink-optimizer
Description
This skill should be used when the user wants to optimize an epub file for e-ink readers (墨水屏电子书). It handles image deduplication, removal of tiny decorative...
README (SKILL.md)

\r \r

epub 墨水屏优化技能\r

\r

目标\r

\r 将 epub 文件中的图片进行四步优化,大幅减小文件体积,同时保留在墨水屏设备上的可读性。\r \r

核心脚本\r

\r scripts/optimize_epub.py — 一键运行全部优化步骤,支持单独开关每个步骤。\r \r

# 全量优化(推荐默认用法)\r
python skills/epub-eink-optimizer/scripts/optimize_epub.py \x3Cepub路径>\r
\r
# 先分析,不修改文件\r
python skills/epub-eink-optimizer/scripts/optimize_epub.py \x3Cepub路径> --dry-run\r
\r
# 自定义参数示例\r
python skills/epub-eink-optimizer/scripts/optimize_epub.py \x3Cepub路径> \\r
    --max-width 600 \\r
    --quality 65 \\r
    --min-size 20480\r
\r
# 只做某几步\r
python skills/epub-eink-optimizer/scripts/optimize_epub.py \x3Cepub路径> \\r
    --no-dedup --no-clean-small\r
```\r
\r
**参数说明:**\r
\r
| 参数 | 默认值 | 说明 |\r
|------|--------|------|\r
| `--max-width` | 800 | 图片最大宽度(像素),超过则等比缩小 |\r
| `--quality` | 70 | JPEG 压缩质量(1-95),70 为画质与体积的平衡点 |\r
| `--min-size` | 10240 | 清除低于此字节数的图片(默认 10KB) |\r
| `--no-dedup` | — | 跳过重复图片合并 |\r
| `--no-resize` | — | 跳过宽度缩放 |\r
| `--no-recompress` | — | 跳过 JPEG 重压缩 |\r
| `--no-clean-small` | — | 跳过清小图 |\r
| `--dry-run` | — | 仅分析,不修改文件 |\r
\r
## 四步优化流程\r
\r
### 步骤 1:去重复图片\r
\r
同一张图片以不同文件名出现在多篇文章中(常见于转载同款配图、作者反复使用的插图)。\r
\r
- 用 MD5 哈希识别完全相同的图片\r
- 保留文件名排序靠前的一份,其余删除\r
- 自动更新所有 XHTML 中的引用和 OPF manifest\r
\r
### 步骤 2:清除小图\r
\r
微信公众号文章末尾通常插有固定的二维码、点赞、广告等装饰性小图(通常 \x3C 5KB),对阅读毫无价值。\r
\r
- 删除低于 `--min-size` 字节的图片文件\r
- 从 XHTML 中移除对应的 `\x3Cimg>` 标签\r
- 清理残留的空 `\x3Cp>` / `\x3Cdiv>` 标签\r
\r
### 步骤 3:缩放大图\r
\r
墨水屏设备分辨率通常为 1024-1448px 宽,超出无意义。\r
\r
- 将宽度超过 `--max-width` 的图片等比缩小\r
- JPEG 保存为 JPEG,PNG 保存为 PNG\r
- 中间使用 LANCZOS 高质量缩放算法\r
\r
### 步骤 4:JPEG 重压缩\r
\r
epub 中的 JPEG 原始质量往往是 85-95,对墨水屏来说过于精细。\r
\r
- 以 `--quality`(默认 70)重新压缩所有 JPEG\r
- 使用 `optimize=True` 开启哈夫曼表优化\r
- 通常可节省 15-25%\r
\r
## 典型效果参考\r
\r
| 场景 | 优化前 | 优化后 | 压缩率 |\r
|------|--------|--------|--------|\r
| 微信公众号合集(100篇+) | 70MB | 13MB | ~82% |\r
| 图文并茂博客(50篇) | 30MB | 8MB | ~73% |\r
| 纯文字为主(少量配图) | 5MB | 3MB | ~40% |\r
\r
## 手动处理补充指南\r
\r
脚本覆盖大多数场景,以下情况需要手动干预(参考 `references/manual-fixes.md`):\r
\r
- 图片为 base64 内嵌(非独立文件)\r
- epub 内部目录结构非标准(如多层嵌套)\r
- 需要将彩色图片转为灰度以进一步减体积\r
\r
## 依赖\r
\r
```bash\r
pip install Pillow\r
```\r
\r
Python 标准库:`zipfile`, `hashlib`, `re`, `io`, `os`\r
Usage Guidance
This skill appears coherent and focused on EPUB image optimization. Before installing/running: 1) review and run the script with --dry-run first and always keep a backup of original EPUBs (the script writes changes in-place). 2) Confirm the script path referenced in SKILL.md matches the package layout. 3) Because the script uses simple basename replacements and regexes to update XHTML/OPF, test on a copy — in nonstandard EPUBs or with filenames that appear in text, replacements could be overzealous. 4) Ensure Pillow is installed in the runtime environment. 5) The provided file listing of optimize_epub.py in this review was truncated; if possible, inspect the full script locally to verify there are no unexpected network calls or extra behavior beyond what's shown. If you need higher assurance, ask the publisher for the full script and verify there are no network operations or hidden subprocess calls before running on sensitive content.
Capability Analysis
Type: OpenClaw Skill Name: epub-eink-optimizer Version: 1.0.0 The skill bundle provides a legitimate utility for optimizing EPUB files for e-ink devices by deduplicating, resizing, and recompressing images. The core logic in `scripts/optimize_epub.py` uses standard Python libraries (Pillow, zipfile) to process files locally and contains no evidence of network activity, data exfiltration, or malicious execution patterns.
Capability Assessment
Purpose & Capability
Name/description match the included code and docs: the Python script processes EPUB files and optimizes images. Declared dependency (Pillow) matches the code. No unrelated environment variables, binaries, or services are requested.
Instruction Scope
SKILL.md instructs running the included script and describes the four optimization steps implemented in scripts/optimize_epub.py. The instructions and script operate on EPUB content (XHTML, OPF, images) only and perform in-place modifications unless --dry-run is used. Two minor concerns: (1) SKILL.md examples use a path 'skills/epub-eink-optimizer/scripts/optimize_epub.py' which doesn't match the manifest path 'scripts/optimize_epub.py' — a path mismatch to verify; (2) the script performs text-based replacements and regex edits on XHTML/OPF (basename substitution and regex removal of <img> and <item> entries) which is brittle and could accidentally remove or alter other references if filenames collide with page text or if EPUB structure is non-standard. Use --dry-run and make backups.
Install Mechanism
No install spec; this is instruction + shipped Python scripts. The only required third-party dependency is Pillow (pip install Pillow), which is reasonable for image processing.
Credentials
No environment variables, credentials, or config paths are requested. The skill's actions are file-local (read/write the provided EPUB).
Persistence & Privilege
always is false; the skill is user-invocable and does not request permanent presence or modify other skills or system-wide settings.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install epub-eink-optimizer
  3. After installation, invoke the skill by name or use /epub-eink-optimizer
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
epub-eink-optimizer 1.0.0 - Initial release: Optimize EPUB files for e-ink readers through a four-step process. - Features automatic image deduplication, removal of small decorative images, resizing oversized images, and JPEG recompression. - Command-line script with flexible parameter control for each optimization stage. - Supports dry-run mode and manual adjustment of thresholds. - Designed to significantly reduce file size while preserving readability on e-ink devices.
Metadata
Slug epub-eink-optimizer
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is epub-eink-optimizer?

This skill should be used when the user wants to optimize an epub file for e-ink readers (墨水屏电子书). It handles image deduplication, removal of tiny decorative... It is an AI Agent Skill for Claude Code / OpenClaw, with 212 downloads so far.

How do I install epub-eink-optimizer?

Run "/install epub-eink-optimizer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is epub-eink-optimizer free?

Yes, epub-eink-optimizer is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does epub-eink-optimizer support?

epub-eink-optimizer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created epub-eink-optimizer?

It is built and maintained by wangkf (@wangkf); the current version is v1.0.0.

💬 Comments