Files
KeyInfo Bot 36c089fee9 Sync third-party and MCP marketplace plugins
Constraint: Public skills are published only by explicit administrator action unless they are tracked third-party market sources.
Confidence: high
Scope-risk: narrow
Directive: Keep private/internal skills out of the public marketplace and preserve normal incremental market Git history.
Tested: Marketplace validation passed.
2026-10-06 15:29:22 +08:00

30 lines
990 B
Python

"""Render PDF pages without Poppler; requires PyMuPDF."""
import argparse
from pathlib import Path
import pymupdf
def convert(pdf_path, output_dir, max_dim=1600):
if max_dim <= 0:
raise ValueError("max_dim must be positive")
output = Path(output_dir)
output.mkdir(parents=True, exist_ok=True)
with pymupdf.open(pdf_path) as document:
for index, page in enumerate(document):
scale = min(max_dim / page.rect.width, max_dim / page.rect.height)
pixmap = page.get_pixmap(matrix=pymupdf.Matrix(scale, scale), alpha=False)
target = output / f"page_{index + 1}.png"
pixmap.save(str(target))
print(target)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("input")
parser.add_argument("output")
parser.add_argument("--max-dim", type=int, default=1600)
args = parser.parse_args()
convert(args.input, args.output, args.max_dim)