img2pdf

Arrange images and PDF pages into multi-per-page A4 PDFs or adaptive-height long pages.

636|91|Updated Jan 7, 2026
One-click install
npx skills add https://github.com/cat-xierluo/legal-skills --skill img2pdf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: img2pdf
Source: https://github.com/cat-xierluo/legal-skills/tree/main/skills/img2pdf
Command: npx skills add https://github.com/cat-xierluo/legal-skills --skill img2pdf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pypdf, Pillow, PyMuPDF, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Legal evidence work often involves dozens of screenshots, photos, or long chat records that must be compiled into printable, well-organized PDF files. Manually arranging images into pages is slow and error-prone, and ultra-long screenshots (WeChat chats, hearing transcripts) lose their logical flow when handled by generic tools.

Core Features & Use Cases

  • N-up Layout: Arrange 1-4 images per A4 page with automatic portrait/landscape detection, configurable margins, and auto mode that picks 3-per-page for portrait images or 1-per-page for landscape images.
  • Long Screenshot Handling: Split ultra-long screenshots by A4 aspect ratio before layout (WeChat chat records), or render the whole image as a single adaptive-height page (hearing transcripts) via vertical mode.
  • PDF Repacking: Re-arrange pages of an existing PDF into a compact N-per-page layout without modifying the original file.
  • Use Case: A lawyer receives a 1080×6000 px WeChat chat screenshot as evidence; the skill splits it into A4-ratio segments and outputs a 2-page landscape A4 PDF ready for court submission.

Quick Start

Combine all screenshots in my evidence folder into a single A4 PDF with three images per page, or convert this long WeChat chat screenshot into a printable PDF.

Frequently Asked Questions about img2pdf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine multiple screenshots into one PDF?

Run the img_to_pdf.py script with --input pointing to your image directory and --output for the result. It supports JPG, PNG, and WebP files, arranging 1-4 images per A4 page with automatic orientation detection.

How to convert a long WeChat chat screenshot to PDF?

Use the --split flag with --per-page 3 to cut the long image into A4-ratio segments (width × √2 pixels each) and lay them out three per page. Alternatively, use --mode vertical to keep the whole image as one adaptive-height page.

Can I rearrange pages of an existing PDF into a compact layout?

Yes, pass a PDF file as --input and each page is treated as an image and re-arranged N per page. The original PDF is never modified; a new repacked PDF is written to the output path.

Does img2pdf support OCR or PDF text editing?

No, the skill explicitly does not perform OCR, edit PDF content, or process video files. For extracting frames from video, use a video screenshot tool first, then arrange the resulting images with this skill.

Why were my images split into too many segments?

The default split height is image width × √2, which can over-segment very tall images. The script warns when segments exceed five times the original image count; increase --split-height to produce fewer, taller segments.