MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_compress

Function test_compress

tests/test_insertimage.py:29–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 assert bbox2 in r2
28
29def test_compress():
30 document = pymupdf.open(f'{scriptdir}/resources/2.pdf')
31 document_new = pymupdf.open()
32 for page in document:
33 pixmap = page.get_pixmap(
34 colorspace=pymupdf.csRGB,
35 dpi=72,
36 annots=False,
37 )
38 page_new = document_new.new_page(-1)
39 page_new.insert_image(rect=page_new.bound(), pixmap=pixmap)
40 document_new.save(
41 f'{scriptdir}/resources/2.pdf.compress.pdf',
42 garbage=3,
43 deflate=True,
44 deflate_images=True,
45 deflate_fonts=True,
46 pretty=True,
47 )
48
49def test_3087():
50 path = os.path.abspath(f'{__file__}/../../tests/resources/test_3087.pdf')

Callers

nothing calls this directly

Calls 5

new_pageMethod · 0.80
insert_imageMethod · 0.80
boundMethod · 0.80
get_pixmapMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…