comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 1:1d09e1dec1d9
1 """
2 Confirm image mask detection in TextPage extractions.
3 """
4
5 import os
6
7 import pymupdf
8
9 scriptdir = os.path.abspath(os.path.dirname(__file__))
10 filename1 = os.path.join(scriptdir, "resources", "img-regular.pdf")
11 filename2 = os.path.join(scriptdir, "resources", "img-transparent.pdf")
12
13
14 def test_imagemask1():
15 doc = pymupdf.open(filename1)
16 page = doc[0]
17 blocks = page.get_text("dict")["blocks"]
18 img = blocks[0]
19 assert img["mask"] is None
20 img = page.get_image_info()[0]
21 assert img["has-mask"] is False
22
23
24 def test_imagemask2():
25 doc = pymupdf.open(filename2)
26 page = doc[0]
27 blocks = page.get_text("dict")["blocks"]
28 img = blocks[0]
29 assert type(img["mask"]) is bytes
30 img = page.get_image_info()[0]
31 assert img["has-mask"] is True