From b06ef03aac29588e2526f487e260425289a03762 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 17 May 2018 16:51:53 -0700 Subject: [PATCH] pipeline: use the resolution of the OCR image rather than recalculating (Recalculating would fail if the image is not centered.) --- src/ocrmypdf/pipeline.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ocrmypdf/pipeline.py b/src/ocrmypdf/pipeline.py index 75fb08c4..bf947154 100644 --- a/src/ocrmypdf/pipeline.py +++ b/src/ocrmypdf/pipeline.py @@ -540,14 +540,13 @@ def select_ocr_image( white = ImageColor.getcolor('#ffffff', im.mode) draw = ImageDraw.ImageDraw(im) - xres = im.width / pageinfo.width_inches - yres = im.height / pageinfo.height_inches + xres, yres = im.info['dpi'] for textarea in pageinfo.get_textareas(): # Calculate resolution based on the image size and page dimensions # without regard whatever resolution is in pageinfo (may differ or # be None) bbox = textarea['bbox'] - log.debug('calculated resolution %r %r', xres, yres) + log.debug('resolution %r %r', xres, yres) pixcoords = [Decimal(bbox[0]) / Decimal(72) * xres, Decimal(bbox[1]) / Decimal(72) * yres,