From 178aee4687243cdfaf24f75b13f3edbc7bfdc34b Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 7 Feb 2016 15:43:45 -0800 Subject: [PATCH] Make rotation optional (for now it's off, possibly should be on) --- ocrmypdf/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index a4d6ea7c..df99a0fc 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -140,6 +140,9 @@ metadata.add_argument( preprocessing = parser.add_argument_group( "Preprocessing options", "Improve OCR quality and final image") +preprocessing.add_argument( + '-r', '--rotate-pages', action='store_true', + help="automatically rotate pages based on detected text orientation") preprocessing.add_argument( '-d', '--deskew', action='store_true', help="deskew each page before performing OCR") @@ -442,6 +445,7 @@ def split_pages( os.path.basename(filename)[0:6] + alt_suffix)) +@active_if(options.rotate_pages) @transform( input=split_pages, filter=suffix('.page.pdf'), @@ -476,6 +480,10 @@ def orient_page( pdfinfo_lock): page_pdf = next(ii for ii in infiles if ii.endswith('.page.pdf')) + + if not options.rotate_pages: + re_symlink(page_pdf, output_file) + return preview = next(ii for ii in infiles if ii.endswith('.preview.png')) orient_conf = tesseract.get_orientation(