Skip to content

Commit

Permalink
Merge branch '1.21' of https://github.com/pymupdf/PyMuPDF into 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
JorjMcKie committed Nov 20, 2022
2 parents fcfed37 + 42fc8ca commit 2fee7d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion docs/document.rst
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,12 @@ For details on **embedded files** refer to Appendix 3.
'(Prices in EUR \\(USD also accepted\\). Areas are in m\\262.)'


.. method:: get_page_pixmap(pno, *args, **kwargs)
.. method:: get_page_pixmap(pno: int, *, matrix: matrix_like = Identity, dpi=None, colorspace: Colorspace = csRGB, clip: rect_like = None, alpha: bool = False, annots: bool = True)

Creates a pixmap from page *pno* (zero-based). Invokes :meth:`Page.get_pixmap`.

All parameters except ``pno`` are *keyword-only.*

:arg int pno: page number, 0-based in ``-∞ < pno < page_count``.

:rtype: :ref:`Pixmap`
Expand Down
23 changes: 13 additions & 10 deletions fitz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,16 @@ def get_page_text(
return doc[pno].get_text(option, clip=clip, flags=flags, sort=sort)


def get_pixmap(page: Page, *args, **kw) -> Pixmap:
def get_pixmap(
page: Page,
*,
matrix: matrix_like=Identity,
dpi=None,
colorspace: Colorspace=csRGB,
clip: rect_like=None,
alpha: bool=False,
annots: bool=True,
) -> Pixmap:
"""Create pixmap of page.
Keyword args:
Expand All @@ -820,18 +829,10 @@ def get_pixmap(page: Page, *args, **kw) -> Pixmap:
alpha: (bool) whether to include alpha channel
annots: (bool) whether to also render annotations
"""
if args:
raise ValueError("method accepts keywords only")
CheckParent(page)
matrix = kw.get("matrix", Identity)
dpi = kw.get("dpi", None)
if dpi:
zoom = dpi / 72
matrix = Matrix(zoom, zoom)
colorspace = kw.get("colorspace", csRGB)
clip = kw.get("clip")
alpha = bool(kw.get("alpha", False))
annots = bool(kw.get("annots", True))

if type(colorspace) is str:
if colorspace.upper() == "GRAY":
Expand All @@ -854,7 +855,9 @@ def get_pixmap(page: Page, *args, **kw) -> Pixmap:
def get_page_pixmap(
doc: Document,
pno: int,
*,
matrix: matrix_like = Identity,
dpi=None,
colorspace: Colorspace = csRGB,
clip: rect_like = None,
alpha: bool = False,
Expand All @@ -873,7 +876,7 @@ def get_page_pixmap(
annots: (bool) also render annotations
"""
return doc[pno].get_pixmap(
matrix=matrix, colorspace=colorspace, clip=clip, alpha=alpha, annots=annots
matrix=matrix, dpi=dpi, colorspace=colorspace, clip=clip, alpha=alpha, annots=annots
)


Expand Down

0 comments on commit 2fee7d8

Please sign in to comment.