1
0
Fork 0
forked from josch/plakativ

allow operation with pymupdf before 1.14.5 when the getImageData() function didn't exist yet (closes: #4)

This commit is contained in:
Johannes 'josch' Schauer 2020-06-10 00:06:48 +02:00
parent 070947570d
commit 3cfdb1564a
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -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,