Skip to content

Commit a2a4a45

Browse files
tests/test_rewrite_images.py: added test_4918().
1 parent 50f6d86 commit a2a4a45

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/test_rewrite_images.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pymupdf
22
import os
3+
import util
4+
35

46
scriptdir = os.path.dirname(__file__)
57

@@ -13,3 +15,25 @@ def test_rewrite_images():
1315
data = doc.tobytes(garbage=3, deflate=True)
1416
size1 = len(data)
1517
assert (1 - (size1 / size0)) > 0.3
18+
19+
20+
def test_4918():
21+
'''
22+
By default this test does nothing, because it requires a rather large input document from:
23+
https://drive.google.com/file/d/1OkIq3XJuKiFfKDWBIcAk8_fLLjpNkuHQ/view?usp=sharing
24+
25+
It's non-trivial to download from this url, so we only do anything if
26+
environment variable PYMUPDF_TEST_4918_PATH is set to local path of the
27+
input document.
28+
29+
As of 2026-06-04 this passes with mupdf master, but segvs with current
30+
pymupdf release 1.27.2.3.
31+
'''
32+
PYMUPDF_TEST_4918_PATH = os.environ.get('PYMUPDF_TEST_4918_PATH')
33+
if not PYMUPDF_TEST_4918_PATH :
34+
print(f'test_4918(): Doing nothing because {PYMUPDF_TEST_4918_PATH=}.')
35+
return
36+
path = PYMUPDF_TEST_4918_PATH
37+
print(f'{path=}')
38+
with pymupdf.open(path) as document:
39+
document.rewrite_images(dpi_threshold=150, dpi_target=100, quality=50)

0 commit comments

Comments
 (0)