MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _render_page_to_numpy

Function _render_page_to_numpy

skills/pdf-parser/scripts/parse_pdf.py:246–257  ·  view source on GitHub ↗
(page: Any)

Source from the content-addressed store, hash-verified

244
245
246def _render_page_to_numpy(page: Any):
247 if not HAS_NUMPY:
248 return None
249
250 scale = max(1.0, float(PDF_PARSER_OCR_DPI) / 72.0)
251 pix = page.get_pixmap(matrix=fitz.Matrix(scale, scale), alpha=False)
252 channels = max(1, int(pix.n))
253 try:
254 image = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.height, pix.width, channels)
255 except Exception:
256 return None
257 return image
258
259
260def _ocr_page_with_rapidocr(page: Any) -> str:

Callers 1

_ocr_page_with_rapidocrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected