MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / full_ocr

Function full_ocr

src/utils.py:336–355  ·  view source on GitHub ↗
(page, dpi, language, flags)

Source from the content-addressed store, hash-verified

334 tessdata = pymupdf.get_tessdata(tessdata)
335
336 def full_ocr(page, dpi, language, flags):
337 zoom = dpi / 72
338 mat = pymupdf.Matrix(zoom, zoom)
339 pix = page.get_pixmap(matrix=mat)
340 ocr_pdf = pymupdf.Document(
341 "pdf",
342 pix.pdfocr_tobytes(
343 compress=False,
344 language=language,
345 tessdata=tessdata,
346 ),
347 )
348 ocr_page = ocr_pdf.load_page(0)
349 unzoom = page.rect.width / ocr_page.rect.width
350 ctm = pymupdf.Matrix(unzoom, unzoom) * page.derotation_matrix
351 tpage = ocr_page.get_textpage(flags=flags, matrix=ctm)
352 ocr_pdf.close()
353 pix = None
354 tpage.parent = weakref.proxy(page)
355 return tpage
356
357 # if OCR for the full page, OCR its pixmap @ desired dpi
358 if full:

Callers 1

get_textpage_ocrFunction · 0.70

Calls 5

load_pageMethod · 0.95
closeMethod · 0.95
pdfocr_tobytesMethod · 0.80
get_pixmapMethod · 0.45
get_textpageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…