(page: Any)
| 244 | |
| 245 | |
| 246 | def _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 | |
| 260 | def _ocr_page_with_rapidocr(page: Any) -> str: |
no outgoing calls
no test coverage detected