Mercurial > hgrepos > Python2 > PyMuPDF
comparison tests/test_imagemasks.py @ 3:2c135c81b16c
MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:44:09 +0200 |
| parents | 1d09e1dec1d9 |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6015a75abc2d | 3:2c135c81b16c |
|---|---|
| 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 |
