From 2a52c6dec2ea58a7ba0a108b5dd60b14691c8d7b Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 14 Feb 2021 01:35:33 -0800 Subject: [PATCH] optimize: skip images with unusually small dimensions They're unlikely to be handled well by our recompressors. It seems that JBIG2 cannot handle very small widths. Fixes #732 --- src/ocrmypdf/optimize.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ocrmypdf/optimize.py b/src/ocrmypdf/optimize.py index 3fa92355..05057d5c 100644 --- a/src/ocrmypdf/optimize.py +++ b/src/ocrmypdf/optimize.py @@ -76,6 +76,9 @@ def extract_image_filter( if image.Length < 100: log.debug(f"Skipping small image, xref {xref}") return None + if image.Width < 8 or image.Height < 8: # Issue 732 + log.debug(f"Skipping oddly sized image, xref {xref}") + return None pim = PdfImage(image)