MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / Pixmap

Class Pixmap

src/__init__.py:13236–14119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13234
13235
13236class Pixmap:
13237
13238 def __init__(self, *args):
13239 """
13240 Pixmap(colorspace, irect, alpha) - empty pixmap.
13241 Pixmap(colorspace, src) - copy changing colorspace.
13242 Pixmap(src, width, height,[clip]) - scaled copy, float dimensions.
13243 Pixmap(src, alpha=1) - copy and add or drop alpha channel.
13244 Pixmap(filename) - from an image in a file.
13245 Pixmap(image) - from an image in memory (bytes).
13246 Pixmap(colorspace, width, height, samples, alpha) - from samples data.
13247 Pixmap(PDFdoc, xref) - from an image at xref in a PDF document.
13248 """
13249 # Cache for property `self.samples_mv`. Set here so __del_() sees it if
13250 # we raise.
13251 #
13252 self._samples_mv = None
13253
13254 # 2024-01-16: Experimental support for a memory-view of the underlying
13255 # data. Doesn't seem to make much difference to Pixmap.set_pixel() so
13256 # not currently used.
13257 self._memory_view = None
13258
13259 if 0:
13260 pass
13261
13262 elif args_match(args,
13263 (Colorspace, mupdf.FzColorspace),
13264 (mupdf.FzRect, mupdf.FzIrect, IRect, Rect, tuple)
13265 ):
13266 # create empty pixmap with colorspace and IRect
13267 cs, rect = args
13268 alpha = 0
13269 pm = mupdf.fz_new_pixmap_with_bbox(cs, JM_irect_from_py(rect), mupdf.FzSeparations(0), alpha)
13270 self.this = pm
13271
13272 elif args_match(args,
13273 (Colorspace, mupdf.FzColorspace),
13274 (mupdf.FzRect, mupdf.FzIrect, IRect, Rect, tuple),
13275 (int, bool)
13276 ):
13277 # create empty pixmap with colorspace and IRect
13278 cs, rect, alpha = args
13279 pm = mupdf.fz_new_pixmap_with_bbox(cs, JM_irect_from_py(rect), mupdf.FzSeparations(0), alpha)
13280 self.this = pm
13281
13282 elif args_match(args, (Colorspace, mupdf.FzColorspace, type(None)), (Pixmap, mupdf.FzPixmap)):
13283 # copy pixmap, converting colorspace
13284 cs, spix = args
13285 if isinstance(cs, Colorspace):
13286 cs = cs.this
13287 elif cs is None:
13288 cs = mupdf.FzColorspace(None)
13289 if isinstance(spix, Pixmap):
13290 spix = spix.this
13291 if not mupdf.fz_pixmap_colorspace(spix).m_internal:
13292 raise ValueError( "source colorspace must not be None")
13293

Callers 12

get_pixmapMethod · 0.85
insert_fileMethod · 0.85
_makePixmapMethod · 0.85
delete_imageMethod · 0.85
get_image_infoMethod · 0.85
get_image_rectsMethod · 0.85
warpMethod · 0.85
get_textpage_ocrFunction · 0.85
get_image_infoFunction · 0.85
get_image_rectsFunction · 0.85
test_2173Function · 0.85

Calls

no outgoing calls

Tested by 1

test_2173Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…