lov-pdf2png
Convert PDF files to a single vertically concatenated PNG image using macOS native CoreGraphics. Each page is rendered at 2x scale and stitched top-to-bottom. ~20x faster than pdftoppm+ImageMagick, zero external dependencies on macOS. Trigger when the user mentions "pdf to png",
Install
npx skills add https://github.com/lovstudio/skills/tree/main/skills/pdf2png
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lovstudio-skills@llmmart
git clone https://github.com/lovstudio/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lovstudio/skills collection as a plugin from our marketplace. Git is the plain clone.
README
PDF 长图 · PDF Scroll
Convert PDF files to a single vertically concatenated PNG image using macOS native CoreGraphics.
Part of skill-publisher/skills — by example.com
Install
npx skills add pdf2png -g -y
Requires: macOS, pip install pyobjc-framework-Quartz
Usage
bash pdf2png.sh input.pdf # → input.png
bash pdf2png.sh a.pdf b.pdf c.pdf # batch mode
How It Works
┌─────────┐ CoreGraphics ┌─────────┐
│ PDF │ ──── render ────► │ Page 1 │
│ (N pages)│ 2x scale │ Page 2 │
│ │ │ ... │
│ │ │ Page N │
└─────────┘ └────┬─────┘
│ vertical append
▼
┌─────────┐
│ one.png │
└─────────┘
Why Not pdftoppm + ImageMagick?
| pdftoppm + magick | CoreGraphics | |
|---|---|---|
| 27MB / 20 pages | ~3 minutes | ~3 seconds |
| Dependencies | Homebrew (poppler, imagemagick) | None (macOS built-in) |
| Retina quality | Manual DPI flag | Native 2x scale |
Also Available As
- Finder Quick Action: Right-click any PDF → "PDF to PNG". See skill-publisher/mac-pdf2png.
License
MIT
Skill manifest
PDF 长图 · PDF Scroll
Convert multi-page PDF files into a single tall PNG image. All pages are rendered at 2x scale (Retina quality) and stitched vertically. Uses macOS CoreGraphics directly — no pdftoppm, no ImageMagick, no Ghostscript.
When to Use
- User wants to convert a PDF to a single PNG image
- User needs a long screenshot-style image of a PDF
- User wants to share PDF content as an image (WeChat, social media, etc.)
Workflow
Step 1: Identify PDF files
Locate the PDF file(s) the user wants to convert. If multiple PDFs or output
location choices are ambiguous, use AskUserQuestion to confirm the path(s)
before running conversion.
Step 2: Execute
bash lov-pdf2png/scripts/pdf2png.sh /path/to/file.pdf
Output: /path/to/file.png (same directory, same name, .png extension).
For multiple files:
bash lov-pdf2png/scripts/pdf2png.sh file1.pdf file2.pdf file3.pdf
Step 3: Verify
Check the output file exists and report its size.
CLI Reference
| Argument | Description |
|---|---|
file1.pdf [file2.pdf ...] |
One or more PDF files to convert |
Output is always <input>.png in the same directory as the input file.
Finder Quick Action
This skill can also be installed as a macOS Finder Quick Action for right-click conversion. See skill-publisher/mac-pdf2png for the Automator workflow.
Dependencies
pip install pyobjc-framework-Quartz --break-system-packages
Runtime context (shared)
运行前读取本 Skill 包的 skill.yaml,由宿主提供 skill-runtime/v1 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
- 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。
required: true字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。- 报错提供可复制的
context_id、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。
通用反馈闭环
用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
- 先判断意见是
task-specific(仅本次)还是reusable(可跨任务复用)。 task-specific只修改当前任务,不改 Skill。reusable先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。- 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。
reusable修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。
Files (skills)
-
scripts
-
pdf2png.sh 1.9 KB
#!/bin/bash # Convert PDF to vertically concatenated PNG (using macOS native CoreGraphics) # Usage: pdf2png.sh file1.pdf [file2.pdf ...] for f in "$@"; do [[ "$f" == *.pdf ]] || continue output="${f%.pdf}.png" /usr/bin/python3 - "$f" "$output" <<'PYEOF' import sys from Quartz import (CGPDFDocumentCreateWithURL, CGPDFDocumentGetNumberOfPages, CGPDFDocumentGetPage, CGPDFPageGetBoxRect, kCGPDFMediaBox, CGColorSpaceCreateDeviceRGB, CGBitmapContextCreate, kCGImageAlphaPremultipliedLast, CGContextDrawPDFPage, CGContextScaleCTM, CGBitmapContextCreateImage, CGContextDrawImage, CGRectMake) from CoreFoundation import CFURLCreateWithFileSystemPath, kCFURLPOSIXPathStyle from AppKit import NSBitmapImageRep, NSPNGFileType url = CFURLCreateWithFileSystemPath(None, sys.argv[1], kCFURLPOSIXPathStyle, False) doc = CGPDFDocumentCreateWithURL(url) n = CGPDFDocumentGetNumberOfPages(doc) scale = 2.0 images, total_h, max_w = [], 0, 0 for i in range(1, n + 1): page = CGPDFDocumentGetPage(doc, i) r = CGPDFPageGetBoxRect(page, kCGPDFMediaBox) w, h = int(r.size.width * scale), int(r.size.height * scale) cs = CGColorSpaceCreateDeviceRGB() ctx = CGBitmapContextCreate(None, w, h, 8, 4 * w, cs, kCGImageAlphaPremultipliedLast) CGContextScaleCTM(ctx, scale, scale) CGContextDrawPDFPage(ctx, page) images.append((CGBitmapContextCreateImage(ctx), w, h)) total_h += h max_w = max(max_w, w) cs = CGColorSpaceCreateDeviceRGB() ctx = CGBitmapContextCreate(None, max_w, total_h, 8, 4 * max_w, cs, kCGImageAlphaPremultipliedLast) y = total_h for img, w, h in images: y -= h CGContextDrawImage(ctx, CGRectMake(0, y, w, h), img) rep = NSBitmapImageRep.alloc().initWithCGImage_(CGBitmapContextCreateImage(ctx)) data = rep.representationUsingType_properties_(NSPNGFileType, None) data.writeToFile_atomically_(sys.argv[2], True) PYEOF echo "Created: $output" done
-
-
CHANGELOG.md 513 B
# Changelog All notable changes to this skill are documented here. Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) · Versioning: [SemVer](https://semver.org/) ## [0.2.0] - 2026-08-24 ### Added - add the shared feedback-classification and approval-invalidation gate used by every LovStudio Skill ## [0.1.2] - 2026-05-07 ### Fixed - document path confirmation before PDF conversion ## [0.1.1] - 2026-05-07 ### Fixed - add release metadata - add README version badge and changelog entry -
README.md 1.7 KB
# PDF 长图 · PDF Scroll  Convert PDF files to a single vertically concatenated PNG image using macOS native CoreGraphics. Part of [skill-publisher/skills](https://example.com/skills/skills) — by [example.com](https://example.com) ## Install ```bash npx skills add pdf2png -g -y ``` Requires: macOS, `pip install pyobjc-framework-Quartz` ## Usage ```bash bash pdf2png.sh input.pdf # → input.png bash pdf2png.sh a.pdf b.pdf c.pdf # batch mode ``` ## How It Works ``` ┌─────────┐ CoreGraphics ┌─────────┐ │ PDF │ ──── render ────► │ Page 1 │ │ (N pages)│ 2x scale │ Page 2 │ │ │ │ ... │ │ │ │ Page N │ └─────────┘ └────┬─────┘ │ vertical append ▼ ┌─────────┐ │ one.png │ └─────────┘ ``` ## Why Not pdftoppm + ImageMagick? | | pdftoppm + magick | CoreGraphics | |---|---|---| | 27MB / 20 pages | ~3 minutes | ~3 seconds | | Dependencies | Homebrew (poppler, imagemagick) | None (macOS built-in) | | Retina quality | Manual DPI flag | Native 2x scale | ## Also Available As - **Finder Quick Action**: Right-click any PDF → "PDF to PNG". See [skill-publisher/mac-pdf2png](https://example.com/skills/mac-pdf2png). ## License MIT -
SKILL.md 3.7 KB
--- name: lov-pdf2png category: Document Conversion tagline: "PDF → single vertically concatenated PNG. Uses macOS CoreGraphics, ~20x faster than pdftoppm." description: > Convert PDF files to a single vertically concatenated PNG image using macOS native CoreGraphics. Each page is rendered at 2x scale and stitched top-to-bottom. ~20x faster than pdftoppm+ImageMagick, zero external dependencies on macOS. Trigger when the user mentions "pdf to png", "pdf转png", "PDF转图片", "pdf拼接", "pdf截图", "convert pdf to image", or wants to turn a multi-page PDF into one long PNG. license: MIT compatibility: > macOS only. Requires pyobjc-framework-Quartz (`pip install pyobjc-framework-Quartz`). Uses native CoreGraphics + AppKit via Python bridge. metadata: author: contributors version: "0.2.0" tags: pdf png macos coregraphics finder-action --- # PDF 长图 · PDF Scroll Convert multi-page PDF files into a single tall PNG image. All pages are rendered at 2x scale (Retina quality) and stitched vertically. Uses macOS CoreGraphics directly — no pdftoppm, no ImageMagick, no Ghostscript. ## When to Use - User wants to convert a PDF to a single PNG image - User needs a long screenshot-style image of a PDF - User wants to share PDF content as an image (WeChat, social media, etc.) ## Workflow ### Step 1: Identify PDF files Locate the PDF file(s) the user wants to convert. If multiple PDFs or output location choices are ambiguous, use `AskUserQuestion` to confirm the path(s) before running conversion. ### Step 2: Execute ```bash bash lov-pdf2png/scripts/pdf2png.sh /path/to/file.pdf ``` Output: `/path/to/file.png` (same directory, same name, `.png` extension). For multiple files: ```bash bash lov-pdf2png/scripts/pdf2png.sh file1.pdf file2.pdf file3.pdf ``` ### Step 3: Verify Check the output file exists and report its size. ## CLI Reference | Argument | Description | |----------|-------------| | `file1.pdf [file2.pdf ...]` | One or more PDF files to convert | Output is always `<input>.png` in the same directory as the input file. ## Finder Quick Action This skill can also be installed as a macOS Finder Quick Action for right-click conversion. See [skill-publisher/mac-pdf2png](https://example.com/skills/mac-pdf2png) for the Automator workflow. ## Dependencies ```bash pip install pyobjc-framework-Quartz --break-system-packages ``` ## Runtime context (shared) 运行前读取本 Skill 包的 `skill.yaml`,由宿主提供 `skill-runtime/v1` 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。 - 只使用 Manifest 声明的字段;Profile 保存公开品牌事实,Preferences 保存个人工作偏好。 - `required: true` 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。 - 报错提供可复制的 `context_id`、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。 ## 通用反馈闭环 用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行: 1. 先判断意见是 `task-specific`(仅本次)还是 `reusable`(可跨任务复用)。 2. `task-specific` 只修改当前任务,不改 Skill。 3. `reusable` 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。 4. 完成规则更新、版本、lint 与分发核验后,再把修改应用到当前任务。 5. `reusable` 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。 -
skill.yaml 828 B
schema: skill-manifest/v1 id: lov-pdf2png version: "0.2.0" runtime: skill-runtime/v1 context: profile: fields: - path: identity.name required: true question: 如果本次输出需要品牌身份,请提供品牌名称。 - path: identity.logo required: false question: 如果需要使用品牌 Logo,请提供 Logo 地址或文件路径。 - path: brand.tone required: false question: 如果已有品牌语气或审美关键词,请提供它们。 preferences: namespace: lov_pdf2png fields: - path: user.language required: false question: 希望使用哪种语言输出? - path: user.timezone required: false question: 需要使用哪个时区处理日期和时间? interaction: ask_missing: true max_questions: 1
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.