Mercurial > hgrepos > Python2 > PyMuPDF
comparison tests/test_rewrite_images.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 import pymupdf | |
| 2 import os | |
| 3 | |
| 4 scriptdir = os.path.dirname(__file__) | |
| 5 | |
| 6 | |
| 7 def test_rewrite_images(): | |
| 8 """Example for decreasing file size by more than 30%.""" | |
| 9 filename = os.path.join(scriptdir, "resources", "test-rewrite-images.pdf") | |
| 10 doc = pymupdf.open(filename) | |
| 11 size0 = os.path.getsize(doc.name) | |
| 12 doc.rewrite_images(dpi_threshold=100, dpi_target=72, quality=33) | |
| 13 data = doc.tobytes(garbage=3, deflate=True) | |
| 14 size1 = len(data) | |
| 15 assert (1 - (size1 / size0)) > 0.3 |
