summaryrefslogtreecommitdiff
path: root/app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch
diff options
context:
space:
mode:
Diffstat (limited to 'app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch')
-rw-r--r--app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch b/app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch
new file mode 100644
index 0000000..e46ae04
--- /dev/null
+++ b/app-text/OCRmyPDF/files/OCRmyPDF-16.4.3-mask.patch
@@ -0,0 +1,29 @@
+From b3324c3b4e8052176f5ec86eda1ea726894fd510 Mon Sep 17 00:00:00 2001
+From: "James R. Barlow" <james@purplerock.ca>
+Date: Sat, 31 Aug 2024 00:37:52 -0700
+Subject: [PATCH] Don't assume /Mask is always a Stream
+
+Fixes #1377
+---
+ src/ocrmypdf/pdfinfo/info.py | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/ocrmypdf/pdfinfo/info.py b/src/ocrmypdf/pdfinfo/info.py
+index 7c946906b..953af9cd5 100644
+--- a/src/ocrmypdf/pdfinfo/info.py
++++ b/src/ocrmypdf/pdfinfo/info.py
+@@ -382,8 +382,12 @@ def __init__(
+ self._height = max(smask.get(Name.Height, 0), self._height)
+ if (mask := pim.obj.get(Name.Mask, None)) is not None:
+ # If the image has a /Mask entry, it has an explicit mask.
+- self._width = max(mask.get(Name.Width, 0), self._width)
+- self._height = max(mask.get(Name.Height, 0), self._height)
++ # /Mask can be a Stream or an Array. If it's a Stream,
++ # use its /Width and /Height if they are larger than the main
++ # image's.
++ if isinstance(mask, Stream):
++ self._width = max(mask.get(Name.Width, 0), self._width)
++ self._height = max(mask.get(Name.Height, 0), self._height)
+
+ # If /ImageMask is true, then this image is a stencil mask
+ # (Images that draw with this stencil mask will have a reference to