From a650caa599600208f6655697f09eb40ac1c508ce Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 3 Sep 2019 23:47:20 -0700 Subject: [PATCH] optimize: don't consider 1bpp images for PNG optimization --- src/ocrmypdf/optimize.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py index 5358bd17..e4b4e208 100644 --- a/src/ocrmypdf/optimize.py +++ b/src/ocrmypdf/optimize.py @@ -107,6 +107,10 @@ def extract_image_generic(*, pike, root, log, image, xref, options): return None pim, filtdp = result + # Don't try to PNG-optimize 1bpp images, since JBIG2 does it better. + if pim.bits_per_component == 1: + return None + if filtdp[0] == Name.DCTDecode and options.optimize >= 2: # This is a simple heuristic derived from some training data, that has # about a 70% chance of guessing whether the JPEG is high quality,