
Lovstudio:Pdf2png
- 1 installs
- Updated May 7, 2026
- lovstudio/pdf2png-skill
Converts a multi-page PDF into a single tall PNG image on macOS using native CoreGraphics at 2x scale.
About
Converts a multi-page PDF into a single vertically concatenated PNG using macOS CoreGraphics. A developer uses it to turn a PDF into one long screenshot-style image for sharing on WeChat or social media.
- Renders each PDF page at 2x scale and stitches them into one tall PNG
- Uses macOS CoreGraphics, no pdftoppm/ImageMagick/Ghostscript needed
Lovstudio:Pdf2png by the numbers
- 1 all-time installs (skills.sh)
- Ranked #565 of 688 Office & Documents skills by installs in the Skillselion catalog
- Data as of Jul 8, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lovstudio/pdf2png-skill --skill lovstudiopdf2pngAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| Last updated | May 7, 2026 |
| Repository | lovstudio/pdf2png-skill ↗ |
What it does
Converts a multi-page PDF into a single tall PNG image on macOS using native CoreGraphics at 2x scale.
Files
pdf2png — PDF to Vertically Concatenated PNG
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. Confirm the path(s).
Step 2: Execute
bash lovstudio-pdf2png/scripts/pdf2png.sh /path/to/file.pdfOutput: /path/to/file.png (same directory, same name, .png extension).
For multiple files:
bash lovstudio-pdf2png/scripts/pdf2png.sh file1.pdf file2.pdf file3.pdfStep 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 lovstudio/mac-pdf2png for the Automator workflow.
Dependencies
pip install pyobjc-framework-Quartz --break-system-packages/Users/mark/projects/lovstudio-skills/skills/lovstudio-pdf2pnglovstudio:pdf2png
Convert PDF files to a single vertically concatenated PNG image using macOS native CoreGraphics.
Part of lovstudio/skills — by lovstudio.ai
Install
npx skills add lovstudio/skills --skill lovstudio:pdf2pngRequires: macOS, pip install pyobjc-framework-Quartz
Usage
bash pdf2png.sh input.pdf # → input.png
bash pdf2png.sh a.pdf b.pdf c.pdf # batch modeHow 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 lovstudio/mac-pdf2png.
License
MIT
#!/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