MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / get_pixmap

Method get_pixmap

src/__init__.py:11816–11857  ·  view source on GitHub ↗

Create pixmap of page. Keyword args: matrix: Matrix for transformation (default: Identity). dpi: desired dots per inch. If given, matrix is ignored. colorspace: (str/Colorspace) cmyk, rgb, gray - case ignored, default csRGB. clip: (irect-like)

(
                page: 'Page',
                *,
                matrix: matrix_like=Identity,
                dpi=None,
                colorspace: Colorspace=None,
                clip: rect_like=None,
                alpha: bool=False,
                annots: bool=True,
                )

Source from the content-addressed store, hash-verified

11814 return links
11815
11816 def get_pixmap(
11817 page: 'Page',
11818 *,
11819 matrix: matrix_like=Identity,
11820 dpi=None,
11821 colorspace: Colorspace=None,
11822 clip: rect_like=None,
11823 alpha: bool=False,
11824 annots: bool=True,
11825 ) -> 'Pixmap':
11826 """Create pixmap of page.
11827
11828 Keyword args:
11829 matrix: Matrix for transformation (default: Identity).
11830 dpi: desired dots per inch. If given, matrix is ignored.
11831 colorspace: (str/Colorspace) cmyk, rgb, gray - case ignored, default csRGB.
11832 clip: (irect-like) restrict rendering to this area.
11833 alpha: (bool) whether to include alpha channel
11834 annots: (bool) whether to also render annotations
11835 """
11836 if colorspace is None:
11837 colorspace = csRGB
11838 if dpi:
11839 zoom = dpi / 72
11840 matrix = Matrix(zoom, zoom)
11841
11842 if type(colorspace) is str:
11843 if colorspace.upper() == "GRAY":
11844 colorspace = csGRAY
11845 elif colorspace.upper() == "CMYK":
11846 colorspace = csCMYK
11847 else:
11848 colorspace = csRGB
11849 if colorspace.n not in (1, 3, 4):
11850 raise ValueError("unsupported colorspace")
11851
11852 dl = page.get_displaylist(annots=annots)
11853 pix = dl.get_pixmap(matrix=matrix, colorspace=colorspace, alpha=alpha, clip=clip)
11854 dl = None
11855 if dpi:
11856 pix.set_dpi(dpi, dpi)
11857 return pix
11858
11859 def remove_rotation(self):
11860 """Set page rotation to 0 while maintaining visual appearance."""

Callers 15

full_ocrFunction · 0.45
get_page_pixmapMethod · 0.45
top_row_bg_colorMethod · 0.45
full_ocrFunction · 0.45
get_pixmapFunction · 0.45
get_page_pixmapFunction · 0.45
test_remove_rotationFunction · 0.45
test_compressFunction · 0.45
test_707727Function · 0.45
test_pagepixmapFunction · 0.45
test_3050Function · 0.45
test_3072Function · 0.45

Calls 3

MatrixClass · 0.85
get_displaylistMethod · 0.80
set_dpiMethod · 0.80

Tested by 15

test_remove_rotationFunction · 0.36
test_compressFunction · 0.36
test_707727Function · 0.36
test_pagepixmapFunction · 0.36
test_3050Function · 0.36
test_3072Function · 0.36
test_3134Function · 0.36
test_3848Function · 0.36
test_3994Function · 0.36
test_3448Function · 0.36
test_3854Function · 0.36
test_4155Function · 0.36