Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4f0f3c022 | ||
|
|
0a42934c08 |
@@ -12,6 +12,13 @@ may be unreliable. Use the API to depend on precise behavior.
|
||||
The public API may be useful in scripts that launch OCRmyPDF processes or that
|
||||
wish to use some of its features for working with PDFs.
|
||||
|
||||
v11.7.3
|
||||
=======
|
||||
|
||||
- Exclude CCITT Group 3 images from being optimized. Some libraries
|
||||
OCRmyPDF uses do not seem to handle this obscure compression format properly.
|
||||
You may get errors or possible corrupted output images without this fix.
|
||||
|
||||
v11.7.2
|
||||
=======
|
||||
|
||||
|
||||
@@ -95,6 +95,10 @@ def extract_image_filter(
|
||||
log.debug(f"Skipping JPEG2000 iamge, xref {xref}")
|
||||
return None # Don't do JPEG2000
|
||||
|
||||
if filtdp[0] == Name.CCITTFaxDecode and filtdp[1].get('/K', 0) >= 0:
|
||||
log.debug(f"Skipping CCITT Group 3 image, xref {xref}")
|
||||
return None # pikepdf doesn't support Group 3 yet
|
||||
|
||||
if Name.Decode in image:
|
||||
log.debug(f"Skipping image with Decode table, xref {xref}")
|
||||
return None # Don't mess with custom Decode tables
|
||||
|
||||
@@ -185,3 +185,16 @@ def test_optimize_off(resources, outpdf):
|
||||
'--plugin',
|
||||
'tests/plugins/tesseract_noop.py',
|
||||
)
|
||||
|
||||
|
||||
def test_group3(resources, outdir):
|
||||
with pikepdf.open(resources / 'ccitt.pdf') as pdf:
|
||||
im = pdf.pages[0].Resources.XObject['/Im1']
|
||||
assert (
|
||||
opt.extract_image_filter(pdf, outdir, im, im.objgen[0]) is not None
|
||||
), "Group 4 should be allowed"
|
||||
|
||||
im.DecodeParms['/K'] = 0
|
||||
assert (
|
||||
opt.extract_image_filter(pdf, outdir, im, im.objgen[0]) is None
|
||||
), "Group 3 should be disallowed"
|
||||
|
||||
Reference in New Issue
Block a user