Remove lossy JBIG2 support, retain lossless JBIG2 only
Lossy JBIG2 has been removed due to well-documented risks of character substitution errors (e.g., 6/8 confusion). The --jbig2-lossy and --jbig2-page-group-size arguments are now deprecated and ignored with a warning. Changes: - Remove jbig2_lossy and jbig2_page_group_size from OCROptions - Simplify optimize.py to use single-image JBIG2 encoding only (no symbol dictionaries/JBIG2Globals) - Remove convert_group() from jbig2enc.py - Deprecate CLI args with warnings for backward compatibility - Update documentation to explain lossless-only JBIG2
This commit is contained in:
@@ -81,8 +81,8 @@ def test_jpg_png_params(resources, outpdf):
|
||||
|
||||
|
||||
@needs_jbig2enc
|
||||
@pytest.mark.parametrize('lossy', [False, True])
|
||||
def test_jbig2_lossy(lossy, resources, outpdf):
|
||||
def test_jbig2_lossless(resources, outpdf):
|
||||
"""Test that JBIG2 lossless encoding works without JBIG2Globals."""
|
||||
args = [
|
||||
resources / 'ccitt.pdf',
|
||||
outpdf,
|
||||
@@ -99,19 +99,14 @@ def test_jbig2_lossy(lossy, resources, outpdf):
|
||||
'--jbig2-threshold',
|
||||
'0.7',
|
||||
]
|
||||
if lossy:
|
||||
args.append('--jbig2-lossy')
|
||||
|
||||
check_ocrmypdf(*args)
|
||||
|
||||
with pikepdf.open(outpdf) as pdf:
|
||||
pim = pikepdf.PdfImage(next(iter(pdf.pages[0].images.values())))
|
||||
assert pim.filters[0] == '/JBIG2Decode'
|
||||
|
||||
if lossy:
|
||||
assert '/JBIG2Globals' in pim.decode_parms[0]
|
||||
else:
|
||||
assert len(pim.decode_parms) == 0
|
||||
# Lossless JBIG2 has no JBIG2Globals (no shared symbol dictionary)
|
||||
assert len(pim.decode_parms) == 0
|
||||
|
||||
|
||||
@needs_pngquant
|
||||
|
||||
Reference in New Issue
Block a user