Mercurial > hgrepos > Python2 > PyMuPDF
diff tests/test_imagemasks.py @ 1:1d09e1dec1d9 upstream
ADD: PyMuPDF v1.26.4: the original sdist.
It does not yet contain MuPDF. This normally will be downloaded when
building PyMuPDF.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:37:51 +0200 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_imagemasks.py Mon Sep 15 11:37:51 2025 +0200 @@ -0,0 +1,31 @@ +""" +Confirm image mask detection in TextPage extractions. +""" + +import os + +import pymupdf + +scriptdir = os.path.abspath(os.path.dirname(__file__)) +filename1 = os.path.join(scriptdir, "resources", "img-regular.pdf") +filename2 = os.path.join(scriptdir, "resources", "img-transparent.pdf") + + +def test_imagemask1(): + doc = pymupdf.open(filename1) + page = doc[0] + blocks = page.get_text("dict")["blocks"] + img = blocks[0] + assert img["mask"] is None + img = page.get_image_info()[0] + assert img["has-mask"] is False + + +def test_imagemask2(): + doc = pymupdf.open(filename2) + page = doc[0] + blocks = page.get_text("dict")["blocks"] + img = blocks[0] + assert type(img["mask"]) is bytes + img = page.get_image_info()[0] + assert img["has-mask"] is True
