Agent skill

Img2pdf

by cat-xierluo in cat-xierluo/legal-skills

将图片或 PDF 页面按 N 张/页编排为标准化 A4 PDF,或将长截图渲染为单张自适应高度 PDF。本技能应在用户需要将截图(手机截图、视频截图)、照片、已有 PDF 页面或长截图(微信聊天、庭审笔录)合并为 PDF 时使用。不要用于:OCR 文字识别、PDF 内容编辑、图片格式转换。

MITAuto-check passedDocuments & Office

Install Img2pdf

skills CLI
$ npx skills add cat-xierluo/legal-skills --skill img2pdf -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install cat-xierluo/legal-skills img2pdf --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/cat-xierluo/legal-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/img2pdf .claude/skills/img2pdf && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
img2pdf
GitHub stars
720
Token cost
~1.1k tokens
SKILL.md length
270 words
Files
6 (incl. scripts, references)
Skills in repo
62
Repo updated
First seen
Licence
MIT

At a glance

将图片或 PDF 页面按 N 张/页编排为标准化 A4 PDF,或将长截图渲染为单张自适应高度 PDF。本技能应在用户需要将截图(手机截图、视频截图)、照片、已有 PDF 页面或长截图(微信聊天、庭审笔录)合并为 PDF 时使用。不要用于:OCR 文字识别、PDF 内容编辑、图片格式转换。

  • Works in 4 steps: 收集输入 → 转换为页面 → 计算布局 → …
  • Tasks that involve PDF
  • SKILL.md covers 定位, 与其他技能配合, 依赖 and 输入/输出, plus 3 more sections
  • Runs Python scripts from its folder; calls python3

What it does

Img2pdf is an agent skill from cat-xierluo/legal-skills. 将图片或 PDF 页面按 N 张/页编排为标准化 A4 PDF,或将长截图渲染为单张自适应高度 PDF。本技能应在用户需要将截图(手机截图、视频截图)、照片、已有 PDF 页面或长截图(微信聊天、庭审笔录)合并为 PDF 时使用。不要用于:OCR 文字识别、PDF 内容编辑、图片格式转换。

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including scripts and reference files (for example `CHANGELOG.md`, `references/layout-examples.md` and `scripts/img_to_pdf.py`).

It sits in Documents & Office, covering PDF. The licence is MIT.

When your agent uses it

  • Tasks that involve PDF

Example prompts

  • “/img2pdf”

Requirements

  • Python 3

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. 收集输入
  2. 转换为页面
  3. 计算布局
  4. 生成 PDF

What it can do on your machine

Read from SKILL.md and the folder at commit db2c58c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Img2pdf loads about 1.1k tokens when it runs, and up to ~2.7k if it reads all its reference files. Until then it costs about 38 tokens; SKILL.md has 270 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from cat-xierluo/legal-skills at commit db2c58c, republished under its MIT licence (© cat-xierluo). 270 words, ~1,147 tokens.

Download SKILL.mdSave it as .claude/skills/img2pdf/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
img2pdf
description
将图片或 PDF 页面按 N 张/页编排为标准化 A4 PDF,或将长截图渲染为单张自适应高度 PDF。本技能应在用户需要将截图(手机截图、视频截图)、照片、已有 PDF 页面或长截图(微信聊天、庭审笔录)合并为 PDF 时使用。不要用于:OCR 文字识别、PDF 内容编辑、图片格式转换。
homepage
https://github.com/cat-xierluo/legal-skills
author
杨卫薪律师(微信ywxlaw)
version
1.2.0
license
MIT

img2pdf

定位

本技能解决"大量截图/照片需要编排为紧凑 PDF 提交"以及"超长截图(微信聊天、庭审笔录)需要保留上下逻辑转为 PDF"的问题。核心场景是法律证据材料整理。

核心职责:

  1. 将图片目录或多个图片文件编排为 A4 PDF,支持 1/2/3/4 张每页。
  2. 将已有 PDF 的每页重新编排为 N 张每页的紧凑布局。
  3. 自动检测图片横竖方向,选择合适的 A4 页面方向。
  4. 可配置页边距,确保打印效果良好。
  5. v1.2.0 长截图模式:按 A4 比例自动切割超长图再编排(微信聊天场景),或将整张长图渲染为单张自适应高度 PDF(庭审笔录场景)。

本技能不做 OCR、不编辑 PDF 内容、不处理视频文件。若需要从视频提取截图,先使用 video-screenshot。

与其他技能配合

  • 上游:video-screenshot 提取视频截图后,用本技能编排为 PDF。
  • 上游:截图工具(手机截图、浏览器截图)产出的图片文件。
  • 下游:pdf-organizer 可对编排后的 PDF 做进一步整理(拆分、合并、命名)。
  • 替代:pdf-organizer 的 --normalize-a4 只做页面标准化,不做多图编排。

依赖

系统依赖

无额外系统依赖。

Python 包
包名用途安装命令
pypdf>=4.0.0PDF 页面变换与合并python3 -m pip install -r scripts/requirements.txt
Pillow>=10.0.0图片格式检测同上
PyMuPDF>=1.24.0图片转 PDF 页面同上

输入/输出

输入
  • 图片目录:扫描目录下所有 JPG/PNG/WebP 文件。
  • 多个图片文件:直接列出图片路径。
  • 已有 PDF:将 PDF 每页当作图片重新编排。
输出
  • 单个 A4 PDF 文件,每页包含 1-4 张图片,等比缩放居中。

工作流程

1. 收集输入

根据 --input 参数收集图片或 PDF 文件。如果是目录,扫描其中所有支持格式的图片。按文件名或修改时间排序。

2. 转换为页面
  • 图片文件:通过 PyMuPDF 转为单页 PDF。
  • PDF 文件:读取每一页作为独立页面。
3. 计算布局

根据 --per-page 和页面方向计算每张图片的可用区域:

  • per-page=1:整页减去边距,横竖由图片方向决定。
  • per-page=1:整页减去边距,横竖由图片方向决定。
  • per-page=2:A4 横版,左右两列。
  • per-page=3:A4 横版,三列并排。
  • per-page=4:A4 横版或竖版,2×2 网格。
  • per-page=auto(默认):竖版图多 → 3张/页,横版图多 → 1张/页。

每张图片等比缩放适配其可用区域,居中放置。

4. 生成 PDF

将编排后的页面写入输出 PDF。不修改任何原始文件。

执行脚本

首次使用时安装依赖:

bash
python3 -m pip install -r scripts/requirements.txt
手机截图(自动 3 张/页)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/screenshots/ \
  --output /path/to/output.pdf
# 自动检测:竖版图多 → 3张/页
电脑截图(自动 1 张/页)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/desktop-screenshots/ \
  --output /path/to/output.pdf
# 自动检测:横版图多 → 1张/页(A4横版)
手机截图 2 张/页(A4 横版左右并排)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/screenshots/ \
  --output /path/to/output.pdf \
  --per-page 2
视频截图 3 张/页
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/frames/ \
  --output /path/to/output.pdf \
  --per-page 3
已有 PDF 重新编排
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/original.pdf \
  --output /path/to/repacked.pdf \
  --per-page 2
多个图片文件
bash
python3 scripts/img_to_pdf.py \
  --input img1.jpg img2.jpg img3.png \
  --output /path/to/output.pdf \
  --per-page 3
微信聊天长截图(v1.2.0,按 A4 比例自动切 + 3 张/页)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/wechat_long.png \
  --output /path/to/wechat.pdf \
  --split \
  --per-page 3
# 1080×6000 → 按 1080×√2≈1527px 切 4 段 → 2 页 A4 横版
微信聊天长截图(显式切割段高)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/wechat_long.png \
  --output /path/to/wechat.pdf \
  --split \
  --split-height 1500 \
  --per-page 3
庭审笔录长截图(v1.2.0 vertical 模式,整图一长页)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/transcript.png \
  --output /path/to/transcript.pdf \
  --mode vertical
# 不切割,1080×5000 → 1 页 595×2573pt
# 页面高度按图等比缩放,保留上下逻辑
预览(不写入文件)
bash
python3 scripts/img_to_pdf.py \
  --input /path/to/dir/ \
  --per-page 2 \
  --dry-run
常用参数
参数说明默认值
--input / -i图片文件、PDF 文件或目录(必填)-
--output / -o输出 PDF 路径<输入名>_编排.pdf
--mode编排模式:nup(N 张/页)或 vertical(单图一长页)nup
--per-page / -nnup 模式下每页图片数:1/2/3/4,或省略自动auto(竖版3张,横版1张)
--margin / -m页边距(pt)25
--orientationnup 模式页面方向:auto/landscape/portraitauto
--sort排序:name/time/nonename
--split启用长截图切割(nup 模式)关闭
--split-height切割段高(px);不传 = 按 A4 比例(图宽 × √2);vertical 模式忽略A4 比例
--dry-run仅预览不输出false
两种模式对照
维度nupvertical
是否切割视 --split 而定不切(强制)
每页图数1/2/3/4必为 1
页面尺寸A4 固定宽度固定 A4 595pt,高度按图等比
适用场景微信聊天、视频截图、证据照片庭审笔录、单页长截图

交付检查

完成后检查:

  1. 输出 PDF 页数 = ceil(总图片数 / per-page)(nup 模式)或 = 图片数(vertical 模式)。
  2. 每页图片清晰可读,没有超出页面边界。
  3. 页边距合理,打印时不会裁切内容。
  4. 横竖方向正确(手机截图横版并排,视频截图三列等)。
  5. 原始图片和 PDF 未被修改或删除。
  6. 长截图模式:切割段高符合 --split-height 或 A4 比例默认;vertical 模式页面高度 = 图高 × (A4 宽 - 2×margin) / 图宽 + 2×margin。
  7. vertical 模式:临时目录已清理(/tmp/img2pdf-splits-* 不残留)。

© cat-xierluo, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (scripts, references) in skills/img2pdf of cat-xierluo/legal-skills.

  • SKILL.md
  • CHANGELOG.md
  • LICENSE.txt
  • references/layout-examples.md
  • scripts/img_to_pdf.py
  • scripts/requirements.txt

Open the folder on GitHubat commit db2c58c

Compare with similar skills

Img2pdf next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Img2pdf compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Img2pdf this skillcat-xierluo/legal-skills720—~1.1kAutomated safety check: PassMIT
MarkitdownImCa0/just-laws78114 repos~3.2kAutomated safety check: NotesMIT
Gzh Designisjiamu/gzh-design-skill4k—~2.2kAutomated safety check: PassAGPL-3.0
GenOffice Document CLIgenspark-ai/genoffice9.2k—~19kAutomated safety check: PassApache-2.0
Harness Book Best Practicewquguru/harness-books3.2k—~4.1kAutomated safety check: PassNone
Bookforge Korean Ebook PDF Makergongnyang/bookforge3161 repos~1.7kAutomated safety check: PassMIT

Similar skills

  • Markitdown

    ImCa0/just-laws

    Convert files and office documents to Markdown. An agent skill from ImCa0/just-laws.

    781 GitHub starsUsed in 14 repos~3.2k tokens
    Documents & OfficeAuto-check: notes
  • Gzh Design

    isjiamu/gzh-design-skill

    微信公众号文章排版引擎,将 Markdown 转换为可直接粘贴到公众号编辑器的 HTML。主题风格从 references/theme-index.md 注册的自定义主题库中选取,自动章节编号、关键词下划线标记、引言卡片、目录导航、代码块、图片/GIF、作者签名。支持 Markdown / Word(.docx) / PDF / 纯文本输入(非 Markdown…

    4k GitHub stars~2.2k tokensUpdated yesterday
    Documents & OfficeAuto-check passed
  • GenOffice Document CLI

    genspark-ai/genoffice

    Creates, converts, reads and edits real pptx, xlsx, docx and PDF files locally through the genoffice command line.

    9.2k GitHub stars~19k tokensUpdated today
    Documents & OfficeAuto-check passed
  • Harness Book Best Practice

    wquguru/harness-books

    Best practices for working on the Harness books repo. An agent skill from wquguru/harness-books.

    3.2k GitHub stars~4.1k tokensUpdated 5 mo ago
    Documents & OfficeAuto-check passed
  • Produces book-style Korean ebook PDFs from a topic or finished manuscript, with six design styles, real book parts and quality-check gates before output.

    316 GitHub starsUsed in 1 repo~1.7k tokens
    Documents & OfficeAuto-check passed
  • Instrument Data To Allotrope

    aws-samples/amazon-bedrock-agents-healthcare-lifesciences

    Official

    Convert laboratory instrument output files (PDF, CSV, Excel, TXT) to Allotrope Simple Model (ASM) JSON format or flattened 2D CSV.

    274 GitHub starsUsed in 2 repos~2.7k tokens
    Documents & OfficeAuto-check passed

More from cat-xierluo/legal-skills

All 62 skills in this repo
  • Elements-Style Complaint Generator

    cat-xierluo/legal-skills

    Converts a lawyer's ordinary complaint or a described case into the Supreme People's Court's elements-style Word template, with layout checks on the result.

    720 GitHub stars~2.5k tokensUpdated today
    Auto-check: notes
  • Lecture Performance Review

    cat-xierluo/legal-skills

    Analyzes raw lecture transcripts for verbal tics, pacing, time use and promise follow-through, with optional slide-by-slide comparison and cross-session tracking.

    720 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • De-AI Polish for Chinese Articles

    cat-xierluo/legal-skills

    Detects and rewrites machine-sounding patterns in the body text of Chinese articles while keeping the author's facts, headings and legal terms intact.

    720 GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • GitHub Star Manager

    cat-xierluo/legal-skills

    Finds GitHub projects mentioned in articles or screenshots and stars them, tracks updates to your starred repos, and builds an HTML dashboard to browse them.

    720 GitHub stars~2k tokensUpdated today
    Auto-check: notes
  • Legal Harness Initializer

    cat-xierluo/legal-skills

    Sets up or incrementally updates AGENTS.md and CLAUDE.md for legal professionals, with a minimal safety baseline and a check that a new session loads and follows the rules.

    720 GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Moot Court Simulation Builder

    cat-xierluo/legal-skills

    Chinese-language skill that organizes a case file into a multi-role mock trial with judge, parties and clerk, producing a transcript, issue review and a to-strengthen list.

    720 GitHub stars~1.4k tokensUpdated today
    Auto-check passed

Questions about Img2pdf

What does Img2pdf do?

将图片或 PDF 页面按 N 张/页编排为标准化 A4 PDF,或将长截图渲染为单张自适应高度 PDF。本技能应在用户需要将截图(手机截图、视频截图)、照片、已有 PDF 页面或长截图(微信聊天、庭审笔录)合并为 PDF 时使用。不要用于:OCR 文字识别、PDF 内容编辑、图片格式转换。. Img2pdf is an agent skill from cat-xierluo/legal-skills.

When should I use Img2pdf?

Img2pdf fits situations like: tasks that involve PDF.

How do I install Img2pdf in Claude Code?

Run `npx skills add cat-xierluo/legal-skills --skill img2pdf -a claude-code`. Or copy the skill folder (skills/img2pdf in cat-xierluo/legal-skills) into .claude/skills/img2pdf in your project. Claude Code loads it when a task matches its description.

How do I install Img2pdf in Codex?

Run `npx skills add cat-xierluo/legal-skills --skill img2pdf -a codex`. Or copy the skill folder (skills/img2pdf in cat-xierluo/legal-skills) into .agents/skills/img2pdf in your project. Codex loads it when a task matches its description.

Can I use Img2pdf in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cat-xierluo/legal-skills --skill img2pdf -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/img2pdf, .gemini/skills/img2pdf, .github/skills/img2pdf and .opencode/skills/img2pdf in your project.

What does Img2pdf need to run?

Going by SKILL.md and its folder, Img2pdf needs Python for the scripts in its folder and the command-line tools its instructions call (python3). Our summary lists: Python 3.

Does Img2pdf access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Img2pdf safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Img2pdf use?

Img2pdf is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Img2pdf use?

About 1.1k tokens (SKILL.md is roughly 4.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.6k tokens, read only when the agent opens those files.

What are the alternatives to Img2pdf?

Skills that share tags, products or a category with Img2pdf: Markitdown (ImCa0/just-laws, 781 stars), Gzh Design (isjiamu/gzh-design-skill, 4k stars), GenOffice Document CLI (genspark-ai/genoffice, 9.2k stars) and Harness Book Best Practice (wquguru/harness-books, 3.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Img2pdf?

cat-xierluo (a GitHub user) maintains it in cat-xierluo/legal-skills, which has 720 GitHub stars. The repository holds 62 skills in this directory. The repository was last updated on October 10, 2026.

Source: cat-xierluo/legal-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.