MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / _render_crop

Function _render_crop

scripts/extract_pdf_assets.py:1046–1052  ·  view source on GitHub ↗

Render a page region to PNG bytes at the given DPI.

(page, bbox: tuple[float, float, float, float], dpi: int)

Source from the content-addressed store, hash-verified

1044
1045
1046def _render_crop(page, bbox: tuple[float, float, float, float], dpi: int) -> bytes:
1047 """Render a page region to PNG bytes at the given DPI."""
1048 clip = fitz.Rect(*bbox)
1049 scale = dpi / 72.0
1050 matrix = fitz.Matrix(scale, scale)
1051 pix = page.get_pixmap(matrix=matrix, clip=clip, alpha=False)
1052 return pix.tobytes("png")
1053
1054
1055def _unique_figure_asset_filename(page_number: int, label: str, used_filenames: set[str]) -> str:

Callers 1

extract_figure_regionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected