diff --git a/src/__init__.py b/src/__init__.py index 61afac8ad..a0355b6da 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -9463,11 +9463,13 @@ def __init__(self, *args): pm = mupdf.fz_new_pixmap_with_bbox(cs, JM_irect_from_py(rect), mupdf.FzSeparations(0), alpha) self.this = pm - elif args_match(args, (Colorspace, mupdf.FzColorspace), (Pixmap, mupdf.FzPixmap)): + elif args_match(args, (Colorspace, mupdf.FzColorspace, type(None)), (Pixmap, mupdf.FzPixmap)): # copy pixmap, converting colorspace cs, spix = args if isinstance(cs, Colorspace): cs = cs.this + elif cs is None: + cs = mupdf.FzColorspace(None) if isinstance(spix, Pixmap): spix = spix.this if not mupdf.fz_pixmap_colorspace(spix).m_internal: @@ -17965,7 +17967,8 @@ def args_match(args, *types): Returns true if matches . Each item in is a type or tuple of types. Any of these types will - match an item in . None will match anything in . + match an item in . `None` will match anything in . `type(None)` + will match an arg whose value is `None`. ''' j = 0 for i in range(len(types)): diff --git a/tests/test_pixmap.py b/tests/test_pixmap.py index f2615158f..30dac45d3 100644 --- a/tests/test_pixmap.py +++ b/tests/test_pixmap.py @@ -245,3 +245,7 @@ def test_3134(): print(f'{stat_irect=}') assert stat_rect.st_size == stat_irect.st_size +def test_3177(): + path = os.path.abspath(f'{__file__}/../../tests/resources/img-transparent.png') + pixmap = fitz.Pixmap(path) + pixmap2 = fitz.Pixmap(None, pixmap)