From c096b4ca8cac00436448976e0c2630f01497d590 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 4 Nov 2016 02:23:02 -0700 Subject: [PATCH] Make debug dump of pageinfo at the end of processing readable --- ocrmypdf/__main__.py | 5 ++++- ocrmypdf/pageinfo.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index b8302631..07b943c5 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -1529,7 +1529,10 @@ def run_pipeline(): _log.info("Output sent to stdout") with _pdfinfo_lock: - _log.debug(_pdfinfo) + if options.verbose: + from pprint import pformat + referent = _pdfinfo._getvalue() # get the real list out of proxy + _log.debug(pformat(referent)) direction = {0: 'n', 90: 'e', 180: 's', 270: 'w'} orientations = [] diff --git a/ocrmypdf/pageinfo.py b/ocrmypdf/pageinfo.py index 216562a5..9470f37c 100644 --- a/ocrmypdf/pageinfo.py +++ b/ocrmypdf/pageinfo.py @@ -326,9 +326,11 @@ def _find_page_regular_images(page, pageinfo, contentsinfo): image['dpi_w'] = max(dpi_w, image.get('dpi_w', 0)) image['dpi_h'] = max(dpi_h, image.get('dpi_h', 0)) - image['dpi_w'] = Decimal(image['dpi_w']) - image['dpi_h'] = Decimal(image['dpi_h']) - image['dpi'] = (image['dpi_w'] * image['dpi_h']) ** Decimal(0.5) + DPI_PREC = Decimal('1.000') + image['dpi_w'] = Decimal(image['dpi_w']).quantize(DPI_PREC) + image['dpi_h'] = Decimal(image['dpi_h']).quantize(DPI_PREC) + dpi = Decimal(image['dpi_w'] * image['dpi_h']).sqrt() + image['dpi'] = dpi.quantize(DPI_PREC) yield image