MCPcopy Create free account
hub / github.com/docling-project/docling-parse / _write_diff_artifacts

Function _write_diff_artifacts

tests/rendering_regression.py:143–160  ·  view source on GitHub ↗
(
    doc_name: str,
    page_no: int,
    actual: Image.Image,
    expected: Image.Image,
)

Source from the content-addressed store, hash-verified

141
142
143def _write_diff_artifacts(
144 doc_name: str,
145 page_no: int,
146 actual: Image.Image,
147 expected: Image.Image,
148) -> None:
149 RENDER_DELTA_FOLDER.mkdir(parents=True, exist_ok=True)
150 actual.save(_diff_artifact_path(doc_name, page_no, "actual.png"))
151 expected.save(_diff_artifact_path(doc_name, page_no, "expected.png"))
152
153 width = min(actual.width, expected.width)
154 height = min(actual.height, expected.height)
155 diff = ImageChops.difference(
156 actual.crop((0, 0, width, height)),
157 expected.crop((0, 0, width, height)),
158 )
159 amplified = ImageEnhance.Brightness(diff).enhance(8)
160 amplified.save(_diff_artifact_path(doc_name, page_no, "diff.png"))
161
162
163def measure_image_comparison(

Callers 1

compare_imagesFunction · 0.85

Calls 2

_diff_artifact_pathFunction · 0.85
saveMethod · 0.45

Tested by

no test coverage detected