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

Function ocr_page

scripts/extract_pdf_assets.py:248–255  ·  view source on GitHub ↗
(page, dpi: int)

Source from the content-addressed store, hash-verified

246
247
248def ocr_page(page, dpi: int) -> str:
249 if fitz is None or pytesseract is None or Image is None:
250 return ""
251 scale = dpi / 72.0
252 matrix = fitz.Matrix(scale, scale)
253 pix = page.get_pixmap(matrix=matrix, alpha=False)
254 image = Image.open(io.BytesIO(pix.tobytes("png")))
255 return normalize_whitespace(pytesseract.image_to_string(image))
256
257
258def extract_page_images(doc, page, page_number: int, images_dir: Path) -> list[dict]:

Callers 1

mainFunction · 0.85

Calls 2

normalize_whitespaceFunction · 0.90
openMethod · 0.45

Tested by

no test coverage detected