Mercurial > hgrepos > Python2 > PyMuPDF
comparison tests/test_2904.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 import pymupdf | |
| 2 | |
| 3 import os | |
| 4 import sys | |
| 5 | |
| 6 def test_2904(): | |
| 7 print(f'test_2904(): {pymupdf.mupdf_version_tuple=}.') | |
| 8 path = os.path.abspath(f'{__file__}/../../tests/resources/test_2904.pdf') | |
| 9 pdf_docs = pymupdf.open(path) | |
| 10 for page_id, page in enumerate(pdf_docs): | |
| 11 page_imgs = page.get_images() | |
| 12 for i, img in enumerate(page_imgs): | |
| 13 if page_id == 5: | |
| 14 #print(f'{page_id=} {i=} {type(img)=} {img=}') | |
| 15 sys.stdout.flush() | |
| 16 e = None | |
| 17 try: | |
| 18 recs = page.get_image_rects(img, transform=True) | |
| 19 except Exception as ee: | |
| 20 print(f'Exception: {page_id=} {i=} {img=}: {ee}') | |
| 21 if 0 and hasattr(pymupdf, 'mupdf'): | |
| 22 print(f'pymupdf.exception_info:') | |
| 23 pymupdf.exception_info() | |
| 24 sys.stdout.flush() | |
| 25 e = ee | |
| 26 if page_id == 5: | |
| 27 print(f'{pymupdf.mupdf_version_tuple=}: {page_id=} {i=} {e=} {img=}:') | |
| 28 if page_id == 5 and i==3: | |
| 29 assert e | |
| 30 if hasattr(pymupdf, 'mupdf'): | |
| 31 # rebased. | |
| 32 assert str(e) == 'code=8: Failed to read JPX header' | |
| 33 else: | |
| 34 # classic | |
| 35 assert str(e) == 'Failed to read JPX header' | |
| 36 else: | |
| 37 assert not e | |
| 38 | |
| 39 # Clear warnings, as we will have generated many. | |
| 40 pymupdf.TOOLS.mupdf_warnings() |
