From aad90bcb54b953eb557e789aa7caf2d58ca6146a Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 8 Dec 2025 23:22:55 -0800 Subject: [PATCH] fix: compute lossless_reconstruction when not present in options Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) --- src/ocrmypdf/_jobcontext.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/_jobcontext.py b/src/ocrmypdf/_jobcontext.py index 6523ada5..bb7c8fc1 100644 --- a/src/ocrmypdf/_jobcontext.py +++ b/src/ocrmypdf/_jobcontext.py @@ -122,7 +122,17 @@ class PageContext: setattr(clean_options, key, value) except TypeError: continue - clean_options.lossless_reconstruction = self.options.lossless_reconstruction + # Set lossless_reconstruction if it exists, otherwise compute it + if hasattr(self.options, 'lossless_reconstruction'): + clean_options.lossless_reconstruction = self.options.lossless_reconstruction + else: + # Compute lossless_reconstruction for Namespace objects + clean_options.lossless_reconstruction = not any([ + getattr(self.options, 'deskew', False), + getattr(self.options, 'clean_final', False), + getattr(self.options, 'force_ocr', False), + getattr(self.options, 'remove_background', False), + ]) state['options'] = clean_options # Handle stream inputs