Skip to content

Commit

Permalink
tests/: added a test for #3624 `Pdf file transform to image have a bl…
Browse files Browse the repository at this point in the history
…ack block`.
  • Loading branch information
julian-smith-artifex-com committed Oct 3, 2024
1 parent 2c05e5e commit 0ed97b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Binary file added tests/resources/test_3624.pdf
Binary file not shown.
Binary file added tests/resources/test_3624_expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import re
import time

import gentle_compare

scriptdir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(scriptdir, "resources", "001003ED.pdf")

Expand Down Expand Up @@ -1364,3 +1366,18 @@ def test_3905():
assert 0
wt = pymupdf.TOOLS.mupdf_warnings()
assert wt == 'format error: cannot recognize version marker\ntrying to repair broken xref\nrepairing PDF document'

def test_3624():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_3624.pdf')
path_png_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_3624_expected.png')
path_png = os.path.normpath(f'{__file__}/../../tests/test_3624.png')
with pymupdf.open(path) as document:
page = document[0]
pixmap = page.get_pixmap(matrix=pymupdf.Matrix(2, 2))
print(f'Saving to {path_png=}.')
pixmap.save(path_png)
rms = gentle_compare.pixmaps_rms(path_png_expected, path_png)
if pymupdf.mupdf_version_tuple < (1, 24, 10):
assert rms > 12
else:
assert rms == 0

0 comments on commit 0ed97b0

Please sign in to comment.