From a373fcd649a1a463083744a29f6f20d1c68e5ed7 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 8 Dec 2025 15:32:39 -0800 Subject: [PATCH] fix: add jobs fallback in pipeline common Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) --- src/ocrmypdf/_pipelines/_common.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ocrmypdf/_pipelines/_common.py b/src/ocrmypdf/_pipelines/_common.py index e5ba9725..d3c219e0 100644 --- a/src/ocrmypdf/_pipelines/_common.py +++ b/src/ocrmypdf/_pipelines/_common.py @@ -20,6 +20,7 @@ from pathlib import Path from typing import NamedTuple, cast import PIL +import PIL.Image from pikepdf import Pdf from ocrmypdf._annots import remove_broken_goto_annotations @@ -307,6 +308,11 @@ def setup_pipeline( if not options.jobs: options.jobs = available_cpu_count() + # Apply PIL max image pixels side effect + PIL.Image.MAX_IMAGE_PIXELS = int(options.max_image_mpixels * 1_000_000) + if PIL.Image.MAX_IMAGE_PIXELS == 0: + PIL.Image.MAX_IMAGE_PIXELS = None # type: ignore + pikepdf_enable_mmap() executor = setup_executor(plugin_manager) return executor