From d3c54fbbde923282b7858c9c301868337ef2c059 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 29 May 2017 13:01:18 -0700 Subject: [PATCH] =?UTF-8?q?For=20=E2=80=94rotate-pages,=20rasterize=20prev?= =?UTF-8?q?iew=20at=20half=20DPI=20instead=20of=20200=20DPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures that time is not wasted on previews at higher resolution than the input as was sometimes the case --- ocrmypdf/pipeline.py | 13 +++++++------ tests/test_userunit.py | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ocrmypdf/pipeline.py b/ocrmypdf/pipeline.py index 3678da9d..6031fb67 100644 --- a/ocrmypdf/pipeline.py +++ b/ocrmypdf/pipeline.py @@ -333,13 +333,14 @@ def rasterize_preview( output_file, log, context): + pageinfo = get_pageinfo(input_file, context) + options = context.get_options() + canvas_dpi = get_canvas_square_dpi(pageinfo, options) / 2 + page_dpi = get_page_square_dpi(pageinfo, options) / 2 + ghostscript.rasterize_pdf( - input_file=input_file, - output_file=output_file, - xres=200, - yres=200, - raster_device='jpeggray', - log=log) + input_file, output_file, xres=canvas_dpi, yres=canvas_dpi, + raster_device='jpeggray', log=log, page_dpi=(page_dpi, page_dpi)) def orient_page( diff --git a/tests/test_userunit.py b/tests/test_userunit.py index c6f7313d..f60d4f2a 100644 --- a/tests/test_userunit.py +++ b/tests/test_userunit.py @@ -38,3 +38,8 @@ def test_userunit_qpdf_passes(spoof_tesseract_cache, poster, outpdf): after = PdfInfo(outpdf) assert isclose(before[0].width_inches, after[0].width_inches) + +def test_rotate_interaction(spoof_tesseract_cache, poster, outpdf): + check_ocrmypdf(poster, outpdf, '--output-type=pdf', + '--rotate-pages', + env=spoof_tesseract_cache)