also replace getPixmap by get_pixmap and getImageData by tobytes
This commit is contained in:
parent
c50b44a3a0
commit
8d00b730f1
1 changed files with 10 additions and 4 deletions
14
plakativ.py
14
plakativ.py
|
@ -338,12 +338,18 @@ class Plakativ:
|
||||||
mat_0 = fitz.Matrix(zoom, zoom)
|
mat_0 = fitz.Matrix(zoom, zoom)
|
||||||
# since pymupdf 1.19.0 a warning will be issued if the deprecated names are used
|
# since pymupdf 1.19.0 a warning will be issued if the deprecated names are used
|
||||||
if hasattr(self.doc[self.pagenr], "get_displaylist"):
|
if hasattr(self.doc[self.pagenr], "get_displaylist"):
|
||||||
gdl = self.doc[self.pagenr].get_displaylist
|
gdl = self.doc[self.pagenr].get_displaylist()
|
||||||
else:
|
else:
|
||||||
gdl = self.doc[self.pagenr].getDisplayList
|
gdl = self.doc[self.pagenr].getDisplayList()
|
||||||
pix = gdl().getPixmap(matrix=mat_0, alpha=False)
|
if hasattr(gdl, "get_pixmap"):
|
||||||
# the getImageData() function was only introduced in pymupdf 1.14.5
|
pix = gdl.get_pixmap(matrix=mat_0, alpha=False)
|
||||||
|
else:
|
||||||
|
pix = gdl.getPixmap(matrix=mat_0, alpha=False)
|
||||||
|
if hasattr(pix, "tobytes"):
|
||||||
|
# getImageData was deprecated in pymupdf 1.19.0
|
||||||
|
return pix.tobytes("ppm")
|
||||||
if hasattr(pix, "getImageData"):
|
if hasattr(pix, "getImageData"):
|
||||||
|
# the getImageData() function was only introduced in pymupdf 1.14.5
|
||||||
return pix.getImageData("ppm")
|
return pix.getImageData("ppm")
|
||||||
else:
|
else:
|
||||||
# this is essentially the same thing that the getImageData()
|
# this is essentially the same thing that the getImageData()
|
||||||
|
|
Loading…
Reference in a new issue