diff --git a/MANIFEST.in b/MANIFEST.in index 919e3517..450f48c8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -14,6 +14,7 @@ include .dockerignore # tests include pytest.ini recursive-include tests *.jpg +recursive-include tests *.png recursive-include tests *.pdf recursive-include tests *.py recursive-include tests *.rst diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 0d9d7e26..46f29cf1 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -3,6 +3,12 @@ RELEASE NOTES OCRmyPDF uses `semantic versioning `_. +v4.3.4: +======= + +- Fixed "decimal.InvalidOperation: quantize result has too many digits" for high DPI images + + v4.3.3: ======= diff --git a/ocrmypdf/ghostscript.py b/ocrmypdf/ghostscript.py index ee1b5bad..f724ebad 100644 --- a/ocrmypdf/ghostscript.py +++ b/ocrmypdf/ghostscript.py @@ -2,7 +2,7 @@ # © 2015 James R. Barlow: github.com/jbarlow83 from tempfile import NamedTemporaryFile -from subprocess import Popen, PIPE, check_call +from subprocess import Popen, PIPE, STDOUT, check_call from shutil import copy from . import get_program from .pdfa import SRGB_ICC_PROFILE @@ -25,16 +25,13 @@ def rasterize_pdf(input_file, output_file, xres, yres, raster_device, log, input_file ] - p = Popen(args_gs, close_fds=True, stdout=PIPE, stderr=PIPE, + p = Popen(args_gs, close_fds=True, stdout=PIPE, stderr=STDOUT, universal_newlines=True) - stdout, stderr = p.communicate() - if stdout: - if 'error' in stdout: - log.error(stdout) # Ghostscript puts errors in stdout - else: - log.debug(stdout) - if stderr: - log.error(stderr) + stdout, _ = p.communicate() + if 'error' in stdout: + log.error(stdout) # Ghostscript puts errors in stdout + else: + log.debug(stdout) if p.returncode == 0: copy(tmp.name, output_file) @@ -60,24 +57,22 @@ def generate_pdfa(pdf_pages, output_file, log, threads=1): "-sOutputFile=" + gs_pdf.name, ] args_gs.extend(pdf_pages) - p = Popen(args_gs, close_fds=True, stdout=PIPE, stderr=PIPE, + p = Popen(args_gs, close_fds=True, stdout=PIPE, stderr=STDOUT, universal_newlines=True) - stdout, stderr = p.communicate() - if stdout: - if 'error' in stdout: - log.error(stdout) - elif 'overprint mode not set' in stdout: - # Unless someone is going to print PDF/A documents on a - # magical sRGB printer I can't see the removal of overprinting - # being a problem.... - log.debug( - "Ghostscript had to remove PDF 'overprinting' from the " - "input file to complete PDF/A conversion. " - ) - else: - log.debug(stdout) - if stderr: - log.error(stderr) + stdout, _ = p.communicate() + + if 'error' in stdout: + log.error(stdout) + elif 'overprint mode not set' in stdout: + # Unless someone is going to print PDF/A documents on a + # magical sRGB printer I can't see the removal of overprinting + # being a problem.... + log.debug( + "Ghostscript had to remove PDF 'overprinting' from the " + "input file to complete PDF/A conversion. " + ) + else: + log.debug(stdout) if p.returncode == 0: # Ghostscript does not change return code when it fails to create diff --git a/tests/test_main.py b/tests/test_main.py index 41dd81c1..7b9f5dc5 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -60,6 +60,7 @@ def check_ocrmypdf(input_basename, output_basename, *args, env=None): output_file = _outfile(output_basename) p, out, err = run_ocrmypdf(input_basename, output_basename, *args, env=env) + print(err) # ensure py.test collects the output, use -s to view if p.returncode != 0: print('stdout\n======') print(out)