Compare commits

...
2 Commits
Author SHA1 Message Date
James R. Barlow f4f0f3c022 v11.7.3 release notes 2021-03-20 23:30:42 -07:00
James R. Barlow 0a42934c08 Exclude Group 3 images from optimization 2021-03-20 23:28:21 -07:00
3 changed files with 24 additions and 0 deletions
+7
View File
@@ -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
=======
+4
View File
@@ -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
+13
View File
@@ -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"