Img2pdf logo

Img2pdf

Community
cat-xierluo
img2pdf

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

Overview

Publishercat-xierluo
Repositorylegal-skills
Skill nameimg2pdf
Stars
722
Forks
109
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by cat-xierluo on GitHub. Read the source before you install it.

Installation

Install the Img2pdf AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/cat-xierluo/legal-skills/tree/main/skills/img2pdf
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/cat-xierluo/legal-skills.git /tmp/legal-skills
mkdir -p .claude/skills
cp -r /tmp/legal-skills/skills/img2pdf .claude/skills/img2pdf
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Img2pdf in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Img2pdf on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Img2pdf is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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-* 不残留)。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Img2pdf AI skill do?

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

Why use Img2pdf on TypingMind?

Because you install it once and use it with any model. Img2pdf is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Img2pdf in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/cat-xierluo/legal-skills/tree/main/skills/img2pdf. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Img2pdf?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Img2pdf?

As many as you like. As long as a model supports skills, you can use Img2pdf with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Img2pdf AI skill free?

Yes. It is published on GitHub by cat-xierluo under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇