Fix regression: Disable Ghostscript JPEG passthrough entirely
This commit is contained in:
@@ -32,6 +32,18 @@ def version():
|
||||
return get_version('gs')
|
||||
|
||||
|
||||
def jpeg_passthrough_available():
|
||||
"""
|
||||
Ghostscript 9.23 introduced JPEG passthrough but it seems to corrupt the
|
||||
last two bytes of certain images, for now we disable it for 9.23 and
|
||||
do not mention it for < 9.23.
|
||||
|
||||
https://bugs.ghostscript.com/show_bug.cgi?id=699216
|
||||
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
def _gs_error_reported(stream):
|
||||
return re.search(r'error', stream, flags=re.IGNORECASE)
|
||||
|
||||
@@ -133,7 +145,8 @@ def generate_pdfa(pdf_pages, output_file, compression, log,
|
||||
strategy = 'RGB' if version() >= '9.19' else '/RGB'
|
||||
|
||||
if version() == '9.23':
|
||||
# 9.23: JPEG passthrough broken for image masks?
|
||||
# 9.23: new feature JPEG passthrough is broken in some cases, best to
|
||||
# disable it always
|
||||
# https://bugs.ghostscript.com/show_bug.cgi?id=699216
|
||||
compression_args.append('-dPassThroughJPEGImages=false')
|
||||
|
||||
|
||||
+1
-5
@@ -610,10 +610,6 @@ def test_masks(spoof_tesseract_noop, resources, outpdf):
|
||||
p, out, err = run_ocrmypdf(
|
||||
resources / 'masks.pdf', outpdf, env=spoof_tesseract_noop)
|
||||
|
||||
if ghostscript.version() == '9.23' and \
|
||||
p.returncode == ExitCode.invalid_output_pdf:
|
||||
pytest.xfail('https://bugs.ghostscript.com/show_bug.cgi?id=699216')
|
||||
|
||||
assert p.returncode == ExitCode.ok
|
||||
|
||||
|
||||
@@ -906,7 +902,7 @@ def test_compression_changed(spoof_tesseract_noop, ocrmypdf_exec,
|
||||
if compression == "jpeg":
|
||||
assert pdfimage.enc == Encoding.jpeg
|
||||
else:
|
||||
if ghostscript.version() >= '9.23':
|
||||
if ghostscript.jpeg_passthrough_available():
|
||||
# Ghostscript 9.23 adds JPEG passthrough, which allows a JPEG to be
|
||||
# copied without transcoding - so report
|
||||
if image.endswith('jpg'):
|
||||
|
||||
Reference in New Issue
Block a user