Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11a561dbce | ||
|
|
dad2198394 | ||
|
|
e40fdc502d | ||
|
|
d446fe5922 | ||
|
|
4ca90c106d | ||
|
|
7c5e58a497 |
+9
-6
@@ -23,12 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends \
|
RUN apt-get install -y --no-install-recommends \
|
||||||
unpaper \
|
unpaper \
|
||||||
libopenjpeg-dev \
|
|
||||||
ghostscript \
|
|
||||||
qpdf \
|
qpdf \
|
||||||
poppler-utils
|
poppler-utils \
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends \
|
|
||||||
tesseract-ocr \
|
tesseract-ocr \
|
||||||
tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-eng tesseract-ocr-fra
|
tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-eng tesseract-ocr-fra
|
||||||
|
|
||||||
@@ -37,6 +33,14 @@ RUN apt-get install -qy --no-install-recommends \
|
|||||||
libpython3-dev \
|
libpython3-dev \
|
||||||
gcc
|
gcc
|
||||||
|
|
||||||
|
# Install Ghostscript from Debian sid to work around JPEG 2000 issue in
|
||||||
|
# Debian stretch libgs9 or gs 9.16~dfsg-2.1
|
||||||
|
|
||||||
|
COPY ./share/etc-apt-sources.list /etc/apt/sources.list
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y ghostscript/sid
|
||||||
|
|
||||||
|
|
||||||
# Enforce UTF-8
|
# Enforce UTF-8
|
||||||
# Borrowed from https://index.docker.io/u/crosbymichael/python/
|
# Borrowed from https://index.docker.io/u/crosbymichael/python/
|
||||||
RUN dpkg-reconfigure locales && \
|
RUN dpkg-reconfigure locales && \
|
||||||
@@ -80,7 +84,6 @@ USER docker
|
|||||||
WORKDIR /home/docker
|
WORKDIR /home/docker
|
||||||
|
|
||||||
ENV OCRMYPDF_TEST_OUTPUT=/tmp/test-output
|
ENV OCRMYPDF_TEST_OUTPUT=/tmp/test-output
|
||||||
ENV OCRMYPDF_IN_DOCKER=1
|
|
||||||
ENV OCRMYPDF_SHARP_TTF=1
|
ENV OCRMYPDF_SHARP_TTF=1
|
||||||
|
|
||||||
# Must use array form of ENTRYPOINT
|
# Must use array form of ENTRYPOINT
|
||||||
|
|||||||
@@ -6,6 +6,24 @@ Please always read this file before installing the package
|
|||||||
Download software here: https://github.com/jbarlow83/OCRmyPDF/tags
|
Download software here: https://github.com/jbarlow83/OCRmyPDF/tags
|
||||||
|
|
||||||
|
|
||||||
|
v4.0.3:
|
||||||
|
=======
|
||||||
|
|
||||||
|
New features
|
||||||
|
------------
|
||||||
|
|
||||||
|
- Page orientations detected are now reported in a summary comment
|
||||||
|
|
||||||
|
|
||||||
|
Fixes
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Show stack trace if unexpect errors occur
|
||||||
|
- Treat "too few characters" error message from Tesseract as a reason to skip that page rather than
|
||||||
|
abort the file
|
||||||
|
- Docker: fix blank JPEG2000 issue by insisting on Ghostscript versions that have this fixed
|
||||||
|
|
||||||
|
|
||||||
v4.0.2:
|
v4.0.2:
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|||||||
@@ -550,6 +550,12 @@ def orient_page(
|
|||||||
with open(output_file, 'wb') as out:
|
with open(output_file, 'wb') as out:
|
||||||
writer.write(out)
|
writer.write(out)
|
||||||
|
|
||||||
|
with pdfinfo_lock:
|
||||||
|
pageno = int(os.path.basename(page_pdf)[0:6]) - 1
|
||||||
|
pageinfo = pdfinfo[pageno].copy()
|
||||||
|
pageinfo['rotated'] = orient_conf.angle
|
||||||
|
pdfinfo[pageno] = pageinfo
|
||||||
|
|
||||||
|
|
||||||
@transform(
|
@transform(
|
||||||
input=orient_page,
|
input=orient_page,
|
||||||
@@ -1045,6 +1051,8 @@ def run_pipeline():
|
|||||||
msg = "Error occurred while running this command:"
|
msg = "Error occurred while running this command:"
|
||||||
_log.error(msg + '\n' + exc_value)
|
_log.error(msg + '\n' + exc_value)
|
||||||
return ExitCode.child_process_error
|
return ExitCode.child_process_error
|
||||||
|
elif not options.verbose:
|
||||||
|
_log.error(e)
|
||||||
|
|
||||||
return ExitCode.other_error
|
return ExitCode.other_error
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -1055,6 +1063,20 @@ def run_pipeline():
|
|||||||
_log.warning('Output file: The generated PDF/A file is INVALID')
|
_log.warning('Output file: The generated PDF/A file is INVALID')
|
||||||
return ExitCode.invalid_output_pdfa
|
return ExitCode.invalid_output_pdfa
|
||||||
|
|
||||||
|
with _pdfinfo_lock:
|
||||||
|
_log.debug(_pdfinfo)
|
||||||
|
direction = {0: 'n', 90: 'e',
|
||||||
|
180: 's', 270: 'w'}
|
||||||
|
orientations = []
|
||||||
|
for n, page in enumerate(_pdfinfo):
|
||||||
|
angle = _pdfinfo[n].get('rotated', 0)
|
||||||
|
if angle != 0:
|
||||||
|
orientations.append('{0}{1}'.format(
|
||||||
|
n + 1,
|
||||||
|
direction.get(angle, '')))
|
||||||
|
if orientations:
|
||||||
|
_log.info('Page orientations detected: ' + ' '.join(orientations))
|
||||||
|
|
||||||
return ExitCode.ok
|
return ExitCode.ok
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ def get_orientation(input_file, language: list, timeout: float, log):
|
|||||||
return OrientationConfidence(angle=0, confidence=0.0)
|
return OrientationConfidence(angle=0, confidence=0.0)
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
tesseract_log_output(log, e.output, input_file)
|
tesseract_log_output(log, e.output, input_file)
|
||||||
if 'Image too large' in e.output:
|
if ('Too few characters. Skipping this page' in e.output or
|
||||||
|
'Image too large' in e.output):
|
||||||
return OrientationConfidence(0, 0)
|
return OrientationConfidence(0, 0)
|
||||||
raise e from e
|
raise e from e
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
deb http://httpredir.debian.org/debian stretch main
|
||||||
|
deb http://httpredir.debian.org/debian stretch-updates main
|
||||||
|
deb http://security.debian.org stretch/updates main
|
||||||
|
deb http://ftp.de.debian.org/debian sid main contrib non-free
|
||||||
@@ -28,6 +28,11 @@ TEST_OUTPUT = os.environ.get(
|
|||||||
default=os.path.join(PROJECT_ROOT, 'tests', 'output', 'main'))
|
default=os.path.join(PROJECT_ROOT, 'tests', 'output', 'main'))
|
||||||
|
|
||||||
|
|
||||||
|
def running_in_docker():
|
||||||
|
# Docker creates a file named /.dockerinit
|
||||||
|
return os.path.exists('/.dockerinit')
|
||||||
|
|
||||||
|
|
||||||
def setup_module():
|
def setup_module():
|
||||||
with suppress(FileNotFoundError):
|
with suppress(FileNotFoundError):
|
||||||
shutil.rmtree(TEST_OUTPUT)
|
shutil.rmtree(TEST_OUTPUT)
|
||||||
@@ -105,6 +110,8 @@ def spoof_tesseract_noop():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def spoof_tesseract_cache():
|
def spoof_tesseract_cache():
|
||||||
|
if running_in_docker():
|
||||||
|
return os.environ.copy()
|
||||||
return spoof('tesseract', "tesseract_cache.py")
|
return spoof('tesseract', "tesseract_cache.py")
|
||||||
|
|
||||||
|
|
||||||
@@ -408,6 +415,8 @@ def test_missing_docinfo(spoof_tesseract_noop):
|
|||||||
assert p.returncode == ExitCode.ok, err
|
assert p.returncode == ExitCode.ok, err
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(running_in_docker(),
|
||||||
|
reason="writes to tests/resources")
|
||||||
def test_uppercase_extension(spoof_tesseract_noop):
|
def test_uppercase_extension(spoof_tesseract_noop):
|
||||||
shutil.copy(_infile("skew.pdf"), _infile("UPPERCASE.PDF"))
|
shutil.copy(_infile("skew.pdf"), _infile("UPPERCASE.PDF"))
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user