Compare commits

...
16 Commits
Author SHA1 Message Date
James R. Barlow 11125c5367 v13.4.5 release notes 2022-05-24 16:52:43 -07:00
James R. Barlow e648411067 Remove pdfminer.six upper version restriction
Needing to update this every time has become more inconvenient than dealing
with the occasional breakage in a new release.
2022-05-24 16:51:38 -07:00
Ben BeasleyandGitHub 11365575d7 Allow pdfminer.six 20220524 (#971) 2022-05-24 16:33:44 -07:00
James R. Barlow 845cb5c40c docs: clarify that --pages and --skip-text exclusions apply to image processing and OCR
Closes #950
2022-05-16 13:20:47 -07:00
James R. Barlow b699e158be Fix references to old repo at jbarlow83/OCRmyPDF 2022-05-16 12:48:10 -07:00
leonnicolasandGitHub 603da52026 Fix small typo in update api.py (#963)
[ci skip]
2022-05-14 21:45:23 -07:00
James R. Barlow 8d0765a5e0 v13.4.4 release notes 2022-05-14 14:53:03 -07:00
James R. Barlow 1ca327e13b Update pdfminer.six version 2022-05-14 14:51:59 -07:00
James R. Barlow f504fd1875 Change Docker base to 22.04 2022-04-28 22:46:30 -07:00
James R. Barlow cf7c20ca16 v13.4.3 release notes 2022-04-14 20:19:31 -07:00
James R. Barlow b00fe3dc5d pytest.skip() - remove kwarg entirely, to avoid breaking older pytest and not getting warns from newer pytest 2022-04-14 20:15:00 -07:00
James R. Barlow e6aa3a4299 tests: explain why CacheOcrEngine needs lock 2022-04-05 16:16:51 -07:00
James R. Barlow 24f1b57288 Merge branch 'master' of github.com:ocrmypdf/OCRmyPDF 2022-04-05 16:04:45 -07:00
James R. Barlow 43302d7e12 Fix pytest.warns() on older pytest
Thanks @QuLogic
2022-04-05 16:02:50 -07:00
Christopher BeschandGitHub fed0226761 Add Gentoo Language Installation Instructions (#936) 2022-04-05 00:26:24 -07:00
Joseph MorrisandGitHub 27e22b4f07 Update jbig2.rst (#911)
Adding Ubuntu package names for dependencies I needed to save others time. The tequired package for leptonica is particularly confusing since configure just says "Error! Leptonica not detected." and there are multiple leptonica packages
2022-04-05 00:25:28 -07:00
19 changed files with 107 additions and 46 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# OCRmyPDF # OCRmyPDF
# #
FROM debian:bookworm-slim as base FROM ubuntu:22.04 as base
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
ENV TZ=UTC ENV TZ=UTC
@@ -22,7 +22,7 @@ Run with verbosity or higher `-v1` to see more detailed logging. This informatio
**Example file** **Example file**
If your issue is a problem that affects only certain files, and we will require an input file (PDF or image) that demonstrates your issue. If your issue is a problem that affects only certain files, and we will require an input file (PDF or image) that demonstrates your issue.
Please provide an input file with no personal or confidential information. At your option you may [GPG-encrypt the file](https://github.com/jbarlow83/OCRmyPDF/wiki) for OCRmyPDF's author only. Please provide an input file with no personal or confidential information. At your option you may [GPG-encrypt the file](https://github.com/ocrmypdf/OCRmyPDF/wiki) for OCRmyPDF's author only.
Links to files hosted elsewhere are perfectly acceptable. You could also look in ``tests/resources`` and see if any of those files reproduce your issue. Links to files hosted elsewhere are perfectly acceptable. You could also look in ``tests/resources`` and see if any of those files reproduce your issue.
+1 -1
View File
@@ -19,7 +19,7 @@ A clear and concise description of any alternative solutions or features you've
**Example file** **Example file**
If your issue concerns how OCRmyPDF processes certain files, and please provide an example file that helps illustrate how OCRmyPDF's output could be improve. If your issue concerns how OCRmyPDF processes certain files, and please provide an example file that helps illustrate how OCRmyPDF's output could be improve.
Please provide an input file with no personal or confidential information. At your option you may [GPG-encrypt the file](https://github.com/jbarlow83/OCRmyPDF/wiki) for OCRmyPDF's author only. Please provide an input file with no personal or confidential information. At your option you may [GPG-encrypt the file](https://github.com/ocrmypdf/OCRmyPDF/wiki) for OCRmyPDF's author only.
Links to files hosted elsewhere are perfectly acceptable. You could also look in ``tests/resources`` and see if any of those files reproduce your issue. Links to files hosted elsewhere are perfectly acceptable. You could also look in ``tests/resources`` and see if any of those files reproduce your issue.
+2 -4
View File
@@ -1,9 +1,7 @@
<img src="docs/images/logo.svg" width="240" alt="OCRmyPDF"> <img src="docs/images/logo.svg" width="240" alt="OCRmyPDF">
[![Build Status](https://github.com/jbarlow83/OCRmyPDF/actions/workflows/build.yml/badge.svg)](https://github.com/jbarlow83/OCRmyPDF/actions/workflows/build.yml) [![PyPI version][pypi]](https://pypi.org/project/ocrmypdf/) ![Homebrew version][homebrew] ![ReadTheDocs][docs] ![Python versions][pyversions] [![Build Status](https://github.com/ocrmypdf/OCRmyPDF/actions/workflows/build.yml/badge.svg)](https://github.com/ocrmypdf/OCRmyPDF/actions/workflows/build.yml) [![PyPI version][pypi]](https://pypi.org/project/ocrmypdf/) ![Homebrew version][homebrew] ![ReadTheDocs][docs] ![Python versions][pyversions]
[azure]: https://dev.azure.com/jim0585/ocrmypdf/_apis/build/status/jbarlow83.OCRmyPDF?branchName=master
[travis]: https://travis-ci.org/jbarlow83/OCRmyPDF.svg?branch=master "Travis build status"
[pypi]: https://img.shields.io/pypi/v/ocrmypdf.svg "PyPI version" [pypi]: https://img.shields.io/pypi/v/ocrmypdf.svg "PyPI version"
[homebrew]: https://img.shields.io/homebrew/v/ocrmypdf.svg "Homebrew version" [homebrew]: https://img.shields.io/homebrew/v/ocrmypdf.svg "Homebrew version"
[docs]: https://readthedocs.org/projects/ocrmypdf/badge/?version=latest "RTD" [docs]: https://readthedocs.org/projects/ocrmypdf/badge/?version=latest "RTD"
@@ -106,7 +104,7 @@ ocrmypdf --help
Our [documentation is served on Read the Docs](https://ocrmypdf.readthedocs.io/en/latest/index.html). Our [documentation is served on Read the Docs](https://ocrmypdf.readthedocs.io/en/latest/index.html).
Please report issues on our [GitHub issues](https://github.com/jbarlow83/OCRmyPDF/issues) page, and follow the issue template for quick response. Please report issues on our [GitHub issues](https://github.com/ocrmypdf/OCRmyPDF/issues) page, and follow the issue template for quick response.
## Requirements ## Requirements
+1 -1
View File
@@ -1,7 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OCRmyPDF Upstream-Name: OCRmyPDF
Upstream-Contact: James R. Barlow <barlow.jim@gmail.com> Upstream-Contact: James R. Barlow <barlow.jim@gmail.com>
Source: https://github.com/jbarlow83/OCRmyPDF Source: https://github.com/ocrmypdf/OCRmyPDF
Files: * Files: *
Copyright: Copyright:
+5 -5
View File
@@ -67,11 +67,11 @@ without modifying the PDF. This is to ensure that PDFs that were
previously OCRed or were "born digital" rather than scanned are not previously OCRed or were "born digital" rather than scanned are not
processed. processed.
If ``--skip-text`` is issued, then no OCR will be performed on pages If ``--skip-text`` is issued, then no image processing or OCR will be
that already have text. The page will be copied to the output. This may performed on pages that already have text. The page will be copied to
be useful for documents that contain both "born digital" and scanned the output. This may be useful for documents that contain both "born
content, or to use OCRmyPDF to normalize and convert to PDF/A regardless digital" and scanned content, or to use OCRmyPDF to normalize and
of their contents. convert to PDF/A regardless of their contents.
If ``--redo-ocr`` is issued, then a detailed text analysis is performed. If ``--redo-ocr`` is issued, then a detailed text analysis is performed.
Text is categorized as either visible or invisible. Invisible text (OCR) Text is categorized as either visible or invisible. Invisible text (OCR)
+1 -1
View File
@@ -42,7 +42,7 @@ extensions = [
# Extension settings # Extension settings
intersphinx_mapping = {'https://docs.python.org/': None} intersphinx_mapping = {'https://docs.python.org/': None}
napoleon_use_rtype = False napoleon_use_rtype = False
issues_github_path = "jbarlow83/OCRmyPDF" issues_github_path = "ocrmypdf/OCRmyPDF"
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
+8 -7
View File
@@ -243,10 +243,11 @@ You can also optimize all images without performing any OCR:
ocrmypdf --tesseract-timeout=0 --optimize 3 --skip-text input.pdf output.pdf ocrmypdf --tesseract-timeout=0 --optimize 3 --skip-text input.pdf output.pdf
Perform OCR only certain pages Process only certain pages
------------------------------ --------------------------
You can ask OCRmyPDF to only apply OCR to certain pages. You can ask OCRmyPDF to only apply `image processing <#image-processing>`__
and OCR to certain pages.
.. code-block:: bash .. code-block:: bash
@@ -260,10 +261,10 @@ overlap pages. OCRmyPDF does not currently account for document page numbers,
such as an introduction section of a book that uses Roman numerals. It simply such as an introduction section of a book that uses Roman numerals. It simply
counts the number of virtual pieces of paper since the start. counts the number of virtual pieces of paper since the start.
Regardless of the argument to ``--pages``, OCRmyPDF will optimize all pages in Regardless of the argument to ``--pages``, OCRmyPDF will optimize all pages/images
the file and convert it to PDF/A, unless you disable those options. In this in the file and convert it to PDF/A, unless you disable those options. Both of these
example, we want to OCR only the title and otherwise change the PDF as little steps are "whole file" operations. In this example, we want to OCR only the title
as possible: and otherwise change the PDF as little as possible:
.. code-block:: bash .. code-block:: bash
+5 -5
View File
@@ -375,7 +375,7 @@ languages you can optionally install them all:
.. note:: .. note::
Users who previously installed OCRmyPDF from the private tap should Users who previously installed OCRmyPDF from the private tap should
switch to the mainline version (``brew untap jbarlow83/ocrmypdf``) switch to the mainline version (``brew untap ocrmypdf/OCRmyPDF``)
and install from there. and install from there.
Manual installation on macOS Manual installation on macOS
@@ -696,7 +696,7 @@ environment:
.. code-block:: bash .. code-block:: bash
pip3 install git+https://github.com/jbarlow83/OCRmyPDF.git pip3 install git+https://github.com/ocrmypdf/OCRmyPDF.git
Or, to install in `development Or, to install in `development
mode <https://pythonhosted.org/setuptools/setuptools.html#development-mode>`__, mode <https://pythonhosted.org/setuptools/setuptools.html#development-mode>`__,
@@ -704,14 +704,14 @@ allowing customization of OCRmyPDF, use the ``-e`` flag:
.. code-block:: bash .. code-block:: bash
pip3 install -e git+https://github.com/jbarlow83/OCRmyPDF.git pip3 install -e git+https://github.com/ocrmypdf/OCRmyPDF.git
You may find it easiest to install in a virtual environment, rather than You may find it easiest to install in a virtual environment, rather than
system-wide: system-wide:
.. code-block:: bash .. code-block:: bash
git clone -b master https://github.com/jbarlow83/OCRmyPDF.git git clone -b master https://github.com/ocrmypdf/OCRmyPDF.git
python3 -m venv python3 -m venv
source venv/bin/activate source venv/bin/activate
cd OCRmyPDF cd OCRmyPDF
@@ -738,7 +738,7 @@ To install all of the development and test requirements:
.. code-block:: bash .. code-block:: bash
git clone -b master https://github.com/jbarlow83/OCRmyPDF.git git clone -b master https://github.com/ocrmypdf/OCRmyPDF.git
python3 -m venv python3 -m venv
source venv/bin/activate source venv/bin/activate
cd OCRmyPDF cd OCRmyPDF
+3
View File
@@ -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
================ ================
+27
View File
@@ -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
=========== ===========
+1 -1
View File
@@ -44,7 +44,7 @@ necessary.
OCRmyPDF uses setuptools-scm-git-archive to ensure that tarballs downloaded from OCRmyPDF uses setuptools-scm-git-archive to ensure that tarballs downloaded from
GitHub contain version information. Unfortunately, these tarballs are not always GitHub contain version information. Unfortunately, these tarballs are not always
deterministic. See this deterministic. See this
`issue <https://github.com/jbarlow83/OCRmyPDF/issues/841#issuecomment-936562696>`_. `issue <https://github.com/ocrmypdf/OCRmyPDF/issues/841#issuecomment-936562696>`_.
jbig2enc jbig2enc
-------- --------
+20
View File
@@ -18,6 +18,26 @@ 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.5
=======
- Remove upper bound on pdfminer.six version.
- Documentation.
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 v13.4.2
======= =======
+4 -4
View File
@@ -3,7 +3,7 @@ name = ocrmypdf
description = OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched description = OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown
url = https://github.com/jbarlow83/OCRmyPDF url = https://github.com/ocrmypdf/OCRmyPDF
author = James R. Barlow author = James R. Barlow
author_email = james@purplerock.ca author_email = james@purplerock.ca
license = MPL-2.0 license = MPL-2.0
@@ -39,8 +39,8 @@ keywords =
scanning scanning
project_urls = project_urls =
Documentation = https://ocrmypdf.readthedocs.io/ Documentation = https://ocrmypdf.readthedocs.io/
Source = https://github.com/jbarlow83/ocrmypdf Source = https://github.com/ocrmypdf/OCRmyPDF
Tracker = https://github.com/jbarlow83/ocrmypdf/issues Tracker = https://github.com/ocrmypdf/OCRmyPDF/issues
[options] [options]
packages = find: packages = find:
@@ -49,7 +49,7 @@ install_requires =
coloredlogs>=14.0 # strictly optional coloredlogs>=14.0 # strictly optional
img2pdf>=0.3.0,<0.5 # pure Python img2pdf>=0.3.0,<0.5 # pure Python
packaging>=20 packaging>=20
pdfminer.six!=20200720,>=20191110,<=20220319 pdfminer.six!=20200720,>=20191110
pikepdf!=5.0.0,>=4.0.0 pikepdf!=5.0.0,>=4.0.0
pluggy>=0.13.0,<2 pluggy>=0.13.0,<2
reportlab>=3.5.66 reportlab>=3.5.66
+1 -1
View File
@@ -295,7 +295,7 @@ def ocr( # pylint: disable=unused-argument
text already, and settings did not tell us to proceed. text already, and settings did not tell us to proceed.
ocrmypdf.InputFileError: Any other problem with the input file. ocrmypdf.InputFileError: Any other problem with the input file.
ocrmypdf.SubprocessOutputError: Any error related to executing a subprocess. ocrmypdf.SubprocessOutputError: Any error related to executing a subprocess.
ocrmypdf.EncryptedPdfERror: If the input PDF is encrypted (password protected). ocrmypdf.EncryptedPdfError: If the input PDF is encrypted (password protected).
OCRmyPDF does not remove passwords. OCRmyPDF does not remove passwords.
ocrmypdf.TesseractConfigError: If Tesseract reported its configuration was not ocrmypdf.TesseractConfigError: If Tesseract reported its configuration was not
valid. valid.
+18 -6
View File
@@ -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
) )
+1 -1
View File
@@ -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))
+1 -1
View 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
View File
@@ -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',