From 642998ead6a2f54894fca0c795951c3cabe4e6bb Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 15 Jun 2020 15:26:41 -0700 Subject: [PATCH] sync: refactor preprocess image filtering --- src/ocrmypdf/_sync.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ocrmypdf/_sync.py b/src/ocrmypdf/_sync.py index b55ace4f..6c730025 100644 --- a/src/ocrmypdf/_sync.py +++ b/src/ocrmypdf/_sync.py @@ -196,15 +196,15 @@ def exec_page_sync(page_context: PageContext): pdf_page_from_image_out = None if not options.lossless_reconstruction: + assert preprocess_out visible_image_out = preprocess_out if should_visible_page_image_use_jpg(page_context.pageinfo): visible_image_out = create_visible_page_jpg(visible_image_out, page_context) - visible_image_out = ( - page_context.plugin_manager.hook.filter_page_image( - page=page_context, image_filename=Path(visible_image_out) - ) - or visible_image_out + filtered_image = page_context.plugin_manager.hook.filter_page_image( + page=page_context, image_filename=visible_image_out ) + if filtered_image: + visible_image_out = filtered_image pdf_page_from_image_out = create_pdf_page_from_image( visible_image_out, page_context )