Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f072e91120 | ||
|
|
efa2bca8a3 | ||
|
|
b039010d3e | ||
|
|
3f7cefcf5d | ||
|
|
45f97d1565 | ||
|
|
1281f8eb68 | ||
|
|
9ef61864fb | ||
|
|
90b2119ad3 | ||
|
|
f0cc7f2230 | ||
|
|
d60a384aab | ||
|
|
14a6093636 | ||
|
|
54b42d73ab | ||
|
|
9abed14f1f | ||
|
|
d09f61d4fe | ||
|
|
4a0130649e | ||
|
|
a0224d94ca | ||
|
|
9e7b9de830 | ||
|
|
08fc5fc01d | ||
|
|
110c75cba2 | ||
|
|
5afca3f342 | ||
|
|
d9eb0ba7ef | ||
|
|
46d0978a09 | ||
|
|
4e35100978 |
@@ -57,6 +57,7 @@ RUN add-apt-repository -y ppa:alex-p/tesseract-ocr-devel
|
|||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ghostscript \
|
ghostscript \
|
||||||
|
jbig2dec \
|
||||||
img2pdf \
|
img2pdf \
|
||||||
libsm6 libxext6 libxrender-dev \
|
libsm6 libxext6 libxrender-dev \
|
||||||
pngquant \
|
pngquant \
|
||||||
|
|||||||
+1
-7
@@ -1,5 +1,3 @@
|
|||||||
# SPDX-FileCopyrightText: 2022 James R. Barlow
|
|
||||||
# SPDX-License-Identifier: CC-BY-SA-4.0
|
|
||||||
---
|
---
|
||||||
name: Feature request
|
name: Feature request
|
||||||
about: Suggest an idea for this project
|
about: Suggest an idea for this project
|
||||||
@@ -19,11 +17,7 @@ A clear and concise description of what you want to happen.
|
|||||||
A clear and concise description of any alternative solutions or features you've considered. Please include the versions of OCRmyPDF and other supporting programs (Tesseract OCR, Ghostscript) - maybe an alternative already exists in a newer version.
|
A clear and concise description of any alternative solutions or features you've considered. Please include the versions of OCRmyPDF and other supporting programs (Tesseract OCR, Ghostscript) - maybe an alternative already exists in a newer version.
|
||||||
|
|
||||||
**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. You could also look in ``tests/resources`` and see if any of those files 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/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.
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context or screenshots about the feature request here.
|
Add any other context or screenshots about the feature request here.
|
||||||
+2
-3
@@ -1,9 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2022 James R. Barlow
|
|
||||||
# SPDX-License-Identifier: CC-BY-SA-4.0
|
|
||||||
---
|
---
|
||||||
name: General issues
|
name: General issues
|
||||||
about: Installation, packages, dependencies, "nothing works", test suite failures...
|
about: Installation, packages, dependencies, "nothing works", test suite failures...
|
||||||
title: ''
|
title: "[BUG]"
|
||||||
labels: ''
|
labels: ''
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
@@ -25,6 +23,7 @@ If applicable, add screenshots to help explain your problem.
|
|||||||
- OS:
|
- OS:
|
||||||
- Python version:
|
- Python version:
|
||||||
- OCRmyPDF version:
|
- OCRmyPDF version:
|
||||||
|
- Platform: x64 or ARM
|
||||||
|
|
||||||
**Installation**
|
**Installation**
|
||||||
How did you install OCRmyPDF? Did you install it from your operating system's
|
How did you install OCRmyPDF? Did you install it from your operating system's
|
||||||
+2
-4
@@ -1,9 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2022 James R. Barlow
|
|
||||||
# SPDX-License-Identifier: CC-BY-SA-4.0
|
|
||||||
---
|
---
|
||||||
name: Problem with a specific input file
|
name: Problem with specific file
|
||||||
about: Something went wrong while trying to OCR a specific file
|
about: Something went wrong while trying to OCR a specific file
|
||||||
title: ''
|
title: "[BUG]"
|
||||||
labels: ''
|
labels: ''
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
python: "3.10"
|
python: "3.10"
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
python: "3.11.0-rc.2 - 3.11.0"
|
python: "3.11"
|
||||||
# - os: ubuntu-latest
|
# - os: ubuntu-latest
|
||||||
# python: "pypy3.8"
|
# python: "pypy3.8"
|
||||||
#- os: ubuntu-latest
|
#- os: ubuntu-latest
|
||||||
@@ -122,7 +122,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest]
|
os: [macos-latest]
|
||||||
python: ["3.9", "3.10"] # 2022-09-20: pikepdf/lxml not available for cp311
|
python: ["3.10", "3.11"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
OS: ${{ matrix.os }}
|
OS: ${{ matrix.os }}
|
||||||
@@ -133,12 +133,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
|
fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
|
||||||
name: Install Python
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python }}
|
|
||||||
|
|
||||||
- name: Install Homebrew deps
|
- name: Install Homebrew deps
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
brew update
|
brew update
|
||||||
brew install \
|
brew install \
|
||||||
@@ -149,6 +145,11 @@ jobs:
|
|||||||
pngquant \
|
pngquant \
|
||||||
tesseract
|
tesseract
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
name: Install Python
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
|
||||||
- name: Install Python packages
|
- name: Install Python packages
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip wheel
|
python -m pip install --upgrade pip wheel
|
||||||
@@ -177,7 +178,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest]
|
os: [windows-latest]
|
||||||
python: ["3.9", "3.10"] # 2022-09-20: pikepdf/lxml not available for cp311
|
python: ["3.10", "3.11"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
OS: ${{ matrix.os }}
|
OS: ${{ matrix.os }}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Copyright: (C) 2022 James R. Barlow
|
|||||||
License: MPL-2.0
|
License: MPL-2.0
|
||||||
|
|
||||||
Files:
|
Files:
|
||||||
|
.github/ISSUE_TEMPLATE/*.md
|
||||||
docs/images/macos-workflow.png
|
docs/images/macos-workflow.png
|
||||||
Copyright: (C) 2022 James R. Barlow
|
Copyright: (C) 2022 James R. Barlow
|
||||||
License: CC-BY-SA-4.0
|
License: CC-BY-SA-4.0
|
||||||
|
|||||||
+1
-1
@@ -160,7 +160,7 @@ Changing tesseract configuration variables
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
You can override tesseract's default `control
|
You can override tesseract's default `control
|
||||||
parameters <https://github.com/tesseract-ocr/tesseract/wiki/ControlParams>`__
|
parameters <https://tesseract-ocr.github.io/tessdoc/tess3/ControlParams.html>`__
|
||||||
with a configuration file.
|
with a configuration file.
|
||||||
|
|
||||||
As an example, this configuration will disable Tesseract's dictionary
|
As an example, this configuration will disable Tesseract's dictionary
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ processors. To maximize parallelism without overloading your system with
|
|||||||
processes, consider using ``parallel -j 2`` to limit parallel to running
|
processes, consider using ``parallel -j 2`` to limit parallel to running
|
||||||
two jobs at once.
|
two jobs at once.
|
||||||
|
|
||||||
This command will run all ocrmypdf all files named ``*.pdf`` in the
|
This command will run ``ocrmypdf`` on all files named ``*.pdf`` in the
|
||||||
current directory and write them to the previous created ``output/``
|
current directory and write them to the previously created ``output/``
|
||||||
folder. It will not search subdirectories.
|
folder. It will not search subdirectories.
|
||||||
|
|
||||||
The ``--tag`` argument tells parallel to print the filename as a prefix
|
The ``--tag`` argument tells parallel to print the filename as a prefix
|
||||||
|
|||||||
@@ -375,8 +375,8 @@ Native Windows
|
|||||||
You must install the following for Windows:
|
You must install the following for Windows:
|
||||||
|
|
||||||
* Python 3.8 (64-bit) or later
|
* Python 3.8 (64-bit) or later
|
||||||
* Tesseract 4.1.1 or later
|
* Tesseract 4.1.1 (64-bit) or later
|
||||||
* Ghostscript 9.50 or later
|
* Ghostscript 9.50 (64-bit) or later
|
||||||
|
|
||||||
Using the `Chocolatey <https://chocolatey.org/>`_ package manager, install the
|
Using the `Chocolatey <https://chocolatey.org/>`_ package manager, install the
|
||||||
following when running in an Administrator command prompt:
|
following when running in an Administrator command prompt:
|
||||||
@@ -395,10 +395,8 @@ Administrator.):
|
|||||||
|
|
||||||
* ``pip install ocrmypdf``
|
* ``pip install ocrmypdf``
|
||||||
|
|
||||||
Chocolatey automatically selects appropriate versions of these applications. If you
|
Chocolatey automatically selects appropriate versions of these applications. Please make sure
|
||||||
are installing them manually, please install 64-bit versions of all applications for
|
you are installing the 64-bit versions.
|
||||||
64-bit Windows, or 32-bit versions of all applications for 32-bit Windows. Mixing
|
|
||||||
the "bitness" of these programs will lead to errors.
|
|
||||||
|
|
||||||
OCRmyPDF will check the Windows Registry and standard locations in your Program Files
|
OCRmyPDF will check the Windows Registry and standard locations in your Program Files
|
||||||
for third party software it needs (specifically, Tesseract and Ghostscript). To
|
for third party software it needs (specifically, Tesseract and Ghostscript). To
|
||||||
@@ -413,6 +411,10 @@ to change the PATH.
|
|||||||
Please download Python from Python.org or Chocolatey instead, and do not use the
|
Please download Python from Python.org or Chocolatey instead, and do not use the
|
||||||
Microsoft Store version.
|
Microsoft Store version.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
32-bit Windows might work, but is not supported.
|
||||||
|
|
||||||
Windows Subsystem for Linux
|
Windows Subsystem for Linux
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
@@ -636,7 +638,7 @@ system-wide:
|
|||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
git clone -b master https://github.com/ocrmypdf/OCRmyPDF.git
|
git clone -b master https://github.com/ocrmypdf/OCRmyPDF.git
|
||||||
python3 -m venv
|
python3 -m venv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
cd OCRmyPDF
|
cd OCRmyPDF
|
||||||
pip install .
|
pip install .
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ OCRmyPDF analyzes each page of a PDF to determine the colorspace and
|
|||||||
resolution (DPI) needed to capture all of the information on that page
|
resolution (DPI) needed to capture all of the information on that page
|
||||||
without losing content. It uses
|
without losing content. It uses
|
||||||
`Ghostscript <http://ghostscript.com/>`__ to rasterize the page, and
|
`Ghostscript <http://ghostscript.com/>`__ to rasterize the page, and
|
||||||
then performs on OCR the rasterized image to create an OCR "layer".
|
then performs OCR on the rasterized image to create an OCR "layer".
|
||||||
The layer is then grafted back onto the original PDF.
|
The layer is then grafted back onto the original PDF.
|
||||||
|
|
||||||
While one can use a program like Ghostscript or ImageMagick to get an
|
While one can use a program like Ghostscript or ImageMagick to get an
|
||||||
|
|||||||
@@ -28,6 +28,20 @@ tagged yet.
|
|||||||
|
|
||||||
.. |OCRmyPDF PyPI| image:: https://img.shields.io/pypi/v/ocrmypdf.svg
|
.. |OCRmyPDF PyPI| image:: https://img.shields.io/pypi/v/ocrmypdf.svg
|
||||||
|
|
||||||
|
v14.0.2
|
||||||
|
=======
|
||||||
|
|
||||||
|
- Fixed :issue:`1052`, an exception on attempting to process certain nonconforming PDFs.
|
||||||
|
- Explicitly documented that Windows 32-bit is no longer supported.
|
||||||
|
- Fixed source installation instructions.
|
||||||
|
- Other documentation fixes.
|
||||||
|
|
||||||
|
v14.0.1
|
||||||
|
=======
|
||||||
|
|
||||||
|
- Fixed some version checks done with smart version comparison.
|
||||||
|
- Added missing jbig2dec to Docker image.
|
||||||
|
|
||||||
v14.0.0
|
v14.0.0
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ def execute_ocrmypdf(file_path):
|
|||||||
elif ON_SUCCESS_ARCHIVE:
|
elif ON_SUCCESS_ARCHIVE:
|
||||||
log.info(f'OCR is done. Archiving {file_path.name} to {ARCHIVE_DIRECTORY}')
|
log.info(f'OCR is done. Archiving {file_path.name} to {ARCHIVE_DIRECTORY}')
|
||||||
shutil.move(file_path, f'{ARCHIVE_DIRECTORY}/{file_path.name}')
|
shutil.move(file_path, f'{ARCHIVE_DIRECTORY}/{file_path.name}')
|
||||||
|
else:
|
||||||
|
log.info('OCR is done')
|
||||||
else:
|
else:
|
||||||
log.info('OCR is done')
|
log.info('OCR is done')
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from os import fspath
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import PIPE, CalledProcessError
|
from subprocess import PIPE, CalledProcessError
|
||||||
|
|
||||||
|
from packaging.version import Version
|
||||||
from PIL import Image, UnidentifiedImageError
|
from PIL import Image, UnidentifiedImageError
|
||||||
|
|
||||||
from ocrmypdf.exceptions import SubprocessOutputError
|
from ocrmypdf.exceptions import SubprocessOutputError
|
||||||
@@ -186,8 +187,8 @@ def generate_pdfa(
|
|||||||
]
|
]
|
||||||
|
|
||||||
strategy = 'LeaveColorUnchanged'
|
strategy = 'LeaveColorUnchanged'
|
||||||
gs_version = version()
|
gs_version = Version(version())
|
||||||
if gs_version == '9.56.0':
|
if gs_version == Version('9.56.0'):
|
||||||
# 9.56.0 breaks our OCR, should be fixed in 9.56.1
|
# 9.56.0 breaks our OCR, should be fixed in 9.56.1
|
||||||
# https://bugs.ghostscript.com/show_bug.cgi?id=705187
|
# https://bugs.ghostscript.com/show_bug.cgi?id=705187
|
||||||
compression_args.append('-dNEWPDF=false')
|
compression_args.append('-dNEWPDF=false')
|
||||||
|
|||||||
@@ -477,14 +477,12 @@ def _image_xobjects(container) -> Iterator[tuple[Object, str]]:
|
|||||||
resources = container['/Resources']
|
resources = container['/Resources']
|
||||||
if '/XObject' not in resources:
|
if '/XObject' not in resources:
|
||||||
return
|
return
|
||||||
xobjs = resources['/XObject'].as_dict()
|
for key, candidate in resources['/XObject'].items():
|
||||||
for xobj in xobjs:
|
if candidate is None or '/Subtype' not in candidate:
|
||||||
candidate: Object = xobjs[xobj]
|
|
||||||
if '/Subtype' not in candidate:
|
|
||||||
continue
|
continue
|
||||||
if candidate['/Subtype'] == '/Image':
|
if candidate['/Subtype'] == '/Image':
|
||||||
pdfimage = candidate
|
pdfimage = candidate
|
||||||
yield (pdfimage, xobj)
|
yield (pdfimage, key)
|
||||||
|
|
||||||
|
|
||||||
def _find_regular_images(
|
def _find_regular_images(
|
||||||
|
|||||||
+3
-5
@@ -15,7 +15,7 @@ import pytest
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import ocrmypdf
|
import ocrmypdf
|
||||||
from ocrmypdf._exec import ghostscript, tesseract
|
from ocrmypdf._exec import tesseract
|
||||||
from ocrmypdf.exceptions import ExitCode, MissingDependencyError
|
from ocrmypdf.exceptions import ExitCode, MissingDependencyError
|
||||||
from ocrmypdf.pdfa import file_claims_pdfa
|
from ocrmypdf.pdfa import file_claims_pdfa
|
||||||
from ocrmypdf.pdfinfo import Colorspace, Encoding, PdfInfo
|
from ocrmypdf.pdfinfo import Colorspace, Encoding, PdfInfo
|
||||||
@@ -178,7 +178,8 @@ def test_maximum_options(renderer, output_type, multipage, outpdf):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
tesseract.version() >= '5', reason="tess 5 tries harder to find its files"
|
tesseract.TesseractVersion(tesseract.version()) >= tesseract.TesseractVersion('5'),
|
||||||
|
reason="tess 5 tries harder to find its files",
|
||||||
)
|
)
|
||||||
def test_tesseract_missing_tessdata(monkeypatch, resources, no_outpdf, tmpdir):
|
def test_tesseract_missing_tessdata(monkeypatch, resources, no_outpdf, tmpdir):
|
||||||
monkeypatch.setenv("TESSDATA_PREFIX", os.fspath(tmpdir))
|
monkeypatch.setenv("TESSDATA_PREFIX", os.fspath(tmpdir))
|
||||||
@@ -777,9 +778,6 @@ def test_sidecar_nonempty(resources, outpdf):
|
|||||||
|
|
||||||
@pytest.mark.parametrize('pdfa_level', ['1', '2', '3'])
|
@pytest.mark.parametrize('pdfa_level', ['1', '2', '3'])
|
||||||
def test_pdfa_n(pdfa_level, resources, outpdf):
|
def test_pdfa_n(pdfa_level, resources, outpdf):
|
||||||
if pdfa_level == '3' and ghostscript.version() < '9.19':
|
|
||||||
pytest.xfail(reason='Ghostscript >= 9.19 required')
|
|
||||||
|
|
||||||
check_ocrmypdf(
|
check_ocrmypdf(
|
||||||
resources / 'ccitt.pdf',
|
resources / 'ccitt.pdf',
|
||||||
outpdf,
|
outpdf,
|
||||||
|
|||||||
@@ -223,6 +223,12 @@ def test_version_comparison():
|
|||||||
need_version='4.1.1',
|
need_version='4.1.1',
|
||||||
version_parser=TesseractVersion,
|
version_parser=TesseractVersion,
|
||||||
)
|
)
|
||||||
|
vd.check_external_program(
|
||||||
|
program="gs",
|
||||||
|
package="ghostscript",
|
||||||
|
version_checker=lambda: '10.0',
|
||||||
|
need_version='9.50',
|
||||||
|
)
|
||||||
with pytest.raises(MissingDependencyError):
|
with pytest.raises(MissingDependencyError):
|
||||||
vd.check_external_program(
|
vd.check_external_program(
|
||||||
program="tesseract",
|
program="tesseract",
|
||||||
|
|||||||
Reference in New Issue
Block a user