From c4831ac00c9147f0831c1d8e71b84d34f06c6e45 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 27 Jul 2017 00:11:12 -0700 Subject: [PATCH 01/26] v5.3 release notes --- docs/release_notes.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index f238b84a..cd395cd5 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -6,6 +6,15 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. +v5.3 +---- + +- Added ``--user-words`` and ``--user-patterns`` arguments which are forwarded to Tesseract OCR as words and regular expressions respective to use to guide OCR. Supplying a list of subject-domain words should assist Tesseract with resolving words. (#165) +- Using a non Latin-1 language with the "hocr" renderer now warns about possible OCR quality and recommends workarounds (#176) +- Output file path added to error message when that location is not writable (#175) +- Otherwise valid PDFs with leading whitespace at the beginning of the file are now accepted + + v5.2 ---- From da79e6bac74c74d75dead208d52fc628e19a0258 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 27 Jul 2017 16:00:41 -0700 Subject: [PATCH 02/26] macos: Skip brew audit because it seems to crash ruby on travis --- .travis/osx_brew.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis/osx_brew.sh b/.travis/osx_brew.sh index 69c2a2a4..e5b4b142 100644 --- a/.travis/osx_brew.sh +++ b/.travis/osx_brew.sh @@ -6,7 +6,9 @@ set -x pip3 install homebrew-pypi-poet python3 .travis/autobrew.py cat ocrmypdf.rb -brew audit ocrmypdf.rb + +# brew audit crashes Travis +#brew audit ocrmypdf.rb # Important: disable debug output so token is hidden set +x From 084d2bf8e23a4e4a386941b75ad830dc2c92bfb3 Mon Sep 17 00:00:00 2001 From: jbarlow83 Date: Wed, 23 Aug 2017 23:19:29 -0700 Subject: [PATCH 03/26] More badges --- README.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 9198ba35..680b7bbc 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,12 @@ OCRmyPDF .. image:: https://travis-ci.org/jbarlow83/OCRmyPDF.svg?branch=master :target: https://travis-ci.org/jbarlow83/OCRmyPDF +.. image:: https://img.shields.io/pypi/v/ocrmypdf.svg + :target: https://pypi.org/project/ocrmypdf/ + +.. image:: https://img.shields.io/docker/build/jbarlow83/ocrmypdf.svg + :target: https://hub.docker.com/r/jbarlow83/ocrmypdf/ + OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched or copy-pasted. From be5831a62929ac457198deb121a0c1ebad621138 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 23 Aug 2017 23:29:21 -0700 Subject: [PATCH 04/26] Offer the readme as a long description for new PyPI --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index 43920611..f52f54eb 100644 --- a/setup.py +++ b/setup.py @@ -185,9 +185,15 @@ if 'upload' in sys.argv[1:]: tests_require = open('test_requirements.txt').read().splitlines() + +def readme(): + with open('README.rst') as f: + return f.read() + setup( name='ocrmypdf', description='OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched', + long_description=readme(), url='https://github.com/jbarlow83/OCRmyPDF', author='James R. Barlow', author_email='jim@purplerock.ca', From 5b413e38737dd2e8d830d8748df857ac62446c67 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 23 Aug 2017 23:29:41 -0700 Subject: [PATCH 05/26] Cookbook: add "don't OCR" examples --- docs/cookbook.rst | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index ca14cb16..91a75a54 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -11,7 +11,7 @@ ocrmypdf has built-in help. .. code-block:: bash - ocrmypdf --help + ocrmypdf --help Add an OCR layer and convert to PDF/A @@ -19,21 +19,21 @@ Add an OCR layer and convert to PDF/A .. code-block:: bash - ocrmypdf input.pdf output.pdf + ocrmypdf input.pdf output.pdf Add an OCR layer and output a standard PDF """""""""""""""""""""""""""""""""""""""""" .. code-block:: bash - ocrmypdf --output-type pdf input.pdf output.pdf + ocrmypdf --output-type pdf input.pdf output.pdf Create a PDF/A with all color and grayscale images converted to JPEG """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .. code-block:: bash - ocrmypdf --output-type pdfa --pdfa-image-compression jpeg input.pdf output.pdf + ocrmypdf --output-type pdfa --pdfa-image-compression jpeg input.pdf output.pdf Modify a file in place """""""""""""""""""""" @@ -42,7 +42,7 @@ The file will only be overwritten if OCRmyPDF is successful. .. code-block:: bash - ocrmypdf myfile.pdf myfile.pdf + ocrmypdf myfile.pdf myfile.pdf Correct page rotation """"""""""""""""""""" @@ -51,7 +51,7 @@ OCR will attempt to automatic correct the rotation of each page. This can help f .. code-block:: bash - ocrmypdf --rotate-pages myfile.pdf myfile.pdf + ocrmypdf --rotate-pages myfile.pdf myfile.pdf You can increase (decrease) the parameter ``--rotate-pages-threshold`` to make page rotation more (less) aggressive. @@ -63,8 +63,8 @@ By default OCRmyPDF assumes the document is English. .. code-block:: bash - ocrmypdf -l fre LeParisien.pdf LeParisien.pdf - ocrmypdf -l eng+fre Bilingual-English-French.pdf Bilingual-English-French.pdf + ocrmypdf -l fre LeParisien.pdf LeParisien.pdf + ocrmypdf -l eng+fre Bilingual-English-French.pdf Bilingual-English-French.pdf Language packs must be installed for all languages specified. See :ref:`Installing additional language packs `. @@ -76,7 +76,7 @@ This produces a file named "output.pdf" and a companion text file named "output. .. code-block:: bash - ocrmypdf --sidecar output.txt input.pdf output.pdf + ocrmypdf --sidecar output.txt input.pdf output.pdf OCR images, not PDFs -------------------- @@ -85,7 +85,7 @@ Use a program like `img2pdf `_ to .. code-block:: bash - img2pdf my-images*.jpg | ocrmypdf - myfile.pdf + img2pdf my-images*.jpg | ocrmypdf - myfile.pdf ``img2pdf`` also has features to control the position of images on a page, if desired. @@ -93,7 +93,7 @@ For convenience, OCRmyPDF can convert single images to PDFs on its own. If the r .. code-block:: bash - ocrmypdf --image-dpi 300 image.png myfile.pdf + ocrmypdf --image-dpi 300 image.png myfile.pdf If you have multiple images, you must use ``img2pdf`` to convert the images to PDF. @@ -105,7 +105,7 @@ You can also use Tesseract 3.04+ directly to convert single page images or multi .. code-block:: bash - tesseract my-image.jpg output-prefix pdf + tesseract my-image.jpg output-prefix pdf Image processing ---------------- @@ -124,11 +124,11 @@ OCRmyPDF perform some image processing on each page of a PDF, if desired. The s .. note:: - In many cases image processing will rasterize PDF pages as images, potentially losing quality. + In many cases image processing will rasterize PDF pages as images, potentially losing quality. .. warning:: - ``--clean-final`` and ``-remove-background`` may leave undesirable visual artifacts in some images where their algorithms have shortcomings. Files should be visually reviewed after using these options. + ``--clean-final`` and ``-remove-background`` may leave undesirable visual artifacts in some images where their algorithms have shortcomings. Files should be visually reviewed after using these options. OCR and correct document skew (crooked scan) @@ -138,13 +138,23 @@ Deskew: .. code-block:: bash - ocrmypdf --deskew input.pdf output.pdf + ocrmypdf --deskew input.pdf output.pdf Image processing commands can be combined. The order in which options are given does not matter. OCRmyPDF always applies the steps of the image processing pipeline in the same order (rotate, remove background, deskew, clean). .. code-block:: bash - ocrmypdf --deskew --clean --rotate-pages input.pdf output.pdf + ocrmypdf --deskew --clean --rotate-pages input.pdf output.pdf + + +Don't actually OCR my PDF +""""""""""""""""""""""""" + +If you set ``--tesseract-timeout 0`` OCRmyPDF will apply its image processing without performing OCR, if all you want to is to apply image processing or PDF/A conversion. + +.. code-block:: bash + + ocrmypdf --tesseract-timeout=0 --remove-background input.pdf output.pdf Improving OCR quality From 9bb42c0229dc2a718d61ddf21754f0b48aff9e0a Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 24 Aug 2017 01:07:23 -0700 Subject: [PATCH 06/26] Wrong error type used for missing language --- ocrmypdf/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index 3c3d571a..ddb62dc5 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -322,7 +322,7 @@ def check_options_languages(options, _log): "data for the following requested languages: \n") for lang in (set(options.language) - tesseract.languages()): msg += lang + '\n' - raise argparse.ArgumentError(None, msg) + raise MissingDependencyError(msg) def check_options_output(options, log): From 6d9ddbe98b942958e2ab5067dee8133f3ad88d3d Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 24 Aug 2017 01:09:19 -0700 Subject: [PATCH 07/26] v5.3.1 notes --- docs/release_notes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index cd395cd5..f93396ea 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -6,6 +6,13 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. +v5.3.1 +------ + +- Fixed wrong return code given for missing Tesseract language packs +- Fixed "brew audit" crashing on Travis when trying to auto-brew + + v5.3 ---- From b3097a2384e2c2923a2100680144f2f5a4678d23 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Thu, 24 Aug 2017 13:01:02 -0700 Subject: [PATCH 08/26] Fix broken test case related to language packs --- docs/release_notes.rst | 6 ++++++ tests/test_main.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index f93396ea..47166807 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -6,6 +6,12 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. +v5.3.2 +------ + +- Fixed a broken test case related to language packs + + v5.3.1 ------ diff --git a/tests/test_main.py b/tests/test_main.py index ec255b48..396559ee 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -416,7 +416,7 @@ def test_french(spoof_tesseract_cache, resources, outpdf): def test_klingon(resources, outpdf): p, out, err = run_ocrmypdf( resources / 'francais.pdf', outpdf, '-l', 'klz') - assert p.returncode == ExitCode.bad_args + assert p.returncode == ExitCode.missing_dependency def test_missing_docinfo(spoof_tesseract_noop, resources, outpdf): From f6a4d8f1f808a1c963c85e498a773ef0439db5ed Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 27 Aug 2017 13:53:36 -0700 Subject: [PATCH 09/26] Fix Ubuntu 14.04 install instructions to account for dropping Py3.4 support [ci skip] --- docs/installation.rst | 64 +++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index cf0068d0..dfd0929c 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -214,15 +214,8 @@ follow these steps. Installing on Ubuntu 14.04 LTS ------------------------------ -Installing on Ubuntu 14.04 LTS (trusty) is more difficult than some other options, because of bugs in Python package installation and because OCRmyPDF depends on some packages newer than are available in the main distribution. - -Add new "apt" repositories needed for backports of Ghostscript 9.16, libav-11 (for unpaper 6.1) and Tesseract 4.00 (alpha). This will replace Ghostscript and Tesseract 3.x on your system. If you prefer to not modify your system in this matter, consider using a Docker container. - -.. code-block:: bash - - sudo add-apt-repository ppa:vshn/ghostscript -y - sudo add-apt-repository ppa:heyarje/libav-11 -y - sudo add-apt-repository ppa:alex-p/tesseract-ocr +Installing on Ubuntu 14.04 LTS (trusty) is more difficult than some other options, +because it is older. Update apt-get: @@ -239,39 +232,38 @@ Install system dependencies: zlib1g-dev \ libjpeg-dev \ libffi-dev \ - libavformat56 libavcodec56 libavutil54 \ + qpdf + +We will need backports of Ghostscript 9.16, libav-11 (for unpaper 6.1), +Tesseract 4.00 (alpha), and Python 3.6. This will replace Ghostscript and +Tesseract 3.x on your system. Python 3.6 will be installed alongside the system +Python 3. + +If you prefer to not modify your system in this matter, consider using a Docker container. + +.. code-block:: bash + + sudo add-apt-repository ppa:vshn/ghostscript -y + sudo add-apt-repository ppa:heyarje/libav-11 -y + sudo add-apt-repository ppa:alex-p/tesseract-ocr -y + sudo add-apt-repository ppa:jonathonf/python-3.6 -y + + sudo apt-get update + + sudo apt-get install \ + python3.6 \ ghostscript \ - qpdf \ - python3-pip \ - python3-pil \ - python3-pytest \ - python3-reportlab \ - python3-wheel \ - python3-venv \ tesseract-ocr \ - tesseract-ocr-eng + tesseract-ocr-eng \ + libavformat56 libavcodec56 libavutil54 \ + wget -If you wish install OCRmyPDF to the system Python, then install as follows (note this installs new packages -into your system Python, which could interfere with other programs): +Now we need to install ``pip`` and let it install ocrmypdf: .. code-block:: bash - sudo pip3 install ocrmypdf - -If you wish to install OCRmyPDF to a virtual environment to isolate the system Python, you can -follow these steps. This includes a workaround `for a known, unresolved issue in Ubuntu 14.04's ensurepip -package `_: - -.. code-block:: bash - - sudo apt-get install python3-venv - python3 -m venv venv-ocrmypdf --without-pip - source venv-ocrmypdf/bin/activate - wget -O - -o /dev/null https://bootstrap.pypa.io/get-pip.py | python - deactivate - python3 -m venv --system-site-packages venv-ocrmypdf - source venv-ocrmypdf/bin/activate - pip install ocrmypdf + wget -O - -o /dev/null https://bootstrap.pypa.io/get-pip.py | python3.6 + pip3.6 install ocrmypdf These installation instructions omit the optional dependency ``unpaper``, which is only available at version 0.4.2 in Ubuntu 14.04. The author could not find a backport of ``unpaper``, and created a .deb package to do the job of installing unpaper 6.1 (for x86 64-bit only): From 952f0cca1551c7afe8040ced82175e0fb2f3558f Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 30 Aug 2017 13:25:54 -0700 Subject: [PATCH 10/26] Dockerfiles: set LANG=C.UTF-8 Issue #184 to avoid issue with printing UTF-8 text to sidecar --- Dockerfile | 2 ++ Dockerfile.tess4 | 2 ++ tests/test_main.py | 8 ++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d4ae7981..203fadf4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr-spa \ tesseract-ocr-deu +ENV LANG=C.UTF-8 + RUN python3 -m venv --system-site-packages /appenv # This installs the latest binary wheel instead of the code in the current diff --git a/Dockerfile.tess4 b/Dockerfile.tess4 index 68280554..76e6cc62 100644 --- a/Dockerfile.tess4 +++ b/Dockerfile.tess4 @@ -30,6 +30,8 @@ RUN apt-get update \ tesseract-ocr-rus \ tesseract-ocr-chi-sim +ENV LANG=C.UTF-8 + RUN python3 -m venv --system-site-packages /appenv # This installs the latest binary wheel instead of the code in the current diff --git a/tests/test_main.py b/tests/test_main.py index 396559ee..f14bad20 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -404,9 +404,13 @@ def test_force_ocr_on_pdf_with_no_images(spoof_tesseract_crash, resources, @pytest.mark.skipif( pytest.helpers.is_macos() and pytest.helpers.running_in_travis(), reason="takes too long to install language packs in Travis macOS homebrew") -def test_french(spoof_tesseract_cache, resources, outpdf): +def test_french(spoof_tesseract_cache, resources, outdir): + # Produce a sidecar too - implicit test that system locale is set up + # properly + sidecar = outdir / 'francais.txt' p, out, err = run_ocrmypdf( - resources / 'francais.pdf', outpdf, '-l', 'fra', + resources / 'francais.pdf', outdir / 'francais.pdf', '-l', 'fra', + '--sidecar', sidecar, env=spoof_tesseract_cache) print(os.environ) assert p.returncode == ExitCode.ok, \ From d04e43d46d96526acdd5533ad77c62d41d3db50d Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 1 Sep 2017 01:00:32 -0700 Subject: [PATCH 11/26] Update copyright info for test files [ci skip] --- tests/resources/README.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/resources/README.rst b/tests/resources/README.rst index 29a803e8..afa1ce19 100644 --- a/tests/resources/README.rst +++ b/tests/resources/README.rst @@ -88,14 +88,18 @@ under the terms of the license in LICENSE.rst. * - overlay.pdf - @maxandersen - PDF file generated by PDFPen pro that triggered content stream parse errors - * - no_conentes.pdf + * - no_contents.pdf - @jbarlow83 - synthetic PDF with a blank page that has no /Contents entry + * - crom.png + - @jbarlow83 + - test for non-dictionary words + Assemblies ========== -These test resources are assemblies from other previously mentioned files, released under the same license terms as their input files. +These test resources are assemblies or derivatives from other previously mentioned files, released under the same license terms as their input files. - cardinal.pdf (four cardinal directions, baked-in rotated copies of LinnSequencer.jpg) - ccitt.pdf (LinnSequencer.jpg, converted to CCITT encoding) @@ -107,6 +111,9 @@ These test resources are assemblies from other previously mentioned files, relea - rotated_skew.pdf (a /Rotate'd and skewed document from LinnSequencer.jpg) - skew.pdf (from LinnSequencer.jpg, skew simulated by adjusting the transformation matrix) - skew-encrypted.pdf (skew.pdf with encryption - access supported by PyPDF2) +- baiona_gray.png (from baiona.png) +- poster.pdf (from LinnSequencer.jpg) + .. _`Wikimedia: LinnSequencer`: https://upload.wikimedia.org/wikipedia/en/b/b7/LinnSequencer_hardware_MIDI_sequencer_brochure_page_2_300dpi.jpg From 4ed1aa4d23e86b06f64420e40bc8caaa14d14bd1 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 1 Sep 2017 12:47:22 -0700 Subject: [PATCH 12/26] Release notes: fix indentation --- docs/release_notes.rst | 479 ++++++++++++++++++++--------------------- 1 file changed, 239 insertions(+), 240 deletions(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 47166807..58bdf5f2 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -5,7 +5,6 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. - v5.3.2 ------ @@ -53,9 +52,9 @@ v5.0 - Backward incompatible changes - + Support for Python 3.4 dropped. Python 3.5 is now required. - + Support for Tesseract 3.02 and 3.03 dropped. Tesseract 3.04 or newer is required. Tesseract 4.00 (alpha) is supported. - + The OCRmyPDF.sh script was removed. + + Support for Python 3.4 dropped. Python 3.5 is now required. + + Support for Tesseract 3.02 and 3.03 dropped. Tesseract 3.04 or newer is required. Tesseract 4.00 (alpha) is supported. + + The OCRmyPDF.sh script was removed. - Add a new feature, ``--sidecar``, which allows creating "sidecar" text files which contain the OCR results in plain text. These OCR text is more reliable than extracting text from PDFs. Closes #126. - New feature: ``--pdfa-image-compression``, which allows overriding Ghostscript's lossy-or-lossless image encoding heuristic and making all images JPEG encoded or lossless encoded as desired. Fixes #163. @@ -89,242 +88,242 @@ v4.5.4 v4.5.3 ------ -- Added a workaround for Ghostscript 9.21 and probably earlier versions would fail with the error message "VMerror -25", due to a Ghostscript bug in XMP metadata handling -- High Unicode characters (U+10000 and up) are no longer accepted for setting metadata on the command line, as Ghostscript may not handle them correctly. -- Fixed an issue where the ``tess4`` renderer would duplicate content onto output pages if tesseract failed or timed out -- Fixed ``tess4`` renderer not recognized when lossless reconstruction is possible +- Added a workaround for Ghostscript 9.21 and probably earlier versions would fail with the error message "VMerror -25", due to a Ghostscript bug in XMP metadata handling +- High Unicode characters (U+10000 and up) are no longer accepted for setting metadata on the command line, as Ghostscript may not handle them correctly. +- Fixed an issue where the ``tess4`` renderer would duplicate content onto output pages if tesseract failed or timed out +- Fixed ``tess4`` renderer not recognized when lossless reconstruction is possible v4.5.2 ------ -- Fix issue #147. ``--pdf-renderer tess4 --clean`` will produce an oversized page containing the original image in the bottom left corner, due to loss DPI information. -- Make "using Tesseract 4.0" warning less ominous -- Set up machinery for homebrew OCRmyPDF tap +- Fix issue #147. ``--pdf-renderer tess4 --clean`` will produce an oversized page containing the original image in the bottom left corner, due to loss DPI information. +- Make "using Tesseract 4.0" warning less ominous +- Set up machinery for homebrew OCRmyPDF tap v4.5.1 ------ -- Fix issue #137, proportions of images with a non-square pixel aspect ratio would be distorted in output for ``--force-ocr`` and some other combinations of flags +- Fix issue #137, proportions of images with a non-square pixel aspect ratio would be distorted in output for ``--force-ocr`` and some other combinations of flags v4.5 ---- -- Exotic PDFs containing "Form XObjects" are now supported (issue #134; PDF reference manual 8.10), and images they contain are taken into account when determining the resolution for rasterizing -- The Tesseract 4 Docker image no longer includes all languages, because it took so long to build something would tend to fail -- OCRmyPDF now warns about using ``--pdf-renderer tesseract`` with Tesseract 3.04 or lower due to issues with Ghostscript corrupting the OCR text in these cases +- Exotic PDFs containing "Form XObjects" are now supported (issue #134; PDF reference manual 8.10), and images they contain are taken into account when determining the resolution for rasterizing +- The Tesseract 4 Docker image no longer includes all languages, because it took so long to build something would tend to fail +- OCRmyPDF now warns about using ``--pdf-renderer tesseract`` with Tesseract 3.04 or lower due to issues with Ghostscript corrupting the OCR text in these cases v4.4.2 ------ -- The Docker images (ocrmypdf, ocrmypdf-polyglot, ocrmypdf-tess4) are now based on Ubuntu 16.10 instead of Debian stretch +- The Docker images (ocrmypdf, ocrmypdf-polyglot, ocrmypdf-tess4) are now based on Ubuntu 16.10 instead of Debian stretch - + This makes supporting the Tesseract 4 image easier - + This could be a disruptive change for any Docker users who built customized these images with their own changes, and made those changes in a way that depends on Debian and not Ubuntu + + This makes supporting the Tesseract 4 image easier + + This could be a disruptive change for any Docker users who built customized these images with their own changes, and made those changes in a way that depends on Debian and not Ubuntu -- OCRmyPDF now prevents running the Tesseract 4 renderer with Tesseract 3.04, which was permitted in v4.4 and v4.4.1 but will not work +- OCRmyPDF now prevents running the Tesseract 4 renderer with Tesseract 3.04, which was permitted in v4.4 and v4.4.1 but will not work v4.4.1 ------ -- To prevent a `TIFF output error `_ caused by img2pdf >= 0.2.1 and Pillow <= 3.4.2, dependencies have been tightened -- The Tesseract 4.00 simultaneous process limit was increased from 1 to 2, since it was observed that 1 lowers performance -- Documentation improvements to describe the ``--tesseract-config`` feature -- Added test cases and fixed error handling for ``--tesseract-config`` -- Tweaks to setup.py to deal with issues in the v4.4 release +- To prevent a `TIFF output error `_ caused by img2pdf >= 0.2.1 and Pillow <= 3.4.2, dependencies have been tightened +- The Tesseract 4.00 simultaneous process limit was increased from 1 to 2, since it was observed that 1 lowers performance +- Documentation improvements to describe the ``--tesseract-config`` feature +- Added test cases and fixed error handling for ``--tesseract-config`` +- Tweaks to setup.py to deal with issues in the v4.4 release v4.4 ---- -- Tesseract 4.00 is now supported on an experimental basis. +- Tesseract 4.00 is now supported on an experimental basis. - + A new rendering option ``--pdf-renderer tess4`` exploits Tesseract 4's new text-only output PDF mode. See the documentation on PDF Renderers for details. - + The ``--tesseract-oem`` argument allows control over the Tesseract 4 OCR engine mode (tesseract's ``--oem``). Use ``--tesseract-oem 2`` to enforce the new LSTM mode. - + Fixed poor performance with Tesseract 4.00 on Linux + + A new rendering option ``--pdf-renderer tess4`` exploits Tesseract 4's new text-only output PDF mode. See the documentation on PDF Renderers for details. + + The ``--tesseract-oem`` argument allows control over the Tesseract 4 OCR engine mode (tesseract's ``--oem``). Use ``--tesseract-oem 2`` to enforce the new LSTM mode. + + Fixed poor performance with Tesseract 4.00 on Linux -- Fixed an issue that caused corruption of output to stdout in some cases -- Removed test for Pillow JPEG and PNG support, as the minimum supported version of Pillow now enforces this -- OCRmyPDF now tests that the intended destination file is writable before proceeding -- The test suite now requires ``pytest-helpers-namespace`` to run (but not install) -- Significant code reorganization to make OCRmyPDF re-entrant and improve performance. All changes should be backward compatible for the v4.x series. +- Fixed an issue that caused corruption of output to stdout in some cases +- Removed test for Pillow JPEG and PNG support, as the minimum supported version of Pillow now enforces this +- OCRmyPDF now tests that the intended destination file is writable before proceeding +- The test suite now requires ``pytest-helpers-namespace`` to run (but not install) +- Significant code reorganization to make OCRmyPDF re-entrant and improve performance. All changes should be backward compatible for the v4.x series. - + However, OCRmyPDF's dependency "ruffus" is not re-entrant, so no Python API is available. Scripts should continue to use the command line interface. + + However, OCRmyPDF's dependency "ruffus" is not re-entrant, so no Python API is available. Scripts should continue to use the command line interface. v4.3.5 ------ -- Update documentation to confirm Python 3.6.0 compatibility. No code changes were needed, so many earlier versions are likely supported. +- Update documentation to confirm Python 3.6.0 compatibility. No code changes were needed, so many earlier versions are likely supported. v4.3.4 ------ -- Fixed "decimal.InvalidOperation: quantize result has too many digits" for high DPI images +- Fixed "decimal.InvalidOperation: quantize result has too many digits" for high DPI images v4.3.3 ------ -- Fixed PDF/A creation with Ghostscript 9.20 properly -- Fixed an exception on inline stencil masks with a missing optional parameter +- Fixed PDF/A creation with Ghostscript 9.20 properly +- Fixed an exception on inline stencil masks with a missing optional parameter v4.3.2 ------ -- Fixed a PDF/A creation issue with Ghostscript 9.20 (note: this fix did not actually work) +- Fixed a PDF/A creation issue with Ghostscript 9.20 (note: this fix did not actually work) v4.3.1 ------ -- Fixed an issue where pages produced by the "hocr" renderer after a Tesseract timeout would be rotated incorrectly if the input page was rotated with a /Rotate marker -- Fixed a file handle leak in LeptonicaErrorTrap that would cause a "too many open files" error for files around hundred pages of pages long when ``--deskew`` or ``--remove-background`` or other Leptonica based image processing features were in use, depending on the system value of ``ulimit -n`` -- Ability to specify multiple languages for multilingual documents is now advertised in documentation -- Reduced the file sizes of some test resources -- Cleaned up debug output -- Tesseract caching in test cases is now more cautious about false cache hits and reproducing exact output, not that any problems were observed +- Fixed an issue where pages produced by the "hocr" renderer after a Tesseract timeout would be rotated incorrectly if the input page was rotated with a /Rotate marker +- Fixed a file handle leak in LeptonicaErrorTrap that would cause a "too many open files" error for files around hundred pages of pages long when ``--deskew`` or ``--remove-background`` or other Leptonica based image processing features were in use, depending on the system value of ``ulimit -n`` +- Ability to specify multiple languages for multilingual documents is now advertised in documentation +- Reduced the file sizes of some test resources +- Cleaned up debug output +- Tesseract caching in test cases is now more cautious about false cache hits and reproducing exact output, not that any problems were observed v4.3 ---- -- New feature ``--remove-background`` to detect and erase the background of color and grayscale images -- Better documentation -- Fixed an issue with PDFs that draw images when the raster stack depth is zero -- ocrmypdf can now redirect its output to stdout for use in a shell pipeline +- New feature ``--remove-background`` to detect and erase the background of color and grayscale images +- Better documentation +- Fixed an issue with PDFs that draw images when the raster stack depth is zero +- ocrmypdf can now redirect its output to stdout for use in a shell pipeline - + This does not improve performance since temporary files are still used for buffering - + Some output validation is disabled in this mode + + This does not improve performance since temporary files are still used for buffering + + Some output validation is disabled in this mode v4.2.5 ------ -- Fixed an issue (#100) with PDFs that omit the optional /BitsPerComponent parameter on images -- Removed non-free file milk.pdf +- Fixed an issue (#100) with PDFs that omit the optional /BitsPerComponent parameter on images +- Removed non-free file milk.pdf v4.2.4 ------ -- Fixed an error (#90) caused by PDFs that use stencil masks properly -- Fixed handling of PDFs that try to draw images or stencil masks without properly setting up the graphics state (such images are now ignored for the purposes of calculating DPI) +- Fixed an error (#90) caused by PDFs that use stencil masks properly +- Fixed handling of PDFs that try to draw images or stencil masks without properly setting up the graphics state (such images are now ignored for the purposes of calculating DPI) v4.2.3 ------ -- Fixed an issue with PDFs that store page rotation (/Rotate) in an indirect object -- Integrated a few fixes to simplify downstream packaging (Debian) +- Fixed an issue with PDFs that store page rotation (/Rotate) in an indirect object +- Integrated a few fixes to simplify downstream packaging (Debian) - + The test suite no longer assumes it is installed - + If running Linux, skip a test that passes Unicode on the command line + + The test suite no longer assumes it is installed + + If running Linux, skip a test that passes Unicode on the command line -- Added a test case to check explicit masks and stencil masks -- Added a test case for indirect objects and linearized PDFs -- Deprecated the OCRmyPDF.sh shell script +- Added a test case to check explicit masks and stencil masks +- Added a test case for indirect objects and linearized PDFs +- Deprecated the OCRmyPDF.sh shell script v4.2.2 ------ -- Improvements to documentation +- Improvements to documentation v4.2.1 ------ -- Fixed an issue where PDF pages that contained stencil masks would report an incorrect DPI and cause Ghostscript to abort -- Implemented stdin streaming +- Fixed an issue where PDF pages that contained stencil masks would report an incorrect DPI and cause Ghostscript to abort +- Implemented stdin streaming v4.2 ---- -- ocrmypdf will now try to convert single image files to PDFs if they are provided as input (#15) +- ocrmypdf will now try to convert single image files to PDFs if they are provided as input (#15) - + This is a basic convenience feature. It only supports a single image and always makes the image fill the whole page. - + For better control over image to PDF conversion, use ``img2pdf`` (one of ocrmypdf's dependencies) + + This is a basic convenience feature. It only supports a single image and always makes the image fill the whole page. + + For better control over image to PDF conversion, use ``img2pdf`` (one of ocrmypdf's dependencies) -- New argument ``--output-type {pdf|pdfa}`` allows disabling Ghostscript PDF/A generation +- New argument ``--output-type {pdf|pdfa}`` allows disabling Ghostscript PDF/A generation - + ``pdfa`` is the default, consistent with past behavior - + ``pdf`` provides a workaround for users concerned about the increase in file size from Ghostscript forcing JBIG2 images to CCITT and transcoding JPEGs - + ``pdf`` preserves as much as it can about the original file, including problems that PDF/A conversion fixes + + ``pdfa`` is the default, consistent with past behavior + + ``pdf`` provides a workaround for users concerned about the increase in file size from Ghostscript forcing JBIG2 images to CCITT and transcoding JPEGs + + ``pdf`` preserves as much as it can about the original file, including problems that PDF/A conversion fixes -- PDFs containing images with "non-square" pixel aspect ratios, such as 200x100 DPI, are now handled and converted properly (fixing a bug that caused to be cropped) -- ``--force-ocr`` rasterizes pages even if they contain no images +- PDFs containing images with "non-square" pixel aspect ratios, such as 200x100 DPI, are now handled and converted properly (fixing a bug that caused to be cropped) +- ``--force-ocr`` rasterizes pages even if they contain no images - + supports users who want to use OCRmyPDF to reconstruct text information in PDFs with damaged Unicode maps (copy and paste text does not match displayed text) - + supports reinterpreting PDFs where text was rendered as curves for printing, and text needs to be recovered - + fixes issue #82 + + supports users who want to use OCRmyPDF to reconstruct text information in PDFs with damaged Unicode maps (copy and paste text does not match displayed text) + + supports reinterpreting PDFs where text was rendered as curves for printing, and text needs to be recovered + + fixes issue #82 -- Fixes an issue where, with certain settings, monochrome images in PDFs would be converted to 8-bit grayscale, increasing file size (#79) -- Support for Ubuntu 12.04 LTS "precise" has been dropped in favor of (roughly) Ubuntu 14.04 LTS "trusty" +- Fixes an issue where, with certain settings, monochrome images in PDFs would be converted to 8-bit grayscale, increasing file size (#79) +- Support for Ubuntu 12.04 LTS "precise" has been dropped in favor of (roughly) Ubuntu 14.04 LTS "trusty" - + Some Ubuntu "PPAs" (backports) are needed to make it work - -- Support for some older dependencies dropped + + Some Ubuntu "PPAs" (backports) are needed to make it work - + Ghostscript 9.15 or later is now required (available in Ubuntu trusty with backports) - + Tesseract 3.03 or later is now required (available in Ubuntu trusty) +- Support for some older dependencies dropped -- Ghostscript now runs in "safer" mode where possible + + Ghostscript 9.15 or later is now required (available in Ubuntu trusty with backports) + + Tesseract 3.03 or later is now required (available in Ubuntu trusty) + +- Ghostscript now runs in "safer" mode where possible v4.1.4 ------ -- Bug fix: monochrome images with an ICC profile attached were incorrectly converted to full color images if lossless reconstruction was not possible due to other settings; consequence was increased file size for these images +- Bug fix: monochrome images with an ICC profile attached were incorrectly converted to full color images if lossless reconstruction was not possible due to other settings; consequence was increased file size for these images v4.1.3 ------ -- More helpful error message for PDFs with version 4 security handler -- Update usage instructions for Windows/Docker users -- Fix order of operations for matrix multiplication (no effect on most users) -- Add a few leptonica wrapper functions (no effect on most users) +- More helpful error message for PDFs with version 4 security handler +- Update usage instructions for Windows/Docker users +- Fix order of operations for matrix multiplication (no effect on most users) +- Add a few leptonica wrapper functions (no effect on most users) v4.1.2 ------ -- Replace IEC sRGB ICC profile with Debian's sRGB (from icc-profiles-free) which is more compatible with the MIT license -- More helpful error message for an error related to certain types of malformed PDFs +- Replace IEC sRGB ICC profile with Debian's sRGB (from icc-profiles-free) which is more compatible with the MIT license +- More helpful error message for an error related to certain types of malformed PDFs v4.1 ---- -- ``--rotate-pages`` now only rotates pages when reasonably confidence in the orientation. This behavior can be adjusted with the new argument ``--rotate-pages-threshold`` -- Fixed problems in error checking if ``unpaper`` is uninstalled or missing at run-time -- Fixed problems with "RethrownJobError" errors during error handling that suppressed the useful error messages +- ``--rotate-pages`` now only rotates pages when reasonably confidence in the orientation. This behavior can be adjusted with the new argument ``--rotate-pages-threshold`` +- Fixed problems in error checking if ``unpaper`` is uninstalled or missing at run-time +- Fixed problems with "RethrownJobError" errors during error handling that suppressed the useful error messages v4.0.7 ------ -- Minor correction to Ghostscript output settings +- Minor correction to Ghostscript output settings v4.0.6 ------ -- Update install instructions -- Provide a sRGB profile instead of using Ghostscript's +- Update install instructions +- Provide a sRGB profile instead of using Ghostscript's v4.0.5 ------ -- Remove some verbose debug messages from v4.0.4 -- Fixed temporary that wasn't being deleted -- DPI is now calculated correctly for cropped images, along with other image transformations -- Inline images are now checked during DPI calculation instead of rejecting the image +- Remove some verbose debug messages from v4.0.4 +- Fixed temporary that wasn't being deleted +- DPI is now calculated correctly for cropped images, along with other image transformations +- Inline images are now checked during DPI calculation instead of rejecting the image v4.0.4 ------ @@ -338,16 +337,16 @@ v4.0.3 New features ^^^^^^^^^^^^ -- Page orientations detected are now reported in a summary comment +- Page orientations detected are now reported in a summary comment Fixes ^^^^^ -- Show stack trace if unexpected 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 +- Show stack trace if unexpected 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 @@ -356,10 +355,10 @@ v4.0.2 Fixes ^^^^^ -- Fixed compatibility with Tesseract 3.04.01 release, particularly its different way of outputting - orientation information -- Improved handling of Tesseract errors and crashes -- Fixed use of chmod on Docker that broke most test cases +- Fixed compatibility with Tesseract 3.04.01 release, particularly its different way of outputting + orientation information +- Improved handling of Tesseract errors and crashes +- Fixed use of chmod on Docker that broke most test cases v4.0.1 @@ -368,7 +367,7 @@ v4.0.1 Fixes ^^^^^ -- Fixed a KeyError if tesseract fails to find page orientation information +- Fixed a KeyError if tesseract fails to find page orientation information v4.0 @@ -377,33 +376,33 @@ v4.0 New features ^^^^^^^^^^^^ -- Automatic page rotation (``-r``) is now available. It uses ignores any prior rotation information - on PDFs and sets rotation based on the dominant orientation of detectable text. This feature is - fairly reliable but some false positives occur especially if there is not much text to work with. (#4) -- Deskewing is now performed using Leptonica instead of unpaper. Leptonica is faster and more reliable - at image deskewing than unpaper. +- Automatic page rotation (``-r``) is now available. It uses ignores any prior rotation information + on PDFs and sets rotation based on the dominant orientation of detectable text. This feature is + fairly reliable but some false positives occur especially if there is not much text to work with. (#4) +- Deskewing is now performed using Leptonica instead of unpaper. Leptonica is faster and more reliable + at image deskewing than unpaper. Fixes ^^^^^ -- Fixed an issue where lossless reconstruction could cause some pages to be appear incorrectly - if the page was rotated by the user in Acrobat after being scanned (specifically if it a /Rotate tag) -- Fixed an issue where lossless reconstruction could misalign the graphics layer with respect to - text layer if the page had been cropped such that its origin is not (0, 0) (#49) +- Fixed an issue where lossless reconstruction could cause some pages to be appear incorrectly + if the page was rotated by the user in Acrobat after being scanned (specifically if it a /Rotate tag) +- Fixed an issue where lossless reconstruction could misalign the graphics layer with respect to + text layer if the page had been cropped such that its origin is not (0, 0) (#49) Changes ^^^^^^^ -- Logging output is now much easier to read -- ``--deskew`` is now performed by Leptonica instead of unpaper (#25) -- libffi is now required -- Some changes were made to the Docker and Travis build environments to support libffi -- ``--pdf-renderer=tesseract`` now displays a warning if the Tesseract version is less than 3.04.01, - the planned release that will include fixes to an important OCR text rendering bug in Tesseract 3.04.00. - You can also manually install ./share/sharp2.ttf on top of pdf.ttf in your Tesseract tessdata folder - to correct the problem. +- Logging output is now much easier to read +- ``--deskew`` is now performed by Leptonica instead of unpaper (#25) +- libffi is now required +- Some changes were made to the Docker and Travis build environments to support libffi +- ``--pdf-renderer=tesseract`` now displays a warning if the Tesseract version is less than 3.04.01, + the planned release that will include fixes to an important OCR text rendering bug in Tesseract 3.04.00. + You can also manually install ./share/sharp2.ttf on top of pdf.ttf in your Tesseract tessdata folder + to correct the problem. v3.2.1 @@ -412,8 +411,8 @@ v3.2.1 Changes ^^^^^^^ -- Fixed issue #47 "convert() got and unexpected keyword argument 'dpi'" by upgrading to img2pdf 0.2 -- Tweaked the Dockerfiles +- Fixed issue #47 "convert() got and unexpected keyword argument 'dpi'" by upgrading to img2pdf 0.2 +- Tweaked the Dockerfiles v3.2 @@ -422,19 +421,19 @@ v3.2 New features ^^^^^^^^^^^^ -- Lossless reconstruction: when possible, OCRmyPDF will inject text layers without - otherwise manipulating the content and layout of a PDF page. For example, a PDF containing a mix - of vector and raster content would see the vector content preserved. Images may still be transcoded - during PDF/A conversion. (``--deskew`` and ``--clean-final`` disable this mode, necessarily.) -- New argument ``--tesseract-pagesegmode`` allows you to pass page segmentation arguments to Tesseract OCR. - This helps for two column text and other situations that confuse Tesseract. -- Added a new "polyglot" version of the Docker image, that generates Tesseract with all languages packs installed, - for the polyglots among us. It is much larger. +- Lossless reconstruction: when possible, OCRmyPDF will inject text layers without + otherwise manipulating the content and layout of a PDF page. For example, a PDF containing a mix + of vector and raster content would see the vector content preserved. Images may still be transcoded + during PDF/A conversion. (``--deskew`` and ``--clean-final`` disable this mode, necessarily.) +- New argument ``--tesseract-pagesegmode`` allows you to pass page segmentation arguments to Tesseract OCR. + This helps for two column text and other situations that confuse Tesseract. +- Added a new "polyglot" version of the Docker image, that generates Tesseract with all languages packs installed, + for the polyglots among us. It is much larger. Changes ^^^^^^^ -- JPEG transcoding quality is now 95 instead of the default 75. Bigger file sizes for less degradation. +- JPEG transcoding quality is now 95 instead of the default 75. Bigger file sizes for less degradation. @@ -444,7 +443,7 @@ v3.1.1 Changes ^^^^^^^ -- Fixed bug that caused incorrect page size and DPI calculations on documents with mixed page sizes +- Fixed bug that caused incorrect page size and DPI calculations on documents with mixed page sizes v3.1 ---- @@ -452,17 +451,17 @@ v3.1 Changes ^^^^^^^ -- Default output format is now PDF/A-2b instead of PDF/A-1b -- Python 3.5 and macOS El Capitan are now supported platforms - no changes were - needed to implement support -- Improved some error messages related to missing input files -- Fixed issue #20 - uppercase .PDF extension not accepted -- Fixed an issue where OCRmyPDF failed to text that certain pages contained previously OCR'ed text, - such as OCR text produced by Tesseract 3.04 -- Inserts /Creator tag into PDFs so that errors can be traced back to this project -- Added new option ``--pdf-renderer=auto``, to let OCRmyPDF pick the best PDF renderer. - Currently it always chooses the 'hocrtransform' renderer but that behavior may change. -- Set up Travis CI automatic integration testing +- Default output format is now PDF/A-2b instead of PDF/A-1b +- Python 3.5 and macOS El Capitan are now supported platforms - no changes were + needed to implement support +- Improved some error messages related to missing input files +- Fixed issue #20 - uppercase .PDF extension not accepted +- Fixed an issue where OCRmyPDF failed to text that certain pages contained previously OCR'ed text, + such as OCR text produced by Tesseract 3.04 +- Inserts /Creator tag into PDFs so that errors can be traced back to this project +- Added new option ``--pdf-renderer=auto``, to let OCRmyPDF pick the best PDF renderer. + Currently it always chooses the 'hocrtransform' renderer but that behavior may change. +- Set up Travis CI automatic integration testing v3.0 ---- @@ -470,55 +469,55 @@ v3.0 New features ^^^^^^^^^^^^ -- Easier installation with a Docker container or Python's ``pip`` package manager -- Eliminated many external dependencies, so it's easier to setup -- Now installs ``ocrmypdf`` to ``/usr/local/bin`` or equivalent for system-wide - access and easier typing -- Improved command line syntax and usage help (``--help``) -- Tesseract 3.03+ PDF page rendering can be used instead for better positioning - of recognized text (``--pdf-renderer tesseract``) -- PDF metadata (title, author, keywords) are now transferred to the - output PDF -- PDF metadata can also be set from the command line (``--title``, etc.) -- Automatic repairs malformed input PDFs if possible -- Added test cases to confirm everything is working -- Added option to skip extremely large pages that take too long to OCR and are - often not OCRable (e.g. large scanned maps or diagrams); other pages are still - processed (``--skip-big``) -- Added option to kill Tesseract OCR process if it seems to be taking too long on - a page, while still processing other pages (``--tesseract-timeout``) -- Less common colorspaces (CMYK, palette) are now supported by conversion to RGB -- Multiple images on the same PDF page are now supported +- Easier installation with a Docker container or Python's ``pip`` package manager +- Eliminated many external dependencies, so it's easier to setup +- Now installs ``ocrmypdf`` to ``/usr/local/bin`` or equivalent for system-wide + access and easier typing +- Improved command line syntax and usage help (``--help``) +- Tesseract 3.03+ PDF page rendering can be used instead for better positioning + of recognized text (``--pdf-renderer tesseract``) +- PDF metadata (title, author, keywords) are now transferred to the + output PDF +- PDF metadata can also be set from the command line (``--title``, etc.) +- Automatic repairs malformed input PDFs if possible +- Added test cases to confirm everything is working +- Added option to skip extremely large pages that take too long to OCR and are + often not OCRable (e.g. large scanned maps or diagrams); other pages are still + processed (``--skip-big``) +- Added option to kill Tesseract OCR process if it seems to be taking too long on + a page, while still processing other pages (``--tesseract-timeout``) +- Less common colorspaces (CMYK, palette) are now supported by conversion to RGB +- Multiple images on the same PDF page are now supported Changes ^^^^^^^ -- New, robust rewrite in Python 3.4+ with ruffus_ pipelines -- Now uses Ghostscript 9.14's improved color conversion model to preserve PDF colors -- OCR text is now rendered in the PDF as invisible text. Previous versions of OCRmyPDF - incorrectly rendered visible text with an image on top. -- All "tasks" in the pipeline can be executed in parallel on any - available CPUs, increasing performance -- The ``-o DPI`` argument has been phased out, in favor of ``--oversample DPI``, in - case we need ``-o OUTPUTFILE`` in the future -- Removed several dependencies, so it's easier to install. We no - longer use: - - - GNU parallel_ - - ImageMagick_ - - Python 2.7 - - Poppler - - MuPDF_ tools - - shell scripts - - Java and JHOVE_ - - libxml2 +- New, robust rewrite in Python 3.4+ with ruffus_ pipelines +- Now uses Ghostscript 9.14's improved color conversion model to preserve PDF colors +- OCR text is now rendered in the PDF as invisible text. Previous versions of OCRmyPDF + incorrectly rendered visible text with an image on top. +- All "tasks" in the pipeline can be executed in parallel on any + available CPUs, increasing performance +- The ``-o DPI`` argument has been phased out, in favor of ``--oversample DPI``, in + case we need ``-o OUTPUTFILE`` in the future +- Removed several dependencies, so it's easier to install. We no + longer use: + + - GNU parallel_ + - ImageMagick_ + - Python 2.7 + - Poppler + - MuPDF_ tools + - shell scripts + - Java and JHOVE_ + - libxml2 -- Some new external dependencies are required or optional, compared to v2.x: +- Some new external dependencies are required or optional, compared to v2.x: - - Ghostscript 9.14+ - - qpdf_ 5.0.0+ - - Unpaper_ 6.1 (optional) - - some automatically managed Python packages + - Ghostscript 9.14+ + - qpdf_ 5.0.0+ + - Unpaper_ 6.1 (optional) + - some automatically managed Python packages .. _ruffus: http://www.ruffus.org.uk/index.html .. _parallel: https://www.gnu.org/software/parallel/ @@ -531,87 +530,87 @@ Changes Release candidates ^^^^^^^^^^^^^^^^^^ -- rc9: +- rc9: - - fix issue #118: report error if ghostscript iccprofiles are missing - - fixed another issue related to #111: PDF rasterized to palette file - - add support image files with a palette - - don't try to validate PDF file after an exception occurs + - fix issue #118: report error if ghostscript iccprofiles are missing + - fixed another issue related to #111: PDF rasterized to palette file + - add support image files with a palette + - don't try to validate PDF file after an exception occurs -- rc8: +- rc8: - - fix issue #111: exception thrown if PDF is missing DocumentInfo dictionary + - fix issue #111: exception thrown if PDF is missing DocumentInfo dictionary -- rc7: +- rc7: - - fix error when installing direct from pip, "no such file 'requirements.txt'" + - fix error when installing direct from pip, "no such file 'requirements.txt'" -- rc6: +- rc6: - - dropped libxml2 (Python lxml) since Python 3's internal XML parser is sufficient - - set up Docker container - - fix Unicode errors if recognized text contains Unicode characters and system locale is not UTF-8 + - dropped libxml2 (Python lxml) since Python 3's internal XML parser is sufficient + - set up Docker container + - fix Unicode errors if recognized text contains Unicode characters and system locale is not UTF-8 -- rc5: +- rc5: - - dropped Java and JHOVE in favour of qpdf - - improved command line error output - - additional tests and bug fixes - - tested on Ubuntu 14.04 LTS + - dropped Java and JHOVE in favour of qpdf + - improved command line error output + - additional tests and bug fixes + - tested on Ubuntu 14.04 LTS -- rc4: +- rc4: - - dropped MuPDF in favour of qpdf - - fixed some installer issues and errors in installation instructions - - improve performance: run Ghostscript with multithreaded rendering - - improve performance: use multiple cores by default - - bug fix: checking for wrong exception on process timeout + - dropped MuPDF in favour of qpdf + - fixed some installer issues and errors in installation instructions + - improve performance: run Ghostscript with multithreaded rendering + - improve performance: use multiple cores by default + - bug fix: checking for wrong exception on process timeout -- rc3: skipping version number intentionally to avoid confusion with Tesseract -- rc2: first release for public testing to test-PyPI, Github -- rc1: testing release process +- rc3: skipping version number intentionally to avoid confusion with Tesseract +- rc2: first release for public testing to test-PyPI, Github +- rc1: testing release process Compatibility notes ------------------- -- ``./OCRmyPDF.sh`` script is still available for now -- Stacking the verbosity option like ``-vvv`` is no longer supported +- ``./OCRmyPDF.sh`` script is still available for now +- Stacking the verbosity option like ``-vvv`` is no longer supported -- The configuration file ``config.sh`` has been removed. Instead, you can - feed a file to the arguments for common settings: +- The configuration file ``config.sh`` has been removed. Instead, you can + feed a file to the arguments for common settings: :: - ocrmypdf input.pdf output.pdf @settings.txt + ocrmypdf input.pdf output.pdf @settings.txt where ``settings.txt`` contains *one argument per line*, for example: :: - -l - deu - --author - A. Merkel - --pdf-renderer - tesseract + -l + deu + --author + A. Merkel + --pdf-renderer + tesseract Fixes ^^^^^ -- Handling of filenames containing spaces: fixed +- Handling of filenames containing spaces: fixed Notes and known issues ^^^^^^^^^^^^^^^^^^^^^^ -- Some dependencies may work with lower versions than tested, so try - overriding dependencies if they are "in the way" to see if they work. +- Some dependencies may work with lower versions than tested, so try + overriding dependencies if they are "in the way" to see if they work. -- ``--pdf-renderer tesseract`` will output files with an incorrect page size in Tesseract 3.03, - due to a bug in Tesseract. +- ``--pdf-renderer tesseract`` will output files with an incorrect page size in Tesseract 3.03, + due to a bug in Tesseract. -- PDF files containing "inline images" are not supported and won't be for the 3.0 release. Scanned - images almost never contain inline images. +- PDF files containing "inline images" are not supported and won't be for the 3.0 release. Scanned + images almost never contain inline images. v2.2-stable (2014-09-29) From 82ebd8ef1a86f3e551cc59b822aa7ff267143880 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 1 Sep 2017 12:50:36 -0700 Subject: [PATCH 13/26] Fix missing error message about trying to use sandwich on old tesseract --- ocrmypdf/__main__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index ddb62dc5..f82d488c 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -332,6 +332,11 @@ def check_options_output(options, log): else: options.pdf_renderer = 'hocr' + if options.pdf_renderer == 'sandwich' and not tesseract.has_textonly_pdf(): + raise MissingDependencyError( + "The 'sandwich' renderer requires Tesseract 3.05.01 or newer; " + "or Tesseract 4.00 alpha newer than February 2017.") + if options.pdf_renderer == 'tess4': log.warning("The 'tess4' PDF renderer has been renamed to 'sandwich'. " "Please use --pdf-renderer=sandwich.") From bafd08391dcb0d84a0ea12443824860b6af5ba70 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 1 Sep 2017 12:50:45 -0700 Subject: [PATCH 14/26] Update release notes --- docs/release_notes.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 58bdf5f2..97f1fd8d 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -5,6 +5,15 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. + +next +---- + +- Fix missing error message that should occur when trying to force ``--pdf-renderer sandwich`` on old versions of Tesseract +- Update copyright information in test files +- Set system ``LANG`` to UTF-8 in Dockerfiles to avoid UTF-8 encoding errors + + v5.3.2 ------ From 6af7d61ee55dce0e161e1ffd36953c04283d3664 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 1 Sep 2017 16:17:26 -0700 Subject: [PATCH 15/26] Fix CI failure due to spoofers not being updated to Tesseract 3.05 strings --- .travis.yml | 1 + docs/release_notes.rst | 6 +++--- tests/spoof/tesseract_big_image_error.py | 10 +++++----- tests/spoof/tesseract_crash.py | 9 +++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index eff3a563..82e46b1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,7 @@ install: script: - mv ocrmypdf dont_import_this_ocrmypdf +- tesseract --version - pytest -n auto - mv dont_import_this_ocrmypdf ocrmypdf diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 97f1fd8d..a6241f98 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -6,10 +6,10 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. -next ----- +v5.3.3 +------ -- Fix missing error message that should occur when trying to force ``--pdf-renderer sandwich`` on old versions of Tesseract +- Fixed missing error message that should occur when trying to force ``--pdf-renderer sandwich`` on old versions of Tesseract - Update copyright information in test files - Set system ``LANG`` to UTF-8 in Dockerfiles to avoid UTF-8 encoding errors diff --git a/tests/spoof/tesseract_big_image_error.py b/tests/spoof/tesseract_big_image_error.py index 63cbe6e4..d4aeae3d 100755 --- a/tests/spoof/tesseract_big_image_error.py +++ b/tests/spoof/tesseract_big_image_error.py @@ -4,9 +4,9 @@ import sys -VERSION_STRING = '''tesseract 3.04.00 - leptonica-1.72 - libjpeg 8d : libpng 1.6.19 : libtiff 4.0.6 : zlib 1.2.5 +VERSION_STRING = '''tesseract 3.05.01 + leptonica-1.74.4 + libjpeg 9b : libpng 1.6.32 : libtiff 4.0.8 : zlib 1.2.8 SPOOFED: return error claiming image too big ''' @@ -20,10 +20,10 @@ def main(): print(VERSION_STRING, file=sys.stderr) sys.exit(0) elif sys.argv[1] == '--list-langs': - print('List of available languages (1):\neng', file=sys.stderr) + print('List of available languages (1):\neng\n', file=sys.stderr) sys.exit(0) elif sys.argv[1] == '--print-parameters': - print('A parameter list would go here', file=sys.stderr) + print('A parameter list would go here\ntextonly_pdf 0\n', file=sys.stderr) sys.exit(0) elif sys.argv[-2] == 'hocr': print("Image too large: (33830, 14959)\n" diff --git a/tests/spoof/tesseract_crash.py b/tests/spoof/tesseract_crash.py index 42b4550c..bf3d71ae 100755 --- a/tests/spoof/tesseract_crash.py +++ b/tests/spoof/tesseract_crash.py @@ -5,9 +5,9 @@ import os import signal -VERSION_STRING = '''tesseract 3.04.00 - leptonica-1.72 - libjpeg 8d : libpng 1.6.19 : libtiff 4.0.6 : zlib 1.2.5 +VERSION_STRING = '''tesseract 3.05.01 + leptonica-1.74.4 + libjpeg 9b : libpng 1.6.32 : libtiff 4.0.8 : zlib 1.2.8 SPOOFED: CRASH ON OCR or -psm 0 ''' @@ -30,7 +30,8 @@ def main(): print('List of available languages (1):\neng', file=sys.stderr) sys.exit(0) elif sys.argv[1] == '--print-parameters': - print('List of parameters would go here', file=sys.stderr) + print('A parameter list would go here\ntextonly_pdf 0\n', + file=sys.stderr) sys.exit(0) elif sys.argv[-2] == 'hocr': print("KABOOM! Tesseract failed for some reason", file=sys.stderr) From 922dbe83c3023bcb506ad24820e26f4126033c0c Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sat, 2 Sep 2017 20:05:57 -0700 Subject: [PATCH 16/26] Update MANIFEST rules --- MANIFEST.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 8f3cdf7f..8a43420d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,8 +7,7 @@ include dev_requirements.txt include .git_archival.txt # docker -include Dockerfile -include Dockerfile.polyglot +include Dockerfile* include .dockerignore # tests @@ -38,6 +37,10 @@ recursive-exclude docs/_build * recursive-include ocrmypdf/data * include *.py exclude tasks.py +exclude debug-runner.py +recursive-exclude .travis * +exclude .travis* + # code recursive-include ocrmypdf *.py From 1467d118ab08c45ab970b772dadd1fdfc259ed6c Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 6 Sep 2017 00:27:02 -0700 Subject: [PATCH 17/26] Add more leptonica functions --- ocrmypdf/lib/compile_leptonica.py | 33 +++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ocrmypdf/lib/compile_leptonica.py b/ocrmypdf/lib/compile_leptonica.py index be9a5a4a..6273d4bb 100644 --- a/ocrmypdf/lib/compile_leptonica.py +++ b/ocrmypdf/lib/compile_leptonica.py @@ -183,10 +183,39 @@ pixColorMagnitude(PIX *pixs, l_int32 bwhite, l_int32 type); -void +PIX * +pixMaskOverColorPixels(PIX *pixs, + l_int32 threshdiff, + l_int32 mindist); + +l_int32 +pixGetAverageMaskedRGB(PIX *pixs, + PIX *pixm, + l_int32 x, + l_int32 y, + l_int32 factor, + l_int32 type, + l_float32 *prval, + l_float32 *pgval, + l_float32 *pbval); + +PIX * +pixGlobalNormRGB(PIX * pixd, + PIX * pixs, + l_int32 rval, + l_int32 gval, + l_int32 bval, + l_int32 mapval); + +PIX * +pixInvert(PIX * pixd, + PIX * pixs); + +void boxDestroy(BOX **pbox); -void lept_free(void *ptr); +void +lept_free(void *ptr); """) From 87c2ed8b276904555cbe33db69ea56d1b2f66b07 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 12 Sep 2017 14:34:53 -0700 Subject: [PATCH 18/26] Improve clarity of --pdf-renderer=tesseract deprecation warning --- ocrmypdf/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index f82d488c..687302a8 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -343,13 +343,18 @@ def check_options_output(options, log): options.pdf_renderer = 'sandwich' if options.pdf_renderer == 'tesseract': - log.warning("The 'tesseract' PDF renderer is deprecated.") if tesseract.version() < '3.05' and options.output_type == 'pdfa': log.warning( "For best results use --pdf-renderer=tesseract " "--output-type=pdf to disable PDF/A generation via " "Ghostscript, which is known to corrupt the OCR text of " "some PDFs produced your version of Tesseract.") + elif tesseract.has_textonly_pdf(): + log.warning( + "The argument --pdf-renderer=tesseract provides support for " + "versions of tesseract older than your version. For best " + "results omit this argument and let OCRmyPDF choose the " + "best available renderer.") if options.debug_rendering and options.pdf_renderer != 'hocr': log.info( From 34fc1f5fd78d35740cfffa8b5f9a2b2fb92a6e6e Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 13 Sep 2017 01:19:18 -0700 Subject: [PATCH 19/26] Add reminder that blank.pdf is not trivial --- tests/resources/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/README.rst b/tests/resources/README.rst index afa1ce19..c495ebdf 100644 --- a/tests/resources/README.rst +++ b/tests/resources/README.rst @@ -57,7 +57,7 @@ under the terms of the license in LICENSE.rst. - test image with 200 x 100 DPI resolution * - blank.pdf - @jbarlow83 - - blank PDF + - blank PDF generated by Adobe Illustrator CC 17, containing a lot of application-specific metadata/bloat * - cmyk.pdf - @jbarlow83 - a CMYK image created in Photoshop From aed9814345e6b0223402307c81b59f10e994c8fc Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 8 Oct 2017 12:13:20 -0700 Subject: [PATCH 20/26] Use Ubuntu 17.04 instead of 16.10 for Docker image (issue #191) Due to 16.10 PPAs no longer being generated by alex-p --- Dockerfile | 3 +-- Dockerfile.tess4 | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 203fadf4..2154a7ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ # OCRmyPDF # -# VERSION 4.4.2 -FROM ubuntu:16.10 +FROM ubuntu:17.04 MAINTAINER James R. Barlow RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/Dockerfile.tess4 b/Dockerfile.tess4 index 76e6cc62..0d116edb 100644 --- a/Dockerfile.tess4 +++ b/Dockerfile.tess4 @@ -1,7 +1,6 @@ # OCRmyPDF # -# VERSION 4.4.2 -FROM ubuntu:16.10 +FROM ubuntu:17.04 MAINTAINER James R. Barlow RUN apt-get update && apt-get install -y --no-install-recommends \ From 82cea2fd858eddba50ea74d7443063cd6368fb5a Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 8 Oct 2017 12:34:36 -0700 Subject: [PATCH 21/26] Update batch processing docs to include Synology script --- docs/batch.rst | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/docs/batch.rst b/docs/batch.rst index f466086f..d897d362 100644 --- a/docs/batch.rst +++ b/docs/batch.rst @@ -90,13 +90,83 @@ This user contributed script also provides an example of batch processing. API """ -OCRmyPDF is currently supported as a command line interface. Due to limitations in one of the libraries OCRmyPDF depends on, it is not yet usable as an API. +OCRmyPDF is currently supported as a command line interface. This means that even if you are using OCRmyPDF in a Python script, you should run it in a subprocess rather importing the ocrmypdf package. + +The reason for this limitation is that the `ruffus `_ library that OCRmyPDF depends on is unfortunately not reentrant. OCRmyPDF works by defining each operation it does as a ruffus task that takes one or more files as input and generates one or more files as output. As such ruffus is fairly fundamental. + +(If you find individual functions implemented in OCRmyPDF useful (such as ``ocrmypdf.pdfinfo``), you can use these if you wish to.) + + +Synology DiskStations +""""""""""""""""""""" + +Synology DiskStations (Network Attached Storage devices) can run the Docker image of OCRmyPDF if the Synology `Docker package `_ is installed. Attached is a script to address particular quirks of using OCRmyPDF on one of these devices. + +This is only possible for x86-based Synology products. Some Synology products use ARM or Power processors and do not support Docker. Further adjustments might be needed to deal with the Synology's relatively limited CPU and RAM. + +.. code-block:: python + + #!/bin/env python3 + # Contributed by github.com/Enantiomerie + + # script needs 2 arguments + # 1. source dir with *.pdf - default is location of script + # 2. move dir where *.pdf and *_OCR.pdf are moved to + + import logging + import os + import subprocess + import sys + import time + import shutil + + script_dir = os.path.dirname(os.path.realpath(__file__)) + timestamp = time.strftime("%Y-%m-%d-%H%M_") + log_file = script_dir + '/' + timestamp + 'ocrmypdf.log' + logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s', filename=log_file, filemode='w') + + if len(sys.argv) > 1: + start_dir = sys.argv[1] + else: + start_dir = '.' + + for dir_name, subdirs, file_list in os.walk(start_dir): + logging.info('\n') + logging.info(dir_name + '\n') + os.chdir(dir_name) + for filename in file_list: + file_ext = os.path.splitext(filename)[1] + if file_ext == '.pdf': + full_path = dir_name + '/' + filename + file_noext = os.path.splitext(filename)[0] + timestamp_OCR = time.strftime("%Y-%m-%d-%H%M_OCR_") + filename_OCR = timestamp_OCR + file_noext + '.pdf' + docker_mount = dir_name + ':/home/docker' + # create string for pdf processing + # diskstation needs a user:group docker:docker. find uid:gid of your diskstation docker:docker with id docker. + # use this uid:gid in -u flag + # rw rights for docker:docker at source dir are also necessary + # the script is processed as root user via chron + cmd = ['docker', 'run', '--rm', '-v', docker_mount, '-u="1030:65538"', 'jbarlow83/ocrmypdf', , '--deskew' , filename, filename_OCR] + logging.info(cmd) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + result = proc.stdout.read() + logging.info(result) + full_path_OCR = dir_name + '/' + filename_OCR + os.chmod(full_path_OCR, 0o666) + os.chmod(full_path, 0o666) + full_path_OCR_archive = sys.argv[2] + full_path_archive = sys.argv[2] + '/no_ocr' + shutil.move(full_path_OCR,full_path_OCR_archive) + shutil.move(full_path, full_path_archive) + logging.info('Finished.\n') + Huge batch jobs """"""""""""""" -If you have thousands of files to work with, contact the author. +If you have thousands of files to work with, contact the author. Consulting work related to OCRmyPDF helps fund this open source project and all inquiries are appreciated. Hot (watched) folders From 571de0e36885d2e2fb1ae9e20da12f0ce78a5689 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 8 Oct 2017 12:41:03 -0700 Subject: [PATCH 22/26] Update release notes --- docs/release_notes.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index a6241f98..518cef17 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -5,6 +5,12 @@ OCRmyPDF uses `semantic versioning `_ for its command line i The OCRmyPDF package itself does not contain a public API, although it is fairly stable and breaking changes are usually timed with a major release. A future release will clearly define the stable public API. +v5.3.4 +------ + +- Change wording of a deprecation warning to improve clarity +- Update documentation + v5.3.3 ------ From 5372656893689f948b9c72e69b6c8b54785c2a4d Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 9 Oct 2017 16:17:42 -0700 Subject: [PATCH 23/26] Don't say tess4 support is experimental - it's pretty good now --- ocrmypdf/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ocrmypdf/__main__.py b/ocrmypdf/__main__.py index 687302a8..5784fb6e 100755 --- a/ocrmypdf/__main__.py +++ b/ocrmypdf/__main__.py @@ -427,7 +427,7 @@ def check_options_ocr_behavior(options, log): def check_options_advanced(options, log): if tesseract.v4(): log.info( - "Tesseract v4.x.alpha found. OCRmyPDF support is experimental.") + "Tesseract v4.x.alpha found.") if options.tesseract_oem and not tesseract.v4(): log.warning( "--tesseract-oem requires Tesseract 4.x -- argument ignored") From b00c9a562d60b9e826c9b332bcef61764d72395e Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 9 Oct 2017 16:18:02 -0700 Subject: [PATCH 24/26] Remove meaningless version from Dockerfile.polyglot --- Dockerfile.polyglot | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile.polyglot b/Dockerfile.polyglot index f5accb4f..e9198d38 100644 --- a/Dockerfile.polyglot +++ b/Dockerfile.polyglot @@ -1,6 +1,5 @@ # OCRmyPDF polyglot # -# VERSION 4.4.2 FROM jbarlow83/ocrmypdf:latest MAINTAINER James R. Barlow From ef5d320e06f463360bb46f0230ae1fabafb945f9 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 9 Oct 2017 16:19:41 -0700 Subject: [PATCH 25/26] Ignore .vscode too --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c5dfd745..2406a7f8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,5 @@ tests/cache/ tests/output/ tests/resources/private/ tmp/ -pdfbox-app*.jar \ No newline at end of file +pdfbox-app*.jar +.vscode/ \ No newline at end of file From 9498601a376990ed8313a02a16d5fa24805df20f Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 10 Oct 2017 12:13:20 -0700 Subject: [PATCH 26/26] Add docs on adding to docker iamge --- docs/languages.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/languages.rst b/docs/languages.rst index 11582e97..5587fb35 100644 --- a/docs/languages.rst +++ b/docs/languages.rst @@ -33,6 +33,34 @@ Docker users Users of the Docker image may use the alternative :ref:`"polyglot" container ` which includes all languages. +Adding individual language packs to a Docker image +"""""""""""""""""""""""""""""""""""""""""""""""""" + +If you wish to add a single language pack, you could do the following: + +* Download the desired ``.trainedata`` file from the `tessdata `_ repository. Let's use Hebrew in this example (``heb.traineddata``) + +* Copy the file to ``/home/user/downloads/heb.traineddata``. + +* Create a new container based on the ocrmypdf-tess4 image and jump into it with a terminal: + +.. code-block:: bash + + host$ docker run -v /home/user/downloads:/home/docker -it --entrypoint /bin/bash ocrmypdf-tess4 + +* Put the file where Tesseract expects it: + +.. code-block:: bash + + docker$ cp /home/docker/heb.traineddata /usr/share/tesseract-ocr/tessdata + +* Note the container id, and save it as a new image (in this example, ``ocrmypdf-tess4-heb``) + +.. code-block:: bash + + host$ docker commit ocrmypdf-tess4-heb + + Known limitations -----------------