pdf2img
Convert every page of a PDF into individual PNG images.
Workflow
Derive the output directory from the PDF file stem:
pdf_path = ~/Downloads/6660-SPS.pdf stem = 6660-SPS output_dir = <ARTIFACTS_DIR>/6660-SPS/Run the bundled script via
execute_codeorbash:python skills/pdf2img/scripts/pdf2img.py "<pdf_path>" "<output_dir>"The script auto-installs
pymupdfif it is missing.Report results – list the saved image paths and total page count to the user.
Script
scripts/pdf2img.py — accepts two positional arguments:
| Argument | Description |
|---|---|
pdf_path |
Path to the source PDF (supports ~) |
output_dir |
Destination folder (created if absent) |
Default resolution is 150 DPI (clear enough for most documents).
Images are named page_001.png, page_002.png, … in order.
Dependencies
pymupdf(fitz) — auto-installed by the script if missing.
Example
User says: "~/Downloads/6660-SPS.pdf 파일을 이미지로 변환해줘"
import subprocess, sys
script = "skills/pdf2img/scripts/pdf2img.py"
pdf = os.path.expanduser("~/Downloads/6660-SPS.pdf")
outdir = os.path.join(ARTIFACTS_DIR, "6660-SPS")
subprocess.run([sys.executable, script, pdf, outdir], check=True)