Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d0765a5e0 | ||
|
|
1ca327e13b | ||
|
|
f504fd1875 | ||
|
|
cf7c20ca16 | ||
|
|
b00fe3dc5d | ||
|
|
e6aa3a4299 | ||
|
|
24f1b57288 | ||
|
|
43302d7e12 | ||
|
|
fed0226761 | ||
|
|
27e22b4f07 |
+1
-1
@@ -1,7 +1,7 @@
|
||||
# OCRmyPDF
|
||||
#
|
||||
|
||||
FROM debian:bookworm-slim as base
|
||||
FROM ubuntu:22.04 as base
|
||||
|
||||
ENV LANG=C.UTF-8
|
||||
ENV TZ=UTC
|
||||
|
||||
@@ -32,6 +32,9 @@ For all other Linux, you must build a JBIG2 encoder from source:
|
||||
|
||||
.. _jbig2-lossy:
|
||||
|
||||
Dependencies include libtoolize and libleptonica, which on Ubuntu systems
|
||||
are packaged as libtool and libleptonica-dev.
|
||||
|
||||
Lossy mode JBIG2
|
||||
================
|
||||
|
||||
|
||||
@@ -54,6 +54,33 @@ to what languages it should search for. Multiple languages can be
|
||||
requested using either ``-l eng+fra`` (English and French) or
|
||||
``-l eng -l fra``.
|
||||
|
||||
Gentoo users
|
||||
============
|
||||
|
||||
On Gentoo the package ``app-text/tessdata_fast``, which ``app-text/tesseract`` depends on, handles Tesseract languages.
|
||||
It accepts USE flags to select what languages should be installed, these can be set in ``/etc/portage/package.use``.
|
||||
Alternatively one can globally set the `L10N use extension <https://wiki.gentoo.org/wiki/Localization/Guide#L10N>`__ in ``/etc/portage/make.conf``.
|
||||
This enables these languages for all packages (e.g. including aspell).
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Display a list of all Tesseract language packs
|
||||
equery uses app-text/tessdata_fast
|
||||
|
||||
# Add English and German language support for Tesseract only
|
||||
echo 'app-text/tessdata_fast l10n_de l10n_en' >> /etc/portage/package.use
|
||||
|
||||
# Add global English and German language support (the `l10n_` from equery has to be omited)
|
||||
echo L10N="de en" >> /etc/portage/make.conf
|
||||
|
||||
# update system to reflect changed USE flags
|
||||
emerge --update --deep --newuse @world
|
||||
|
||||
You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as
|
||||
to what languages it should search for. Multiple languages can be
|
||||
requested using either ``-l eng+fra`` (English and French) or
|
||||
``-l eng -l fra``.
|
||||
|
||||
macOS users
|
||||
===========
|
||||
|
||||
|
||||
@@ -18,6 +18,20 @@ tagged yet.
|
||||
|
||||
.. |OCRmyPDF PyPI| image:: https://img.shields.io/pypi/v/ocrmypdf.svg
|
||||
|
||||
v13.4.4
|
||||
=======
|
||||
|
||||
- Updated pdfminer.six version.
|
||||
- Docker image changed to Ubuntu 22.04 now that it is released and provides the
|
||||
dependencies we need. This seems more consistent than our recent change to
|
||||
Debian.
|
||||
|
||||
v13.4.3
|
||||
=======
|
||||
|
||||
- Fix error on pytest.skip() with older versions of pytest.
|
||||
- Documentation updates.
|
||||
|
||||
v13.4.2
|
||||
=======
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ install_requires =
|
||||
coloredlogs>=14.0 # strictly optional
|
||||
img2pdf>=0.3.0,<0.5 # pure Python
|
||||
packaging>=20
|
||||
pdfminer.six!=20200720,>=20191110,<=20220319
|
||||
pdfminer.six!=20200720,>=20191110,<=20220506
|
||||
pikepdf!=5.0.0,>=4.0.0
|
||||
pluggy>=0.13.0,<2
|
||||
reportlab>=3.5.66
|
||||
|
||||
@@ -50,11 +50,11 @@ import logging
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import threading
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from subprocess import PIPE, CalledProcessError, CompletedProcess
|
||||
from unittest.mock import patch
|
||||
import threading
|
||||
|
||||
from ocrmypdf import hookimpl
|
||||
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine
|
||||
@@ -177,28 +177,40 @@ def cached_run(options, run_args, **run_kwargs):
|
||||
|
||||
|
||||
class CacheOcrEngine(TesseractOcrEngine):
|
||||
# Concurrent threads (with --use-threads) might try to use different parts
|
||||
# of the OcrEngine, so we need a lock to protect the state of patched
|
||||
# module whenever it's patched. Should refactor ocrmypdf._exec.tesseract so that
|
||||
# it does not to be patched at all for testing.
|
||||
lock = threading.Lock()
|
||||
|
||||
@staticmethod
|
||||
def get_orientation(input_file, options):
|
||||
with CacheOcrEngine.lock, patch('ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)):
|
||||
return TesseractOcrEngine.get_orientation(input_file, options)
|
||||
with CacheOcrEngine.lock, patch(
|
||||
'ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)
|
||||
):
|
||||
return TesseractOcrEngine.get_orientation(input_file, options)
|
||||
|
||||
@staticmethod
|
||||
def get_deskew(input_file, options) -> float:
|
||||
with CacheOcrEngine.lock, patch('ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)):
|
||||
with CacheOcrEngine.lock, patch(
|
||||
'ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)
|
||||
):
|
||||
return TesseractOcrEngine.get_deskew(input_file, options)
|
||||
|
||||
@staticmethod
|
||||
def generate_hocr(input_file, output_hocr, output_text, options):
|
||||
with CacheOcrEngine.lock, patch('ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)):
|
||||
with CacheOcrEngine.lock, patch(
|
||||
'ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)
|
||||
):
|
||||
TesseractOcrEngine.generate_hocr(
|
||||
input_file, output_hocr, output_text, options
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def generate_pdf(input_file, output_pdf, output_text, options):
|
||||
with CacheOcrEngine.lock, patch('ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)):
|
||||
with CacheOcrEngine.lock, patch(
|
||||
'ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)
|
||||
):
|
||||
TesseractOcrEngine.generate_pdf(
|
||||
input_file, output_pdf, output_text, options
|
||||
)
|
||||
|
||||
@@ -188,7 +188,7 @@ def test_xml_metadata_preserved(test_file, output_type, resources, outpdf):
|
||||
try:
|
||||
from libxmp.utils import file_to_dict # pylint: disable=import-outside-toplevel
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pytest.skip(reason="libxmp not available or libexempi3 not installed")
|
||||
pytest.skip("libxmp not available or libexempi3 not installed")
|
||||
|
||||
before = file_to_dict(str(input_file))
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ def test_stack_abuse():
|
||||
pdfinfo.info._interpret_contents(stream)
|
||||
|
||||
stream = pikepdf.Stream(p, b'q ' * 135)
|
||||
with pytest.warns():
|
||||
with pytest.warns(UserWarning):
|
||||
with pytest.raises(RuntimeError):
|
||||
pdfinfo.info._interpret_contents(stream)
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ def test_stdin(ocrmypdf_exec, resources, outpdf):
|
||||
|
||||
def test_stdout(ocrmypdf_exec, resources, outpdf):
|
||||
if 'COV_CORE_DATAFILE' in os.environ:
|
||||
pytest.skip(reason="Coverage uses stdout")
|
||||
pytest.skip("Coverage uses stdout")
|
||||
|
||||
input_file = str(resources / 'francais.pdf')
|
||||
output_file = str(outpdf)
|
||||
@@ -72,7 +72,7 @@ def test_bad_locale(monkeypatch):
|
||||
)
|
||||
def test_dev_null(resources):
|
||||
if 'COV_CORE_DATAFILE' in os.environ:
|
||||
pytest.skip(reason="Coverage uses stdout")
|
||||
pytest.skip("Coverage uses stdout")
|
||||
|
||||
p = run_ocrmypdf(
|
||||
resources / 'trivial.pdf',
|
||||
|
||||
Reference in New Issue
Block a user