How to use the ocrmypdf.leptonica.Pix function in ocrmypdf

To help you get started, we’ve selected a few ocrmypdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jbarlow83 / OCRmyPDF / tests / test_rotation.py View on Github external
def test_tesseract_orientation(resources, tmp_path):
    pix = leptonica.Pix.open(resources / 'crom.png')
    pix_rotated = pix.rotate_orth(2)  # 180 degrees clockwise
    pix_rotated.write_implied_format(tmp_path / '000001.png')

    log = logging.getLogger()
    tesseract.get_orientation(  # Test results of this are unreliable
        tmp_path / '000001.png', engine_mode='3', timeout=10, log=log
    )
github jbarlow83 / OCRmyPDF / tests / test_rotation.py View on Github external
return
        ghostscript.rasterize_pdf(
            pdf,
            png,
            xres=100,
            yres=100,
            raster_device='pngmono',
            log=gslog,
            pageno=pageno,
            rotation=0,
        )

    rasterize(reference_pdf, reference_pageno, reference_png)
    rasterize(test_pdf, test_pageno, test_png)

    pix_ref = leptonica.Pix.open(reference_png)
    pix_test = leptonica.Pix.open(test_png)

    return leptonica.Pix.correlation_binary(pix_ref, pix_test)
github jbarlow83 / OCRmyPDF / tests / test_lept.py View on Github external
def crom_pix(resources):
    pix = lept.Pix.open(resources / 'crom.png')
    im = Image.open(resources / 'crom.png')
    yield pix, im
    im.close()