From 3cfdb1564a2b28d30a33fdce246cb86a7f386baf Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Wed, 10 Jun 2020 00:06:48 +0200 Subject: [PATCH] allow operation with pymupdf before 1.14.5 when the getImageData() function didn't exist yet (closes: #4) --- plakativ.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plakativ.py b/plakativ.py index 77e39b9..cf95497 100755 --- a/plakativ.py +++ b/plakativ.py @@ -270,7 +270,13 @@ class Plakativ: pix = ( self.doc[self.pagenr].getDisplayList().getPixmap(matrix=mat_0, alpha=False) ) - return pix.getImageData("ppm") + # the getImageData() function was only introduced in pymupdf 1.14.5 + if hasattr(pix, "getImageData"): + return pix.getImageData("ppm") + else: + # this is essentially the same thing that the getImageData() + # function does + return pix._getImageData(2) # 2 stands for pgm/ppm/pbm def compute_layout( self,