mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2026-01-06 04:01:25 +00:00
Add test case for corrupt ICC profiles
This commit is contained in:
parent
e7a44ba87a
commit
6c427f82ea
@ -361,7 +361,7 @@ class ImageInfo:
|
||||
self._comp = 3
|
||||
except UnsupportedImageTypeError as ex:
|
||||
self._comp = None
|
||||
logger.warn(
|
||||
logger.warning(
|
||||
f"An image with a corrupt or unreadable ICC profile was found. "
|
||||
f"The output PDF may not match the input PDF visually: {ex}. {self}"
|
||||
)
|
||||
|
||||
@ -922,3 +922,25 @@ def test_outputtype_none(resources, outtxt):
|
||||
'tests/plugins/tesseract_noop.py',
|
||||
)
|
||||
assert p.returncode == ExitCode.ok
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def graph_bad_icc(resources, outdir):
|
||||
synth_input_file = outdir / 'graph-bad-icc.pdf'
|
||||
with pikepdf.open(resources / 'graph.pdf') as pdf:
|
||||
icc = pdf.make_stream(
|
||||
b'invalid icc profile', N=3, Alternate=pikepdf.Name.DeviceRGB
|
||||
)
|
||||
pdf.pages[0].Resources.XObject['/Im0'].ColorSpace = pikepdf.Array(
|
||||
[pikepdf.Name.ICCBased, icc]
|
||||
)
|
||||
pdf.save(synth_input_file)
|
||||
yield synth_input_file
|
||||
|
||||
|
||||
def test_corrupt_icc(graph_bad_icc, outpdf, caplog):
|
||||
result = run_ocrmypdf_api(graph_bad_icc, outpdf)
|
||||
assert result == ExitCode.ok
|
||||
assert any(
|
||||
'corrupt or unreadable ICC profile' in rec.message for rec in caplog.records
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user