Fix regression: Disable Ghostscript JPEG passthrough entirely

This commit is contained in:
James R. Barlow
2018-04-17 17:00:24 -07:00
parent 1a516b2af9
commit 0b10db91be
2 changed files with 15 additions and 6 deletions
+14 -1
View File
@@ -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
View File
@@ -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'):