pymupdf
Use scripts/pymupdf_cli.py for deterministic pymupdf operations instead of ad-hoc fitz snippets.
Workflow
- 1. Confirm the PDF file path is accessible locally.
- Run the desired command (export-images, extract-images, info).
- Inspect the output directory or stdout.
Command Guide
- - Export pages as images:
-
python scripts/pymupdf_cli.py export-images --input <file.pdf> --output-dir <dir/>
- Override format:
--format png (default),
jpg, or
ppm.
- Override resolution:
--dpi 300 (default: 150).
- Restrict to specific pages:
--pages 0 1 2.
- - Extract images embedded inside a PDF:
-
python scripts/pymupdf_cli.py extract-images --input <file.pdf> --output-dir <dir/>
- Optionally restrict to specific pages:
--pages 0 1 2.
- - Inspect page dimensions and basic document info:
- INLINECODE9
Operational Rules
- - Pages are always 0-indexed in all commands.
- INLINECODE10 renders each page as a raster image at the specified DPI.
- INLINECODE11 saves raw image streams embedded in the PDF (e.g. photos, logos); output filenames include page index and image index.
- Install dependency if missing:
pip install pymupdf. - For text extraction, splitting, merging, or rotating PDFs, use the pypdf skill instead.
pymupdf
使用 scripts/pymupdf_cli.py 执行确定性的 pymupdf 操作,而非临时编写 fitz 代码片段。
工作流程
- 1. 确认 PDF 文件路径在本地可访问。
- 运行所需命令(export-images、extract-images、info)。
- 检查输出目录或标准输出。
命令指南
- python scripts/pymupdf_cli.py export-images --input <文件.pdf> --output-dir <目录/>
- 覆盖格式:--format png(默认)、jpg 或 ppm。
- 覆盖分辨率:--dpi 300(默认:150)。
- 限制特定页面:--pages 0 1 2。
- python scripts/pymupdf_cli.py extract-images --input <文件.pdf> --output-dir <目录/>
- 可选择限制特定页面:--pages 0 1 2。
- python scripts/pymupdf_cli.py info --input <文件.pdf>
操作规则
- - 所有命令中的页面索引均从 0 开始。
- export-images 将每个页面以指定 DPI 渲染为光栅图像。
- extract-images 保存 PDF 中嵌入的原始图像流(如照片、徽标);输出文件名包含页面索引和图像索引。
- 若缺少依赖,请安装:pip install pymupdf。
- 如需提取文本、拆分、合并或旋转 PDF,请改用 pypdf 技能。