Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf7c20ca16 | ||
|
|
b00fe3dc5d | ||
|
|
e6aa3a4299 | ||
|
|
24f1b57288 | ||
|
|
43302d7e12 | ||
|
|
fed0226761 | ||
|
|
27e22b4f07 |
@@ -32,6 +32,9 @@ For all other Linux, you must build a JBIG2 encoder from source:
|
|||||||
|
|
||||||
.. _jbig2-lossy:
|
.. _jbig2-lossy:
|
||||||
|
|
||||||
|
Dependencies include libtoolize and libleptonica, which on Ubuntu systems
|
||||||
|
are packaged as libtool and libleptonica-dev.
|
||||||
|
|
||||||
Lossy mode JBIG2
|
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
|
requested using either ``-l eng+fra`` (English and French) or
|
||||||
``-l eng -l fra``.
|
``-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
|
macOS users
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ tagged yet.
|
|||||||
|
|
||||||
.. |OCRmyPDF PyPI| image:: https://img.shields.io/pypi/v/ocrmypdf.svg
|
.. |OCRmyPDF PyPI| image:: https://img.shields.io/pypi/v/ocrmypdf.svg
|
||||||
|
|
||||||
|
v13.4.3
|
||||||
|
=======
|
||||||
|
|
||||||
|
- Fix error on pytest.skip() with older versions of pytest.
|
||||||
|
- Documentation updates.
|
||||||
|
|
||||||
v13.4.2
|
v13.4.2
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ import logging
|
|||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import threading
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import PIPE, CalledProcessError, CompletedProcess
|
from subprocess import PIPE, CalledProcessError, CompletedProcess
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import threading
|
|
||||||
|
|
||||||
from ocrmypdf import hookimpl
|
from ocrmypdf import hookimpl
|
||||||
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine
|
from ocrmypdf.builtin_plugins.tesseract_ocr import TesseractOcrEngine
|
||||||
@@ -177,28 +177,40 @@ def cached_run(options, run_args, **run_kwargs):
|
|||||||
|
|
||||||
|
|
||||||
class CacheOcrEngine(TesseractOcrEngine):
|
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()
|
lock = threading.Lock()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_orientation(input_file, options):
|
def get_orientation(input_file, options):
|
||||||
with CacheOcrEngine.lock, patch('ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)):
|
with CacheOcrEngine.lock, patch(
|
||||||
return TesseractOcrEngine.get_orientation(input_file, options)
|
'ocrmypdf._exec.tesseract.run', new=partial(cached_run, options)
|
||||||
|
):
|
||||||
|
return TesseractOcrEngine.get_orientation(input_file, options)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_deskew(input_file, options) -> float:
|
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)
|
return TesseractOcrEngine.get_deskew(input_file, options)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_hocr(input_file, output_hocr, output_text, options):
|
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(
|
TesseractOcrEngine.generate_hocr(
|
||||||
input_file, output_hocr, output_text, options
|
input_file, output_hocr, output_text, options
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generate_pdf(input_file, output_pdf, output_text, options):
|
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(
|
TesseractOcrEngine.generate_pdf(
|
||||||
input_file, output_pdf, output_text, options
|
input_file, output_pdf, output_text, options
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ def test_xml_metadata_preserved(test_file, output_type, resources, outpdf):
|
|||||||
try:
|
try:
|
||||||
from libxmp.utils import file_to_dict # pylint: disable=import-outside-toplevel
|
from libxmp.utils import file_to_dict # pylint: disable=import-outside-toplevel
|
||||||
except Exception: # pylint: disable=broad-except
|
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))
|
before = file_to_dict(str(input_file))
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ def test_stack_abuse():
|
|||||||
pdfinfo.info._interpret_contents(stream)
|
pdfinfo.info._interpret_contents(stream)
|
||||||
|
|
||||||
stream = pikepdf.Stream(p, b'q ' * 135)
|
stream = pikepdf.Stream(p, b'q ' * 135)
|
||||||
with pytest.warns():
|
with pytest.warns(UserWarning):
|
||||||
with pytest.raises(RuntimeError):
|
with pytest.raises(RuntimeError):
|
||||||
pdfinfo.info._interpret_contents(stream)
|
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):
|
def test_stdout(ocrmypdf_exec, resources, outpdf):
|
||||||
if 'COV_CORE_DATAFILE' in os.environ:
|
if 'COV_CORE_DATAFILE' in os.environ:
|
||||||
pytest.skip(reason="Coverage uses stdout")
|
pytest.skip("Coverage uses stdout")
|
||||||
|
|
||||||
input_file = str(resources / 'francais.pdf')
|
input_file = str(resources / 'francais.pdf')
|
||||||
output_file = str(outpdf)
|
output_file = str(outpdf)
|
||||||
@@ -72,7 +72,7 @@ def test_bad_locale(monkeypatch):
|
|||||||
)
|
)
|
||||||
def test_dev_null(resources):
|
def test_dev_null(resources):
|
||||||
if 'COV_CORE_DATAFILE' in os.environ:
|
if 'COV_CORE_DATAFILE' in os.environ:
|
||||||
pytest.skip(reason="Coverage uses stdout")
|
pytest.skip("Coverage uses stdout")
|
||||||
|
|
||||||
p = run_ocrmypdf(
|
p = run_ocrmypdf(
|
||||||
resources / 'trivial.pdf',
|
resources / 'trivial.pdf',
|
||||||
|
|||||||
Reference in New Issue
Block a user