diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index ddcb72b0..00000000
--- a/.coveragerc
+++ /dev/null
@@ -1,16 +0,0 @@
-# Coverage isn't really compatible with subprocesses so results are unreliable
-
-[run]
-branch = True
-#concurrency = multiprocessing
-source = ocrmypdf/
-
-[report]
-exclude_lines =
- pragma: no cover
- def __repr__
- raise AssertionError
- raise NotImplementedError
- if 0:
- if False:
- if __name__ == .__main__.:
diff --git a/.docker/Dockerfile b/.docker/Dockerfile
index ebb63ddd..4700004e 100644
--- a/.docker/Dockerfile
+++ b/.docker/Dockerfile
@@ -1,16 +1,62 @@
# OCRmyPDF
#
-FROM ubuntu:18.04
+FROM ubuntu:20.04 as base
+
+FROM base as builder
+
+ENV LANG=C.UTF-8
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential autoconf automake libtool \
libleptonica-dev \
zlib1g-dev \
- libexempi3 \
- ocrmypdf \
+ python3-dev \
+ python3-distutils \
+ libffi-dev \
+ libqpdf-dev \
+ ca-certificates \
+ curl \
+ git
+
+# Get the latest pip (Ubuntu version doesn't support manylinux2010)
+RUN \
+ curl https://bootstrap.pypa.io/get-pip.py | python3
+
+# Compile and install jbig2
+# Needs libleptonica-dev, zlib1g-dev
+RUN \
+ mkdir jbig2 \
+ && curl -L https://github.com/agl/jbig2enc/archive/ea6a40a.tar.gz | \
+ tar xz -C jbig2 --strip-components=1 \
+ && cd jbig2 \
+ && ./autogen.sh && ./configure && make && make install \
+ && cd .. \
+ && rm -rf jbig2
+
+COPY . /app
+
+WORKDIR /app
+
+RUN pip3 install --no-cache-dir \
+ -r requirements/main.txt \
+ -r requirements/webservice.txt \
+ -r requirements/test.txt \
+ -r requirements/watcher.txt \
+ .
+
+FROM base
+
+ENV LANG=C.UTF-8
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ghostscript \
+ img2pdf \
+ liblept5 \
+ libsm6 libxext6 libxrender-dev \
+ zlib1g \
pngquant \
- python3-pip \
- python3-venv \
+ python3 \
+ qpdf \
tesseract-ocr \
tesseract-ocr-chi-sim \
tesseract-ocr-deu \
@@ -19,54 +65,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr-por \
tesseract-ocr-spa \
unpaper \
- wget
+ && rm -rf /var/lib/apt/lists/*
+WORKDIR /app
-ENV LANG=C.UTF-8
+COPY --from=builder /usr/local/lib/ /usr/local/lib/
+COPY --from=builder /usr/local/bin/ /usr/local/bin/
-# Compile and install jbig2
-# Needs libleptonica-dev, zlib1g-dev
-RUN \
- mkdir jbig2 \
- && wget -q https://github.com/agl/jbig2enc/archive/0.29.tar.gz -O - | \
- tar xz -C jbig2 --strip-components=1 \
- && cd jbig2 \
- && ./autogen.sh && ./configure && make && make install \
- && cd .. \
- && rm -rf jbig2
+COPY --from=builder /app/misc/webservice.py /app/
+COPY --from=builder /app/misc/watcher.py /app/
-RUN apt-get remove -y autoconf automake libtool
+# Copy minimal project files to get the test suite.
+COPY --from=builder /app/setup.cfg /app/setup.py /app/README.md /app/
+COPY --from=builder /app/requirements /app/requirements
+COPY --from=builder /app/tests /app/tests
-RUN python3 -m venv --system-site-packages /appenv
-
-# This installs the latest binary wheel instead of the code in the current
-# folder. Installing from source will fail, apparently because cffi needs
-# build-essentials (gcc) to do a source installation
-# (i.e. "pip install ."). It's unclear to me why this is the case.
-RUN . /appenv/bin/activate; \
- pip install --upgrade pip \
- && pip install --upgrade ocrmypdf
-
-# Now copy the application in, mainly to get the test suite.
-# Do this now to make the best use of Docker cache.
-COPY . /application
-RUN . /appenv/bin/activate; \
- pip install -r /application/requirements/test.txt
-
-# Remove the junk, including the source version of application since it was
-# already installed
-RUN rm -rf /tmp/* /var/tmp/* /root/* /application/ocrmypdf \
- && apt-get remove -y build-essential \
- && apt-get autoremove -y \
- && apt-get autoclean -y
-
-RUN useradd docker \
- && mkdir /home/docker \
- && chown docker:docker /home/docker
-
-USER docker
-WORKDIR /home/docker
-
-# Must use array form of ENTRYPOINT
-# Non-array form does not append other arguments, because that is "intuitive"
-ENTRYPOINT ["/application/.docker/docker-wrapper.sh"]
+ENTRYPOINT ["/usr/local/bin/ocrmypdf"]
diff --git a/.docker/alpine.dockerfile b/.docker/alpine.dockerfile
deleted file mode 100644
index d54951f6..00000000
--- a/.docker/alpine.dockerfile
+++ /dev/null
@@ -1,84 +0,0 @@
-FROM alpine:3.9 as base
-
-FROM base as builder
-
-ENV LANG=C.UTF-8
-
-RUN \
- echo '@testing http://nl.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
- # Add runtime dependencies
- && apk add --update \
- python3-dev \
- py3-setuptools \
- jbig2enc@testing \
- ghostscript \
- qpdf \
- tesseract-ocr \
- unpaper \
- pngquant \
- libxml2-dev \
- libxslt-dev \
- zlib-dev \
- qpdf-dev \
- libffi-dev \
- leptonica-dev \
- binutils \
- # Install pybind11 for pikepdf
- && pip3 install pybind11 \
- # Install flask for the webservice
- && pip3 install flask \
- # Add build dependencies
- && apk add --virtual build-dependencies \
- build-base \
- git
-
-COPY . /app
-
-WORKDIR /app
-
-RUN pip3 install .
-
-FROM base
-
-ENV LANG=C.UTF-8
-
-RUN \
- echo '@testing http://nl.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories \
- # Add runtime dependencies
- && apk add --update \
- python3 \
- jbig2enc@testing \
- ghostscript \
- qpdf \
- tesseract-ocr \
- tesseract-ocr-data-deu \
- tesseract-ocr-data-chi_sim \
- unpaper \
- pngquant \
- libxml2 \
- libxslt \
- zlib \
- qpdf \
- libffi \
- leptonica-dev \
- binutils \
- && mkdir /app
-
-WORKDIR /app
-
-# Copy build artifacts (python site-packages9
-COPY --from=builder /usr/lib/python3.6/site-packages /usr/lib/python3.6/site-packages
-COPY --from=builder /usr/bin/ocrmypdf /usr/bin/dumppdf.py /usr/bin/latin2ascii.py /usr/bin/pdf2txt.py /usr/bin/img2pdf /usr/bin/chardetect /usr/bin/
-
-# Copy
-COPY --from=builder /app/.docker/webservice.py /app/
-
-# Copy minimal project files to get the test suite.
-COPY --from=builder /app/setup.cfg /app/setup.py /app/README.md /app/
-COPY --from=builder /app/requirements /app/requirements
-COPY --from=builder /app/tests /app/tests
-COPY --from=builder /app/src /app/src
-# Copy PKG-INFO from build artifact in app dir to make setuptools-scm happy
-RUN cp /usr/lib/python3.6/site-packages/ocrmypdf-*.egg-info/PKG-INFO /app
-
-ENTRYPOINT ["/usr/bin/ocrmypdf"]
diff --git a/.docker/docker-wrapper.sh b/.docker/docker-wrapper.sh
deleted file mode 100755
index ecc1af3e..00000000
--- a/.docker/docker-wrapper.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-. /appenv/bin/activate
-cd /home/docker
-exec ocrmypdf "$@"
\ No newline at end of file
diff --git a/.docker/polyglot.dockerfile b/.docker/polyglot.dockerfile
deleted file mode 100644
index c837a197..00000000
--- a/.docker/polyglot.dockerfile
+++ /dev/null
@@ -1,17 +0,0 @@
-# OCRmyPDF polyglot
-#
-FROM jbarlow83/ocrmypdf:latest
-
-USER root
-
-# Update system and install our dependencies
-RUN apt-get update && apt-get install -y --no-install-recommends \
- tesseract-ocr-all
-
-RUN apt-get autoremove -y && apt-get clean -y
-
-USER docker
-
-# Must use array form of ENTRYPOINT
-# Non-array form does not append other arguments, because that is "intuitive"
-ENTRYPOINT ["/application/.docker/docker-wrapper.sh"]
\ No newline at end of file
diff --git a/.docker/webservice.dockerfile b/.docker/webservice.dockerfile
deleted file mode 100644
index cd0f71be..00000000
--- a/.docker/webservice.dockerfile
+++ /dev/null
@@ -1,24 +0,0 @@
-# OCRmyPDF webservice
-#
-FROM jbarlow83/ocrmypdf-polyglot:latest
-
-USER root
-
-# Update system and install our dependencies
-RUN apt-get update && apt-get install -y --no-install-recommends \
- python3-flask
-
-RUN apt-get autoremove -y && apt-get clean -y
-
-EXPOSE 5000
-
-COPY .docker/webservice.py /application
-
-USER docker
-
-VOLUME ["/config"]
-
-# This config file is optional
-ENV OCRMYPDF_WEBSERVICE_SETTINGS "/config/config.py"
-
-ENTRYPOINT ["python3", "/application/webservice.py"]
diff --git a/.dockerignore b/.dockerignore
index ee63ddca..2879b33a 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,26 +1,44 @@
+# dotfiles
+.*
+!.coveragerc
+!.dockerignore
+!.git_archival.txt
+!.gitattributes
+!.gitignore
+!.pre-commit-config.yaml
+!.readthedocs.yml
+
+# Dev scratch
*.ipynb
-*.pdf
-*.pyc
-*.rst
-*.sublime*
**/*.pyc
-.*/
-!.git/
-!.docker/
-.ruffus_history.sqlite
-bin/
-build/
-docs/
-dist/
-htmlcov/
-include/
-lib/
-MANIFEST.in
-ocrmypdf.egg-info/
-staging/
-tests/cache/
-tests/output/
+/*.pdf
+/*.qdf
+/*.png
+/scratch.py
+IDEAS
+log/
tests/resources/private/
tmp/
venv*/
+/debug_tests.py
+*.traineddata
+/private
+
+# Package building
+*.egg-info/
+build/
+dist/
wheelhouse/
+pip-wheel-metadata/
+
+# Code coverage
+htmlcov/
+
+# Docker specific
+bin/
+docs/
+include/
+lib/
+
+# Docker include .git/
+!.git/
diff --git a/.gitattributes b/.gitattributes
index 7dab7cbc..928cb783 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9,5 +9,6 @@
*.png binary
*.jpg binary
*.bin binary
+*.afdesign binary
.git_archival.txt export-subst
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 00000000..f9e58e51
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: james-barlow
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/ISSUE_TEMPLATE/1-general-issues.md b/.github/ISSUE_TEMPLATE/1-general-issues.md
new file mode 100644
index 00000000..3aa3c2d6
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/1-general-issues.md
@@ -0,0 +1,32 @@
+---
+name: General issues
+about: Installation, packages, dependencies, "nothing works", test suite failures...
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Describe the bug**
+What's the problem?
+
+**To Reproduce**
+Steps to reproduce the behavior.
+
+**Expected behavior**
+What did you expected to happen?
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**System (please complete the following information):**
+ - OS:
+ - Python version:
+ - OCRmyPDF version:
+
+**Installation**
+How did you install OCRmyPDF? Did you install it from your operating system's
+package manager, or using pip?
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/2-problem-with-a-specific-input-file.md b/.github/ISSUE_TEMPLATE/2-problem-with-a-specific-input-file.md
new file mode 100644
index 00000000..595d9cee
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/2-problem-with-a-specific-input-file.md
@@ -0,0 +1,40 @@
+---
+name: Problem with a specific input file
+about: Something went wrong while trying to OCR a specific file
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+What command line or API call were you trying to run?
+
+```bash
+ocrmypdf ...arguments... input.pdf output.pdf
+```
+
+Run with verbosity or higher `-v1` to see more detailed logging. This information may be helpful.
+
+**Example file**
+If your issue is a problem that affects only certain files, and we will require an input file (PDF or image) that demonstrates your issue.
+
+Please provide an input file with no personal or confidential information. At your option you may [GPG-encrypt the file](https://github.com/jbarlow83/OCRmyPDF/wiki) for OCRmyPDF's author only.
+
+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.
+
+*(Issues without example files usually cannot be resolved. It's like reporting an issue against a web browser without providing a URL.)*
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**System**
+ - OS: [e.g. Linux, Windows, macOS]
+ - OCRmyPDF Version: ``ocrmypdf --version``
+ - How did you install ocrmypdf? Did you use a system package manager, `pip`, or a Docker image?
diff --git a/.github/ISSUE_TEMPLATE/3-feature_request.md b/.github/ISSUE_TEMPLATE/3-feature_request.md
new file mode 100644
index 00000000..bbcbbe7d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/3-feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/issue_template.md b/.github/issue_template.md
deleted file mode 100644
index f3142596..00000000
--- a/.github/issue_template.md
+++ /dev/null
@@ -1,33 +0,0 @@
-**Describe the issue**
-A clear and concise description of what the issue is.
-
-**To Reproduce**
-What command line were you trying to run?
-
-```bash
-ocrmypdf ...arguments... input.pdf output.pdf
-```
-
-**Example file**
-Please include an example *input* PDF (or image). The input file is more helpful.
-
-Please check any or all that apply about the test file:
-
-- [ ] This is the input file
-- [ ] The file contains no personal or confidential information
-- [ ] I am the copyright holder for this file
-- [ ] I permit this file to be included in the OCRmyPDF test suite under the CC-BY-SA 4.0 license
-- [ ] I am not the copyright holder, but this file is available under a free software license
-
-Files that are not free for inclusion in this project are quite welcome, but we like to collect free files for our test suite when possible. Please do *not* submit files with confidential information. At your option you may encrypt files for OCRmyPDF's author only.
-
-**Expected behavior**
-A clear and concise description of what you expected to happen. Include screenshots if applicable.
-
-**System:**
-
-- OS: [e.g. Linux, macOS]
-- OCRmyPDF Version: [e.g. v7.4.0]
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 00000000..cad70f3f
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,275 @@
+name: Test and deploy
+
+on:
+ push:
+ branches:
+ - master
+ - ci
+ - release/*
+ tags:
+ - v*
+ paths-ignore:
+ - README*
+ pull_request:
+
+jobs:
+ test_linux:
+ name: Test ${{ matrix.os }} with Python ${{ matrix.python }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-18.04] #, ubuntu-20.04]
+ python: ["3.6"] #, "3.7", "3.8", "3.9"]
+
+ env:
+ OS: ${{ matrix.os }}
+ PYTHON: ${{ matrix.python }}
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
+
+ - uses: actions/setup-python@v2
+ name: Install Python
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install common packages
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends \
+ curl \
+ ghostscript \
+ img2pdf \
+ libffi-dev \
+ liblept5 \
+ libsm6 libxext6 libxrender-dev \
+ pngquant \
+ poppler-utils \
+ tesseract-ocr \
+ tesseract-ocr-deu \
+ tesseract-ocr-eng \
+ unpaper \
+ zlib1g
+
+ - name: Install Ubuntu 18.04 packages
+ if: matrix.os == 'ubuntu-18.04'
+ run: |
+ sudo apt-get install -y --no-install-recommends \
+ libexempi3
+
+ - name: Install Ubuntu 20.04 packages
+ if: matrix.os == 'ubuntu-20.04'
+ run: |
+ sudo apt-get install -y --no-install-recommends \
+ libexempi8
+
+ - name: Install Python packages
+ run: |
+ python -m pip install -r requirements/main.txt -r requirements/test.txt .
+
+ - name: Report versions
+ run: |
+ tesseract --version
+ gs --version
+ pngquant --version
+ unpaper --version
+ img2pdf --version
+
+ - name: Test
+ run: |
+ python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/
+
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v1
+ with:
+ files: ./coverage.xml
+ env_vars: OS,PYTHON
+
+ test_macos:
+ name: Test macOS
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [macos-latest]
+ python: ["3.9"]
+
+ env:
+ OS: ${{ matrix.os }}
+ PYTHON: ${{ matrix.python }}
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
+
+ - uses: actions/setup-python@v2
+ name: Install Python
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install Homebrew deps
+ run: |
+ brew update
+ brew install \
+ exempi \
+ ghostscript \
+ jbig2enc \
+ leptonica \
+ openjpeg \
+ pngquant \
+ tesseract
+
+ - name: Install Python packages
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install -r requirements/main.txt -r requirements/test.txt .
+
+ - name: Report versions
+ run: |
+ tesseract --version
+ gs --version
+ pngquant --version
+ img2pdf --version
+
+ - name: Test
+ run: |
+ python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/
+
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v1
+ with:
+ files: ./coverage.xml
+ env_vars: OS,PYTHON
+
+ test_windows:
+ name: Test Windows
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [windows-latest]
+ python: ["3.9"]
+
+ env:
+ OS: ${{ matrix.os }}
+ PYTHON: ${{ matrix.python }}
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
+
+ - uses: actions/setup-python@v2
+ name: Install Python
+ with:
+ python-version: ${{ matrix.python }}
+
+ - name: Install system packages
+ run: |
+ choco install --yes --no-progress --pre tesseract
+ choco install --yes --no-progress ghostscript
+ choco install --yes --no-progress pngquant
+
+ - name: Install Python packages
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install -r requirements/main.txt -r requirements/test.txt .
+
+ - name: Test
+ run: |
+ python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/
+
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v1
+ with:
+ files: ./coverage.xml
+ env_vars: OS,PYTHON
+
+ wheel_sdist_linux:
+ name: Build sdist and wheels
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
+
+ - uses: actions/setup-python@v2
+ name: Install Python
+ with:
+ python-version: "3.6"
+
+ - name: Make wheels and sdist
+ run: |
+ python -m pip install --upgrade pip wheel
+ python setup.py sdist
+ python setup.py bdist_wheel
+
+ - uses: actions/upload-artifact@v2
+ with:
+ path: |
+ ./dist/*.whl
+ ./dist/*.tar.gz
+
+ upload_pypi:
+ name: Deploy artifacts to PyPI
+ needs: [wheel_sdist_linux, test_linux, test_macos, test_windows]
+ runs-on: ubuntu-latest
+ if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
+ steps:
+ - uses: actions/download-artifact@v2
+ with:
+ name: artifact
+ path: dist
+
+ - uses: pypa/gh-action-pypi-publish@master
+ with:
+ user: __token__
+ password: ${{ secrets.TOKEN_PYPI }}
+ # repository_url: https://test.pypi.org/legacy/
+
+ docker:
+ name: Build Docker images
+ needs: [wheel_sdist_linux, test_linux, test_macos, test_windows]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Set image tag to release or branch
+ run: echo "DOCKER_IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
+
+ - name: If master, set to latest
+ run: echo 'DOCKER_IMAGE_TAG=latest' >> $GITHUB_ENV
+ if: env.DOCKER_IMAGE_TAG == 'master'
+
+ - name: Set Docker Hub repository to username
+ run: echo "DOCKER_REPOSITORY=jbarlow83" >> $GITHUB_ENV
+
+ - name: Set image name
+ run: echo "DOCKER_IMAGE_NAME=ocrmypdf" >> $GITHUB_ENV
+
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags
+
+ - name: Login to Docker Hub
+ uses: docker/login-action@v1
+ with:
+ username: jbarlow83
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ - name: Set up Docker Buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Print image tag
+ run: echo "Building image ${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
+
+ - name: Build
+ run: |
+ docker buildx build \
+ --push \
+ --platform linux/arm64/v8,linux/amd64 \
+ --tag "${DOCKER_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \
+ --file .docker/Dockerfile .
diff --git a/.gitignore b/.gitignore
index b2881fb4..60de406b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,44 +1,44 @@
-# Development environment
-.bash_history
-.pylintrc
-.pytest_cache/
-.ruffus_history.sqlite
-.venv/
-*.pyc
-*.sublime-*
+# dotfiles
+.*
+!.coveragerc
+!.dockerignore
+!.git_archival.txt
+!.gitattributes
+!.gitignore
+!.pre-commit-config.yaml
+!.readthedocs.yml
+!.github/
+
+# Dev scratch
+*.ipynb
+**/*.pyc
+/*.pdf
+/*.qdf
+/*.png
+/scratch.py
+IDEAS
+log/
+tests/resources/private/
+tmp/
+venv*/
+/debug_tests.py
+*.traineddata
+/private
+/coverage.xml
# Package building
-.eggs/
*.egg-info/
build/
dist/
wheelhouse/
pip-wheel-metadata/
+# Code coverage
+htmlcov/
+
# Automatically generated files
docs/_build/
docs/_static/
docs/_templates/
docs/Makefile
ocrmypdf/lib/_*.py
-
-# Code coverage
-.coverage*
-htmlcov/
-
-# Testing
-.ipynb_checkpoints/
-.vscode/
-*.ipynb
-*.profile
-/*.pdf
-/*.qdf
-/*.png
-/scratch.py
-IDEAS
-log/
-tests/output/
-tests/resources/private/
-tmp/
-/debug_tests.py
-*.traineddata
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index b268b628..3cd240e2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,23 @@
repos:
-- repo: https://github.com/ambv/black
- rev: stable
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v3.4.0
hooks:
- - id: black
- language_version: python3.7
+ - id: check-case-conflict
+ - id: check-merge-conflict
+ - id: check-toml
+ - id: check-yaml
+ - id: debug-statements
+ - repo: https://github.com/asottile/seed-isort-config
+ rev: v2.2.0
+ hooks:
+ - id: seed-isort-config
+ - repo: https://github.com/pre-commit/mirrors-isort
+ rev: v5.7.0 # pick the isort version you'd like to use from https://github.com/pre-commit/mirrors-isort/releases
+ hooks:
+ - id: isort
+ - repo: https://github.com/psf/black
+ rev: 20.8b1
+ hooks:
+ - id: black
+ language_version: python
+ exclude: ^src/ocrmypdf/lib/_leptonica.py
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7ca3206e..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,146 +0,0 @@
-cache:
- pip: true
- directories:
- - $HOME/Library/Caches/Homebrew
-
-matrix:
- include:
- - os: linux
- dist: trusty
- sudo: required
- language: python
- python: "3.6"
- env:
- - DIST=trusty
- addons: &trusty_apt
- apt:
- update: true
- sources:
- - sourceline: 'ppa:alex-p/tesseract-ocr'
- - sourceline: 'ppa:heyarje/libav-11'
- - sourceline: 'ppa:vshn/ghostscript'
- packages:
- - ghostscript
- - libavcodec56
- - libavformat56
- - libavutil54
- - libexempi3
- - libffi-dev
- - pngquant
- - poppler-utils
- - qpdf
- - tesseract-ocr
- - tesseract-ocr-deu
- - tesseract-ocr-eng
- - tesseract-ocr-fra
- - os: linux
- dist: xenial
- sudo: required
- language: python
- python: "3.7"
- env:
- - DIST=xenial
- addons:
- apt:
- update: true
- sources:
- - sourceline: 'ppa:alex-p/tesseract-ocr'
- packages:
- - ghostscript
- - libexempi3
- - libffi-dev
- - pngquant
- - poppler-utils
- - qpdf
- - tesseract-ocr
- - tesseract-ocr-deu
- - tesseract-ocr-eng
- - tesseract-ocr-fra
- - unpaper
- - os: osx
- osx_image: xcode9.2
- language: generic
- addons:
- homebrew:
- update: true
- packages:
- - exempi
- - ghostscript
- - jbig2enc
- - leptonica
- - openjpeg
- - pngquant
- - python
- - qpdf
- - tesseract
- - unpaper
- - os: osx
- osx_image: xcode9.2
- language: generic
- env:
- - ADD_PDFMINER=1
- addons:
- homebrew:
- update: true
- packages:
- - exempi
- - ghostscript
- - jbig2enc
- - leptonica
- - openjpeg
- - pngquant
- - python
- - qpdf
- - tesseract
- - unpaper
-
-before_cache:
-- rm -f $HOME/.cache/pip/log/debug.log
-
-before_install: |
- mkdir -p bin
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
- pip3 install --upgrade pip
- pip3 install --upgrade wheel
- if [[ "$DIST" == "trusty" ]]; then
- mkdir -p packages
- wget -q 'https://www.dropbox.com/s/vaq0kbwi6e6au80/unpaper_6.1-1.deb?raw=1' -O packages/unpaper_6.1-1.deb
- sudo dpkg -i packages/unpaper_6.1-1.deb
- fi
- elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
- pip3 install --upgrade pip
- pip3 install wheel
- fi
-
-install:
-- export PATH=$PWD/bin:$PATH
-- pip3 install pycparser # py3.7 workaround for https://github.com/eliben/pycparser/issues/251
-- pip3 install -r requirements/main.txt
-- pip3 install --no-deps .
-- |
- if [[ "$ADD_PDFMINER" == "1" ]]; then
- pip3 install --no-deps .[pdfminer]
- fi
-- pip3 install -r requirements/test.txt
-
-script:
-- tesseract --version
-- qpdf --version
-- pytest -n auto
-
-deploy:
- # release for main pypi
- # 3.6 is considered the build leader and does the deploy, otherwise there is
- # a race and all versions will try to deploy
- # OTOH if we ever need separate binary wheels then each version needs its
- # own deploy
-- provider: pypi
- user: ocrmypdf-travis
- password:
- secure: "DTFOmmNL6olA0+yXvp4u9jXZlZeqrJsJ0526jzqf4a3gZ6jnGTq5UI6WzRsslSyoMMfXKtHQebqHM6ogSgCZinyZ3ufHJo8fn9brxbEc2gsiWkbj5o3bGwdWMT1vNNE7XW0VCpw87rZ1EEwjl4FJHFudMlPR1yfU5+uq0k0PACo="
- distributions: "sdist bdist_wheel"
- on:
- branch: master
- tags: true
- condition: $TRAVIS_PYTHON_VERSION == "3.6" && $TRAVIS_OS_NAME == "linux"
- skip_upload_docs: true
diff --git a/LICENSE b/LICENSE
index f288702d..a612ad98 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,373 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+ means
+
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+
+1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+
+1.8. "License"
+ means this document.
+
+1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+
+1.10. "Modifications"
+ means any of the following:
+
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+
+1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+
+1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+ or
+
+(b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party's negligence to the *
+* extent applicable law prohibits such limitation. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 2021f662..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,43 +0,0 @@
-# requirements
-recursive-include requirements *
-
-# git
-include .git_archival.txt
-
-# docker
-include .dockerignore
-recursive-include .docker *
-
-# tests
-include .coveragerc
-recursive-include tests *.bin
-recursive-include tests *.jpg
-recursive-include tests *.jsonl
-recursive-include tests *.png
-recursive-include tests *.pdf
-recursive-include tests *.py
-recursive-include tests *.rst
-recursive-include tests *.txt
-recursive-exclude tests/resources/private *
-
-# documentation
-include LICENSE
-include *.rst
-recursive-exclude .github *
-recursive-include docs *.py
-recursive-include docs *.rst
-recursive-include docs *.svg
-recursive-exclude docs/_build *
-
-
-# support files
-recursive-include src/ocrmypdf/data *
-include *.py
-exclude tasks.py
-recursive-exclude .travis *
-exclude .travis*
-
-
-# code
-exclude src/ocrmypdf/lib/_leptonica.py
-exclude scratch.py
diff --git a/README.md b/README.md
index 3509fb71..a0bf0a35 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,13 @@
-OCRmyPDF
-========
+
-[![Travis build status][travis]](https://travis-ci.org/jbarlow83/OCRmyPDF) [![PyPI version][pypi]](https://pypi.org/project/ocrmypdf/) ![Homebrew version][homebrew] ![ReadTheDocs][docs]
+[](https://github.com/jbarlow83/OCRmyPDF/actions/workflows/build.yml) [![PyPI version][pypi]](https://pypi.org/project/ocrmypdf/) ![Homebrew version][homebrew] ![ReadTheDocs][docs] ![Python versions][pyversions]
+[azure]: https://dev.azure.com/jim0585/ocrmypdf/_apis/build/status/jbarlow83.OCRmyPDF?branchName=master
[travis]: https://travis-ci.org/jbarlow83/OCRmyPDF.svg?branch=master "Travis build status"
-
[pypi]: https://img.shields.io/pypi/v/ocrmypdf.svg "PyPI version"
-
[homebrew]: https://img.shields.io/homebrew/v/ocrmypdf.svg "Homebrew version"
-
[docs]: https://readthedocs.org/projects/ocrmypdf/badge/?version=latest "RTD"
+[pyversions]: https://img.shields.io/pypi/pyversions/ocrmypdf "Supported Python versions"
OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched or copy-pasted.
@@ -27,15 +25,14 @@ ocrmypdf # it's a scriptable command line program
[See the release notes for details on the latest changes](https://ocrmypdf.readthedocs.io/en/latest/release_notes.html).
-Main features
--------------
+## Main features
- Generates a searchable [PDF/A](https://en.wikipedia.org/?title=PDF/A) file from a regular PDF
- Places OCR text accurately below the image to ease copy / paste
- Keeps the exact resolution of the original embedded images
- When possible, inserts OCR information as a "lossless" operation without disrupting any other content
- Optimizes PDF images, often producing files smaller than the input file
-- If requested deskews and/or cleans the image before performing OCR
+- If requested, deskews and/or cleans the image before performing OCR
- Validates input and output files
- Distributes work across all available CPU cores
- Uses [Tesseract OCR](https://github.com/tesseract-ocr/tesseract) engine to recognize more than [100 languages](https://github.com/tesseract-ocr/tessdata)
@@ -44,10 +41,9 @@ Main features
For details: please consult the [documentation](https://ocrmypdf.readthedocs.io/en/latest/).
-Motivation
-----------
+## Motivation
-I searched the web for a free command line tool to OCR PDF files on Linux/UNIX: I found many, but none of them were really satisfying.
+I searched the web for a free command line tool to OCR PDF files: I found many, but none of them were really satisfying:
- Either they produced PDF files with misplaced text under the image (making copy/paste impossible)
- Or they did not handle accents and multilingual characters
@@ -59,33 +55,23 @@ I searched the web for a free command line tool to OCR PDF files on Linux/UNIX:
...so I decided to develop my own tool.
-Installation
-------------
+## Installation
-Linux, UNIX, and macOS are supported. Windows is not directly supported but there is a Docker image available that runs on Windows.
+Linux, Windows, macOS and FreeBSD are supported. Docker images are also available.
-Users of Debian 9 or later or Ubuntu 16.10 or later may simply
-
-```bash
-apt-get install ocrmypdf
-```
-
-and users of Fedora 29 or later may simply
-
-```bash
-dnf install ocrmypdf
-```
-
-and macOS users with Homebrew may simply
-
-```bash
-brew install ocrmypdf
-```
+| Operating system | Install command |
+| ----------------------------- | ------------------------------|
+| Debian, Ubuntu | ``apt install ocrmypdf`` |
+| Windows Subsystem for Linux | ``apt install ocrmypdf`` |
+| Fedora | ``dnf install ocrmypdf`` |
+| macOS | ``brew install ocrmypdf`` |
+| LinuxBrew | ``brew install ocrmypdf`` |
+| FreeBSD | ``pkg install py37-ocrmypdf`` |
+| Conda | ``conda install ocrmypdf`` |
For everyone else, [see our documentation](https://ocrmypdf.readthedocs.io/en/latest/installation.html) for installation steps.
-Languages
----------
+## Languages
OCRmyPDF uses Tesseract for OCR, and relies on its language packs. For Linux users, you can often find packages that provide language packs:
@@ -94,15 +80,20 @@ OCRmyPDF uses Tesseract for OCR, and relies on its language packs. For Linux use
apt-cache search tesseract-ocr
# Debian/Ubuntu users
-apt-get install tesseract-ocr-chi-sim # Example: Install Chinese Simplified language back
+apt-get install tesseract-ocr-chi-sim # Example: Install Chinese Simplified language pack
+
+# Arch Linux users
+pacman -S tesseract-data-eng tesseract-data-deu # Example: Install the English and German language packs
+
+# brew macOS users
+brew install tesseract-lang
```
You can then pass the `-l LANG` argument to OCRmyPDF to give a hint as to what languages it should search for. Multiple languages can be requested.
-Documentation and support
--------------------------
+## Documentation and support
-Once ocrmypdf is installed, the built-in help which explains the command syntax and options can be accessed via:
+Once OCRmyPDF is installed, the built-in help which explains the command syntax and options can be accessed via:
```bash
ocrmypdf --help
@@ -110,42 +101,37 @@ ocrmypdf --help
Our [documentation is served on Read the Docs](https://ocrmypdf.readthedocs.io/en/latest/index.html).
-If you detect an issue, please:
+Please report issues on our [GitHub issues](https://github.com/jbarlow83/OCRmyPDF/issues) page, and follow the issue template for quick response.
-- Check whether your issue is already known
-- If no problem report exists on github, please create one here:
-- Describe your problem thoroughly
-- Append the console output of the script when running the debug mode (`-v 1` option)
-- If possible provide your input PDF file as well as the content of the temporary folder (using a file sharing service like Dropbox)
+## Requirements
-Requirements
-------------
+In addition to the required Python version (3.6+), OCRmyPDF requires external program installations of Ghostscript, Tesseract OCR, QPDF, and Leptonica. OCRmyPDF is pure Python, but uses CFFI to portably generate library bindings. OCRmyPDF works on pretty much everything: Linux, macOS, Windows and FreeBSD.
-Runs on CPython 3.5, 3.6 and 3.7. Requires external program installations of Ghostscript, Tesseract OCR, QPDF, and Leptonica. ocrmypdf is pure Python, but uses CFFI to portably generate library bindings.
-
-Press & Media
--------------
+## Press & Media
- [Going paperless with OCRmyPDF](https://medium.com/@ikirichenko/going-paperless-with-ocrmypdf-e2f36143f46a)
- [Converting a scanned document into a compressed searchable PDF with redactions](https://medium.com/@treyharris/converting-a-scanned-document-into-a-compressed-searchable-pdf-with-redactions-63f61c34fe4c)
-- [c't 1-2014, page 59](http://heise.de/-2279695): Detailed presentation of OCRmyPDF v1.0 in the leading German IT magazine c't
-- [heise Open Source, 09/2014: Texterkennung mit OCRmyPDF](http://heise.de/-2356670)
+- [c't 1-2014, page 59](https://heise.de/-2279695): Detailed presentation of OCRmyPDF v1.0 in the leading German IT magazine c't
+- [heise Open Source, 09/2014: Texterkennung mit OCRmyPDF](https://heise.de/-2356670)
+- [heise Durchsuchbare PDF-Dokumente mit OCRmyPDF erstellen](https://www.heise.de/ratgeber/Durchsuchbare-PDF-Dokumente-mit-OCRmyPDF-erstellen-4607592.html)
+- [Excellent Utilities: OCRmyPDF](https://www.linuxlinks.com/excellent-utilities-ocrmypdf-add-ocr-text-layer-scanned-pdfs/)
-Business enquiries
-------------------
+## Business enquiries
-OCRmyPDF would not be the software that it is today is without companies and users choosing to provide support for feature development and consulting enquiries. We are happy to discuss all enquiries, whether for extending the existing feature set, or integrating OCRmyPDF into a larger system.
+OCRmyPDF would not be the software that it is today without companies and users choosing to provide support for feature development and consulting enquiries. We are happy to discuss all enquiries, whether for extending the existing feature set, or integrating OCRmyPDF into a larger system.
-License
--------
+## License
-The OCRmyPDF software is licensed under the GNU GPLv3. Certain files are covered by other licenses, as noted in their source files.
+The OCRmyPDF software is licensed under the Mozilla Public License 2.0
+(MPL-2.0). This license permits integration of OCRmyPDF with other code,
+included commercial and closed source, but asks you to publish source-level
+modifications you make to OCRmyPDF.
-The license for each test file varies, and is noted in tests/resources/README.rst. The documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA 4.0).
+Some components of OCRmyPDF have other licenses, as noted in those files and the
+``debian/copyright`` file. Most files in ``misc/`` use the MIT license, and the
+documentation and test files are generally licensed under Creative Commons
+ShareAlike 4.0 (CC-BY-SA 4.0).
-OCRmyPDF versions prior to 6.0 were distributed under the MIT License.
-
-Disclaimer
-----------
+## Disclaimer
The software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/debian/copyright b/debian/copyright
index 8c190b4d..a48ac1dc 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -2,35 +2,70 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OCRmyPDF
Upstream-Contact: James R. Barlow
Source: https://github.com/jbarlow83/OCRmyPDF
-Files-Excluded: tests/resources/milk.pdf
Files: *
Copyright:
- (C) 2013-2017 The OCRmyPDF Authors
- (C) 2013-2016, 2015-2017 2016, 2017, 2017-2018, 2018 James R. Barlow
-License: GPL-3+
+ (C) 2013-2015 Julien Pfefferkorn
+ (C) 2015-2020 James R. Barlow
+ (C) 2019 Martin Wind
+License: MPL-2.0
+
+Files: misc/*
+Copyright:
+ (C) 2020 James R. Barlow
+License: Expat
+
+Files: misc/completion/ocrmypdf.bash
+Copyright:
+ (C) 2019 Frank Pille
+ (C) 2020 Alex Willner
+License: Expat
+
+Files: misc/completion/ocrmypdf.fish
+Copyright:
+ (C) 2020 James R. Barlow
+License: Expat
+
+Files: misc/batch.py
+Copyright:
+ (C) 2016 findingorder: https://github.com/findingorder
+License: Expat
+
+Files: misc/synology.py
+Copyright:
+ (C) github.com/Enantiomerie
+License: Expat
+
+Files: misc/watcher.py
+Copyright:
+ (C) 2019 Ian Alexander: https://github.com/ianalexander
+ (C) 2020 James R. Barlow
+License: Expat
+
+Files: misc/webservice.py
+Copyright: (C) 2019 James R. Barlow
+License: AGPL-3+
Files: docs tests/resources/*
Copyright: (C) 2013-2018 James R. Barlow
License: CC-BY-SA-4.0
+Files: docs/images/bitmap_vs_svg.svg
+Copyright: (C) 2006 Yug
+License: CC-BY-SA-2.5
+
Files: src/ocrmypdf/hocrtransform.py
Copyright: (C) 2010 Jonathan Brinley
(C) 2013-14 Julien Pfefferkorn
(C) 2015-16 James R. Barlow
License: Expat
-Files: src/ocrmypdf/pdfa.py
-Copyright: (C) 2015 James R. Barlow
- (C) 1986-2017 The authors of GhostScript
-License: GPL-3+
-
Files: src/ocrmypdf/_unicodefun.py
Copyright: (C) 2014 Armin Ronacher
(C) 2017 James R. Barlow
License: BSD-3-clause
-Files: tests/spoof/*
+Files: tests/plugins/*
Copyright: (C) 2016, 2017, 2016-2018 James R. Barlow
License: Expat
@@ -82,12 +117,17 @@ License: CC-BY-SA-3.0
Files: tests/resources/typewriter.png tests/resources/2400dpi.pdf
Copyright: (C) 2005 Ellywa
License: GFDL-1.2+ or CC-BY-SA-1.0 or CC-BY-SA-2.0 or CC-BY-SA-2.5 or CC-BY-SA-3.0
+Comment:
+ Obtained from: https://commons.wikimedia.org/wiki/File:Triumph.typewriter_text_Linzensoep.gif
Files: tests/resources/overlay.pdf
Copyright: (C) 2017 Max Anderson
License: Expat
-Files: tests/resources/baiona*.png
+Files:
+ tests/resources/baiona*.png
+ tests/resources/baiona*.jpg
+ tests/resources/link.pdf
Copyright: (C) 2014 Euskaldunaa
License: CC-BY-SA-4.0
@@ -95,11 +135,12 @@ Files: tests/resources/vector.pdf
Copyright: (C) 2018 Catscratch
License: Expat
-Files: test/resources/enron*.pdf
-Copyright: EnronData.org
-License: CC-BY-3.0
- See: https://enrondata.readthedocs.io/en/latest/data/edo-enron-email-pst-dataset/
-Comment: Unprocessed.
+Files: tests/resources/3small.pdf
+Copyright: (C) 2014 Euskaldunaa
+ (C) 2017 James R. Barlow
+ (C) 2005 Ellywa
+License: CC-BY-SA-4.0 and (GFDL-1.2+ or CC-BY-SA-1.0 or CC-BY-SA-2.0 or CC-BY-SA-2.5 or CC-BY-SA-3.0)
+Comment: concatenation of baiona_gray.png, crom.png and typewriter.png/2400dpi.pdf
Files: src/ocrmypdf/data/sRGB.icc
Copyright: Kai-Uwe Behrmann
@@ -113,6 +154,13 @@ Files: debian/*
Copyright: (C) 2016 Sean Whitton
License: GPL-3+
+License: MPL-2.0
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0.
+ .
+ On Debian systems the full text of the MPL-2.0 can be found in
+ /usr/share/common-licenses/MPL-2.0.
+
License: GPL-3+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -130,6 +178,669 @@ License: GPL-3+
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
+License: AGPL-3+
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+ .
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+ .
+ Preamble
+ .
+ The GNU Affero General Public License is a free, copyleft license for
+ software and other kinds of works, specifically designed to ensure
+ cooperation with the community in the case of network server software.
+ .
+ The licenses for most software and other practical works are designed
+ to take away your freedom to share and change the works. By contrast,
+ our General Public Licenses are intended to guarantee your freedom to
+ share and change all versions of a program--to make sure it remains free
+ software for all its users.
+ .
+ When we speak of free software, we are referring to freedom, not
+ price. Our General Public Licenses are designed to make sure that you
+ have the freedom to distribute copies of free software (and charge for
+ them if you wish), that you receive source code or can get it if you
+ want it, that you can change the software or use pieces of it in new
+ free programs, and that you know you can do these things.
+ .
+ Developers that use our General Public Licenses protect your rights
+ with two steps: (1) assert copyright on the software, and (2) offer
+ you this License which gives you legal permission to copy, distribute
+ and/or modify the software.
+ .
+ A secondary benefit of defending all users' freedom is that
+ improvements made in alternate versions of the program, if they
+ receive widespread use, become available for other developers to
+ incorporate. Many developers of free software are heartened and
+ encouraged by the resulting cooperation. However, in the case of
+ software used on network servers, this result may fail to come about.
+ The GNU General Public License permits making a modified version and
+ letting the public access it on a server without ever releasing its
+ source code to the public.
+ .
+ The GNU Affero General Public License is designed specifically to
+ ensure that, in such cases, the modified source code becomes available
+ to the community. It requires the operator of a network server to
+ provide the source code of the modified version running there to the
+ users of that server. Therefore, public use of a modified version, on
+ a publicly accessible server, gives the public access to the source
+ code of the modified version.
+ .
+ An older license, called the Affero General Public License and
+ published by Affero, was designed to accomplish similar goals. This is
+ a different license, not a version of the Affero GPL, but Affero has
+ released a new version of the Affero GPL which permits relicensing under
+ this license.
+ .
+ The precise terms and conditions for copying, distribution and
+ modification follow.
+ .
+ TERMS AND CONDITIONS
+ .
+ 0. Definitions.
+ .
+ "This License" refers to version 3 of the GNU Affero General Public License.
+ .
+ "Copyright" also means copyright-like laws that apply to other kinds of
+ works, such as semiconductor masks.
+ .
+ "The Program" refers to any copyrightable work licensed under this
+ License. Each licensee is addressed as "you". "Licensees" and
+ "recipients" may be individuals or organizations.
+ .
+ To "modify" a work means to copy from or adapt all or part of the work
+ in a fashion requiring copyright permission, other than the making of an
+ exact copy. The resulting work is called a "modified version" of the
+ earlier work or a work "based on" the earlier work.
+ .
+ A "covered work" means either the unmodified Program or a work based
+ on the Program.
+ .
+ To "propagate" a work means to do anything with it that, without
+ permission, would make you directly or secondarily liable for
+ infringement under applicable copyright law, except executing it on a
+ computer or modifying a private copy. Propagation includes copying,
+ distribution (with or without modification), making available to the
+ public, and in some countries other activities as well.
+ .
+ To "convey" a work means any kind of propagation that enables other
+ parties to make or receive copies. Mere interaction with a user through
+ a computer network, with no transfer of a copy, is not conveying.
+ .
+ An interactive user interface displays "Appropriate Legal Notices"
+ to the extent that it includes a convenient and prominently visible
+ feature that (1) displays an appropriate copyright notice, and (2)
+ tells the user that there is no warranty for the work (except to the
+ extent that warranties are provided), that licensees may convey the
+ work under this License, and how to view a copy of this License. If
+ the interface presents a list of user commands or options, such as a
+ menu, a prominent item in the list meets this criterion.
+ .
+ 1. Source Code.
+ .
+ The "source code" for a work means the preferred form of the work
+ for making modifications to it. "Object code" means any non-source
+ form of a work.
+ .
+ A "Standard Interface" means an interface that either is an official
+ standard defined by a recognized standards body, or, in the case of
+ interfaces specified for a particular programming language, one that
+ is widely used among developers working in that language.
+ .
+ The "System Libraries" of an executable work include anything, other
+ than the work as a whole, that (a) is included in the normal form of
+ packaging a Major Component, but which is not part of that Major
+ Component, and (b) serves only to enable use of the work with that
+ Major Component, or to implement a Standard Interface for which an
+ implementation is available to the public in source code form. A
+ "Major Component", in this context, means a major essential component
+ (kernel, window system, and so on) of the specific operating system
+ (if any) on which the executable work runs, or a compiler used to
+ produce the work, or an object code interpreter used to run it.
+ .
+ The "Corresponding Source" for a work in object code form means all
+ the source code needed to generate, install, and (for an executable
+ work) run the object code and to modify the work, including scripts to
+ control those activities. However, it does not include the work's
+ System Libraries, or general-purpose tools or generally available free
+ programs which are used unmodified in performing those activities but
+ which are not part of the work. For example, Corresponding Source
+ includes interface definition files associated with source files for
+ the work, and the source code for shared libraries and dynamically
+ linked subprograms that the work is specifically designed to require,
+ such as by intimate data communication or control flow between those
+ subprograms and other parts of the work.
+ .
+ The Corresponding Source need not include anything that users
+ can regenerate automatically from other parts of the Corresponding
+ Source.
+ .
+ The Corresponding Source for a work in source code form is that
+ same work.
+ .
+ 2. Basic Permissions.
+ .
+ All rights granted under this License are granted for the term of
+ copyright on the Program, and are irrevocable provided the stated
+ conditions are met. This License explicitly affirms your unlimited
+ permission to run the unmodified Program. The output from running a
+ covered work is covered by this License only if the output, given its
+ content, constitutes a covered work. This License acknowledges your
+ rights of fair use or other equivalent, as provided by copyright law.
+ .
+ You may make, run and propagate covered works that you do not
+ convey, without conditions so long as your license otherwise remains
+ in force. You may convey covered works to others for the sole purpose
+ of having them make modifications exclusively for you, or provide you
+ with facilities for running those works, provided that you comply with
+ the terms of this License in conveying all material for which you do
+ not control copyright. Those thus making or running the covered works
+ for you must do so exclusively on your behalf, under your direction
+ and control, on terms that prohibit them from making any copies of
+ your copyrighted material outside their relationship with you.
+ .
+ Conveying under any other circumstances is permitted solely under
+ the conditions stated below. Sublicensing is not allowed; section 10
+ makes it unnecessary.
+ .
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+ .
+ No covered work shall be deemed part of an effective technological
+ measure under any applicable law fulfilling obligations under article
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
+ similar laws prohibiting or restricting circumvention of such
+ measures.
+ .
+ When you convey a covered work, you waive any legal power to forbid
+ circumvention of technological measures to the extent such circumvention
+ is effected by exercising rights under this License with respect to
+ the covered work, and you disclaim any intention to limit operation or
+ modification of the work as a means of enforcing, against the work's
+ users, your or third parties' legal rights to forbid circumvention of
+ technological measures.
+ .
+ 4. Conveying Verbatim Copies.
+ .
+ You may convey verbatim copies of the Program's source code as you
+ receive it, in any medium, provided that you conspicuously and
+ appropriately publish on each copy an appropriate copyright notice;
+ keep intact all notices stating that this License and any
+ non-permissive terms added in accord with section 7 apply to the code;
+ keep intact all notices of the absence of any warranty; and give all
+ recipients a copy of this License along with the Program.
+ .
+ You may charge any price or no price for each copy that you convey,
+ and you may offer support or warranty protection for a fee.
+ .
+ 5. Conveying Modified Source Versions.
+ .
+ You may convey a work based on the Program, or the modifications to
+ produce it from the Program, in the form of source code under the
+ terms of section 4, provided that you also meet all of these conditions:
+ .
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+ .
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+ .
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+ .
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+ .
+ A compilation of a covered work with other separate and independent
+ works, which are not by their nature extensions of the covered work,
+ and which are not combined with it such as to form a larger program,
+ in or on a volume of a storage or distribution medium, is called an
+ "aggregate" if the compilation and its resulting copyright are not
+ used to limit the access or legal rights of the compilation's users
+ beyond what the individual works permit. Inclusion of a covered work
+ in an aggregate does not cause this License to apply to the other
+ parts of the aggregate.
+ .
+ 6. Conveying Non-Source Forms.
+ .
+ You may convey a covered work in object code form under the terms
+ of sections 4 and 5, provided that you also convey the
+ machine-readable Corresponding Source under the terms of this License,
+ in one of these ways:
+ .
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+ .
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+ .
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+ .
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+ .
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+ .
+ A separable portion of the object code, whose source code is excluded
+ from the Corresponding Source as a System Library, need not be
+ included in conveying the object code work.
+ .
+ A "User Product" is either (1) a "consumer product", which means any
+ tangible personal property which is normally used for personal, family,
+ or household purposes, or (2) anything designed or sold for incorporation
+ into a dwelling. In determining whether a product is a consumer product,
+ doubtful cases shall be resolved in favor of coverage. For a particular
+ product received by a particular user, "normally used" refers to a
+ typical or common use of that class of product, regardless of the status
+ of the particular user or of the way in which the particular user
+ actually uses, or expects or is expected to use, the product. A product
+ is a consumer product regardless of whether the product has substantial
+ commercial, industrial or non-consumer uses, unless such uses represent
+ the only significant mode of use of the product.
+ .
+ "Installation Information" for a User Product means any methods,
+ procedures, authorization keys, or other information required to install
+ and execute modified versions of a covered work in that User Product from
+ a modified version of its Corresponding Source. The information must
+ suffice to ensure that the continued functioning of the modified object
+ code is in no case prevented or interfered with solely because
+ modification has been made.
+ .
+ If you convey an object code work under this section in, or with, or
+ specifically for use in, a User Product, and the conveying occurs as
+ part of a transaction in which the right of possession and use of the
+ User Product is transferred to the recipient in perpetuity or for a
+ fixed term (regardless of how the transaction is characterized), the
+ Corresponding Source conveyed under this section must be accompanied
+ by the Installation Information. But this requirement does not apply
+ if neither you nor any third party retains the ability to install
+ modified object code on the User Product (for example, the work has
+ been installed in ROM).
+ .
+ The requirement to provide Installation Information does not include a
+ requirement to continue to provide support service, warranty, or updates
+ for a work that has been modified or installed by the recipient, or for
+ the User Product in which it has been modified or installed. Access to a
+ network may be denied when the modification itself materially and
+ adversely affects the operation of the network or violates the rules and
+ protocols for communication across the network.
+ .
+ Corresponding Source conveyed, and Installation Information provided,
+ in accord with this section must be in a format that is publicly
+ documented (and with an implementation available to the public in
+ source code form), and must require no special password or key for
+ unpacking, reading or copying.
+ .
+ 7. Additional Terms.
+ .
+ "Additional permissions" are terms that supplement the terms of this
+ License by making exceptions from one or more of its conditions.
+ Additional permissions that are applicable to the entire Program shall
+ be treated as though they were included in this License, to the extent
+ that they are valid under applicable law. If additional permissions
+ apply only to part of the Program, that part may be used separately
+ under those permissions, but the entire Program remains governed by
+ this License without regard to the additional permissions.
+ .
+ When you convey a copy of a covered work, you may at your option
+ remove any additional permissions from that copy, or from any part of
+ it. (Additional permissions may be written to require their own
+ removal in certain cases when you modify the work.) You may place
+ additional permissions on material, added by you to a covered work,
+ for which you have or can give appropriate copyright permission.
+ .
+ Notwithstanding any other provision of this License, for material you
+ add to a covered work, you may (if authorized by the copyright holders of
+ that material) supplement the terms of this License with terms:
+ .
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+ .
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+ .
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+ .
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+ .
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+ .
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+ .
+ All other non-permissive additional terms are considered "further
+ restrictions" within the meaning of section 10. If the Program as you
+ received it, or any part of it, contains a notice stating that it is
+ governed by this License along with a term that is a further
+ restriction, you may remove that term. If a license document contains
+ a further restriction but permits relicensing or conveying under this
+ License, you may add to a covered work material governed by the terms
+ of that license document, provided that the further restriction does
+ not survive such relicensing or conveying.
+ .
+ If you add terms to a covered work in accord with this section, you
+ must place, in the relevant source files, a statement of the
+ additional terms that apply to those files, or a notice indicating
+ where to find the applicable terms.
+ .
+ Additional terms, permissive or non-permissive, may be stated in the
+ form of a separately written license, or stated as exceptions;
+ the above requirements apply either way.
+ .
+ 8. Termination.
+ .
+ You may not propagate or modify a covered work except as expressly
+ provided under this License. Any attempt otherwise to propagate or
+ modify it is void, and will automatically terminate your rights under
+ this License (including any patent licenses granted under the third
+ paragraph of section 11).
+ .
+ However, if you cease all violation of this License, then your
+ license from a particular copyright holder is reinstated (a)
+ provisionally, unless and until the copyright holder explicitly and
+ finally terminates your license, and (b) permanently, if the copyright
+ holder fails to notify you of the violation by some reasonable means
+ prior to 60 days after the cessation.
+ .
+ Moreover, your license from a particular copyright holder is
+ reinstated permanently if the copyright holder notifies you of the
+ violation by some reasonable means, this is the first time you have
+ received notice of violation of this License (for any work) from that
+ copyright holder, and you cure the violation prior to 30 days after
+ your receipt of the notice.
+ .
+ Termination of your rights under this section does not terminate the
+ licenses of parties who have received copies or rights from you under
+ this License. If your rights have been terminated and not permanently
+ reinstated, you do not qualify to receive new licenses for the same
+ material under section 10.
+ .
+ 9. Acceptance Not Required for Having Copies.
+ .
+ You are not required to accept this License in order to receive or
+ run a copy of the Program. Ancillary propagation of a covered work
+ occurring solely as a consequence of using peer-to-peer transmission
+ to receive a copy likewise does not require acceptance. However,
+ nothing other than this License grants you permission to propagate or
+ modify any covered work. These actions infringe copyright if you do
+ not accept this License. Therefore, by modifying or propagating a
+ covered work, you indicate your acceptance of this License to do so.
+ .
+ 10. Automatic Licensing of Downstream Recipients.
+ .
+ Each time you convey a covered work, the recipient automatically
+ receives a license from the original licensors, to run, modify and
+ propagate that work, subject to this License. You are not responsible
+ for enforcing compliance by third parties with this License.
+ .
+ An "entity transaction" is a transaction transferring control of an
+ organization, or substantially all assets of one, or subdividing an
+ organization, or merging organizations. If propagation of a covered
+ work results from an entity transaction, each party to that
+ transaction who receives a copy of the work also receives whatever
+ licenses to the work the party's predecessor in interest had or could
+ give under the previous paragraph, plus a right to possession of the
+ Corresponding Source of the work from the predecessor in interest, if
+ the predecessor has it or can get it with reasonable efforts.
+ .
+ You may not impose any further restrictions on the exercise of the
+ rights granted or affirmed under this License. For example, you may
+ not impose a license fee, royalty, or other charge for exercise of
+ rights granted under this License, and you may not initiate litigation
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
+ any patent claim is infringed by making, using, selling, offering for
+ sale, or importing the Program or any portion of it.
+ .
+ 11. Patents.
+ .
+ A "contributor" is a copyright holder who authorizes use under this
+ License of the Program or a work on which the Program is based. The
+ work thus licensed is called the contributor's "contributor version".
+ .
+ A contributor's "essential patent claims" are all patent claims
+ owned or controlled by the contributor, whether already acquired or
+ hereafter acquired, that would be infringed by some manner, permitted
+ by this License, of making, using, or selling its contributor version,
+ but do not include claims that would be infringed only as a
+ consequence of further modification of the contributor version. For
+ purposes of this definition, "control" includes the right to grant
+ patent sublicenses in a manner consistent with the requirements of
+ this License.
+ .
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+ patent license under the contributor's essential patent claims, to
+ make, use, sell, offer for sale, import and otherwise run, modify and
+ propagate the contents of its contributor version.
+ .
+ In the following three paragraphs, a "patent license" is any express
+ agreement or commitment, however denominated, not to enforce a patent
+ (such as an express permission to practice a patent or covenant not to
+ sue for patent infringement). To "grant" such a patent license to a
+ party means to make such an agreement or commitment not to enforce a
+ patent against the party.
+ .
+ If you convey a covered work, knowingly relying on a patent license,
+ and the Corresponding Source of the work is not available for anyone
+ to copy, free of charge and under the terms of this License, through a
+ publicly available network server or other readily accessible means,
+ then you must either (1) cause the Corresponding Source to be so
+ available, or (2) arrange to deprive yourself of the benefit of the
+ patent license for this particular work, or (3) arrange, in a manner
+ consistent with the requirements of this License, to extend the patent
+ license to downstream recipients. "Knowingly relying" means you have
+ actual knowledge that, but for the patent license, your conveying the
+ covered work in a country, or your recipient's use of the covered work
+ in a country, would infringe one or more identifiable patents in that
+ country that you have reason to believe are valid.
+ .
+ If, pursuant to or in connection with a single transaction or
+ arrangement, you convey, or propagate by procuring conveyance of, a
+ covered work, and grant a patent license to some of the parties
+ receiving the covered work authorizing them to use, propagate, modify
+ or convey a specific copy of the covered work, then the patent license
+ you grant is automatically extended to all recipients of the covered
+ work and works based on it.
+ .
+ A patent license is "discriminatory" if it does not include within
+ the scope of its coverage, prohibits the exercise of, or is
+ conditioned on the non-exercise of one or more of the rights that are
+ specifically granted under this License. You may not convey a covered
+ work if you are a party to an arrangement with a third party that is
+ in the business of distributing software, under which you make payment
+ to the third party based on the extent of your activity of conveying
+ the work, and under which the third party grants, to any of the
+ parties who would receive the covered work from you, a discriminatory
+ patent license (a) in connection with copies of the covered work
+ conveyed by you (or copies made from those copies), or (b) primarily
+ for and in connection with specific products or compilations that
+ contain the covered work, unless you entered into that arrangement,
+ or that patent license was granted, prior to 28 March 2007.
+ .
+ Nothing in this License shall be construed as excluding or limiting
+ any implied license or other defenses to infringement that may
+ otherwise be available to you under applicable patent law.
+ .
+ 12. No Surrender of Others' Freedom.
+ .
+ If conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License. If you cannot convey a
+ covered work so as to satisfy simultaneously your obligations under this
+ License and any other pertinent obligations, then as a consequence you may
+ not convey it at all. For example, if you agree to terms that obligate you
+ to collect a royalty for further conveying from those to whom you convey
+ the Program, the only way you could satisfy both those terms and this
+ License would be to refrain entirely from conveying the Program.
+ .
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+ .
+ Notwithstanding any other provision of this License, if you modify the
+ Program, your modified version must prominently offer all users
+ interacting with it remotely through a computer network (if your version
+ supports such interaction) an opportunity to receive the Corresponding
+ Source of your version by providing access to the Corresponding Source
+ from a network server at no charge, through some standard or customary
+ means of facilitating copying of software. This Corresponding Source
+ shall include the Corresponding Source for any work covered by version 3
+ of the GNU General Public License that is incorporated pursuant to the
+ following paragraph.
+ .
+ Notwithstanding any other provision of this License, you have
+ permission to link or combine any covered work with a work licensed
+ under version 3 of the GNU General Public License into a single
+ combined work, and to convey the resulting work. The terms of this
+ License will continue to apply to the part which is the covered work,
+ but the work with which it is combined will remain governed by version
+ 3 of the GNU General Public License.
+ .
+ 14. Revised Versions of this License.
+ .
+ The Free Software Foundation may publish revised and/or new versions of
+ the GNU Affero General Public License from time to time. Such new versions
+ will be similar in spirit to the present version, but may differ in detail to
+ address new problems or concerns.
+ .
+ Each version is given a distinguishing version number. If the
+ Program specifies that a certain numbered version of the GNU Affero General
+ Public License "or any later version" applies to it, you have the
+ option of following the terms and conditions either of that numbered
+ version or of any later version published by the Free Software
+ Foundation. If the Program does not specify a version number of the
+ GNU Affero General Public License, you may choose any version ever published
+ by the Free Software Foundation.
+ .
+ If the Program specifies that a proxy can decide which future
+ versions of the GNU Affero General Public License can be used, that proxy's
+ public statement of acceptance of a version permanently authorizes you
+ to choose that version for the Program.
+ .
+ Later license versions may give you additional or different
+ permissions. However, no additional obligations are imposed on any
+ author or copyright holder as a result of your choosing to follow a
+ later version.
+ .
+ 15. Disclaimer of Warranty.
+ .
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+ .
+ 16. Limitation of Liability.
+ .
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGES.
+ .
+ 17. Interpretation of Sections 15 and 16.
+ .
+ If the disclaimer of warranty and limitation of liability provided
+ above cannot be given local legal effect according to their terms,
+ reviewing courts shall apply local law that most closely approximates
+ an absolute waiver of all civil liability in connection with the
+ Program, unless a warranty or assumption of liability accompanies a
+ copy of the Program in return for a fee.
+ .
+ END OF TERMS AND CONDITIONS
+ .
+ How to Apply These Terms to Your New Programs
+ .
+ If you develop a new program, and you want it to be of the greatest
+ possible use to the public, the best way to achieve this is to make it
+ free software which everyone can redistribute and change under these terms.
+ .
+ To do so, attach the following notices to the program. It is safest
+ to attach them to the start of each source file to most effectively
+ state the exclusion of warranty; and each file should have at least
+ the "copyright" line and a pointer to where the full notice is found.
+ .
+
+ Copyright (C)
+ .
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+ .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+ .
+ Also add information on how to contact you by electronic and paper mail.
+ .
+ If your software can interact with users remotely through a computer
+ network, you should also make sure that it provides a way for users to
+ get its source. For example, if your program is a web application, its
+ interface could display a "Source" link that leads users to an archive
+ of the code. There are many ways you could offer source, and different
+ solutions will be better for different programs; see section 13 for the
+ specific requirements.
+ .
+ You should also get your employer (if you work as a programmer) or school,
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
+ For more information on this, and how to apply and follow the GNU AGPL, see
+ .
+
License: Expat
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/docs/advanced.rst b/docs/advanced.rst
index da1f1675..09a7376a 100644
--- a/docs/advanced.rst
+++ b/docs/advanced.rst
@@ -1,16 +1,34 @@
+=================
Advanced features
=================
Control of unpaper
-------------------
+==================
-OCRmyPDF uses ``unpaper`` to provide the implementation of the ``--clean`` and ``--clean-final`` arguments. `unpaper `_ provides a variety of image processing filters to improve images.
+OCRmyPDF uses ``unpaper`` to provide the implementation of the
+``--clean`` and ``--clean-final`` arguments.
+`unpaper `__
+provides a variety of image processing filters to improve images.
-By default, OCRmyPDF uses only ``unpaper`` arguments that were found to be safe to use on almost all files without having to inspect every page of the file afterwards. This is particularly true when only ``--clean`` is used, since that instructs OCRmyPDF to only clean the image before OCR and not the final image.
+By default, OCRmyPDF uses only ``unpaper`` arguments that were found to
+be safe to use on almost all files without having to inspect every page
+of the file afterwards. This is particularly true when only ``--clean``
+is used, since that instructs OCRmyPDF to only clean the image before
+OCR and not the final image.
-However, if you wish to use the more aggressive options in ``unpaper``, you may use ``--unpaper-args '...'`` to override the OCRmyPDF's defaults and forward other arguments to unpaper. This option will forward arguments to ``unpaper`` without any knowledge of what that program considers to be valid arguments. The string of arguments must be quoted as shown in the examples below. No filename arguments may be included. OCRmyPDF will assume it can append input and output filename of intermediate images to the ``--unpaper-args`` string.
+However, if you wish to use the more aggressive options in ``unpaper``,
+you may use ``--unpaper-args '...'`` to override the OCRmyPDF's defaults
+and forward other arguments to unpaper. This option will forward
+arguments to ``unpaper`` without any knowledge of what that program
+considers to be valid arguments. The string of arguments must be quoted
+as shown in the examples below. No filename arguments may be included.
+OCRmyPDF will assume it can append input and output filename of
+intermediate images to the ``--unpaper-args`` string.
-In this example, we tell ``unpaper`` to expect two pages of text on a sheet (image), such as occurs when two facing pages of a book are scanned. ``unpaper`` uses this information to deskew each independently and clean up the margins of both.
+In this example, we tell ``unpaper`` to expect two pages of text on a
+sheet (image), such as occurs when two facing pages of a book are
+scanned. ``unpaper`` uses this information to deskew each independently
+and clean up the margins of both.
.. code-block:: bash
@@ -19,40 +37,71 @@ In this example, we tell ``unpaper`` to expect two pages of text on a sheet (ima
.. warning::
- Some ``unpaper`` features will reposition text within the image. ``--clean-final`` is recommended to avoid this issue.
+ Some ``unpaper`` features will reposition text within the image.
+ ``--clean-final`` is recommended to avoid this issue.
.. warning::
- Some ``unpaper`` features cause multiple input or output files to be consumed or produced. OCRmyPDF requires ``unpaper`` to consume one file and produce one file. An deviation from that condition will result in errors.
+ Some ``unpaper`` features cause multiple input or output files to be
+ consumed or produced. OCRmyPDF requires ``unpaper`` to consume one
+ file and produce one file. An deviation from that condition will
+ result in errors.
.. note::
- ``unpaper`` uses uncompressed PBM/PGM/PPM files for its intermediate files. For large images or documents, it can take a lot of temporary disk space.
+ ``unpaper`` uses uncompressed PBM/PGM/PPM files for its intermediate
+ files. For large images or documents, it can take a lot of temporary
+ disk space.
Control of OCR options
-----------------------
+======================
-OCRmyPDF provides many features to control the behavior of the OCR engine, Tesseract.
+OCRmyPDF provides many features to control the behavior of the OCR
+engine, Tesseract.
When OCR is skipped
-"""""""""""""""""""
+-------------------
-If a page in a PDF seems to have text, by default OCRmyPDF will exit without modifying the PDF. This is to ensure that PDFs that were previously OCRed or were "born digital" rather than scanned are not processed.
+If a page in a PDF seems to have text, by default OCRmyPDF will exit
+without modifying the PDF. This is to ensure that PDFs that were
+previously OCRed or were "born digital" rather than scanned are not
+processed.
-If ``--skip-text`` is issued, then no OCR will be performed on pages that already have text. The page will be copied to the output. This may be useful for documents that contain both "born digital" and scanned content, or to use OCRmyPDF to normalize and convert to PDF/A regardless of their contents.
+If ``--skip-text`` is issued, then no OCR will be performed on pages
+that already have text. The page will be copied to the output. This may
+be useful for documents that contain both "born digital" and scanned
+content, or to use OCRmyPDF to normalize and convert to PDF/A regardless
+of their contents.
-If ``--redo-ocr`` is issued, then a detailed text analysis is performed. Text is categorized as either visible or invisible. Invisible text (OCR) is stripped out. Then an image of each page is created with visible text masked out. The page image is sent for OCR, and any additional text is inserted as OCR. If a file contains a mix of text and bitmap images that contain text, OCRmyPDF will locate the additional text in images without disrupting the existing text.
+If ``--redo-ocr`` is issued, then a detailed text analysis is performed.
+Text is categorized as either visible or invisible. Invisible text (OCR)
+is stripped out. Then an image of each page is created with visible text
+masked out. The page image is sent for OCR, and any additional text is
+inserted as OCR. If a file contains a mix of text and bitmap images that
+contain text, OCRmyPDF will locate the additional text in images without
+disrupting the existing text.
-If ``--force-ocr`` is issued, then all pages will be rasterized to images, discarding any hidden OCR text, and rasterizing any printable text. This is useful for redoing OCR, for fixing OCR text with a damaged character map (text is selectable but not searchable), and destroying redacted information. Any forms and vector graphics will be rasterized as well.
+If ``--force-ocr`` is issued, then all pages will be rasterized to
+images, discarding any hidden OCR text, and rasterizing any printable
+text. This is useful for redoing OCR, for fixing OCR text with a damaged
+character map (text is selectable but not searchable), and destroying
+redacted information. Any forms and vector graphics will be rasterized
+as well.
Time and image size limits
-""""""""""""""""""""""""""
+--------------------------
-By default, OCRmyPDF permits tesseract to run for three minutes (180 seconds) per page. This is usually more than enough time to find all text on a reasonably sized page with modern hardware.
+By default, OCRmyPDF permits tesseract to run for three minutes (180
+seconds) per page. This is usually more than enough time to find all
+text on a reasonably sized page with modern hardware.
-If a page is skipped, it will be inserted without OCR. If preprocessing was requested, the preprocessed image layer will be inserted.
+If a page is skipped, it will be inserted without OCR. If preprocessing
+was requested, the preprocessed image layer will be inserted.
-If you want to adjust the amount of time spent on OCR, change ``--tesseract-timeout``. You can also automatically skip images that exceed a certain number of megapixels with ``--skip-big``. (A 300 DPI, 8.5×11" page is 8.4 megapixels.)
+If you want to adjust the amount of time spent on OCR, change
+``--tesseract-timeout``. You can also automatically skip images that
+exceed a certain number of megapixels with ``--skip-big``. (A 300 DPI,
+8.5×11" page is 8.4 megapixels.)
.. code-block:: bash
@@ -60,21 +109,26 @@ If you want to adjust the amount of time spent on OCR, change ``--tesseract-time
ocrmypdf --tesseract-timeout 300 --skip-big 50 bigfile.pdf output.pdf
Overriding default tesseract
-""""""""""""""""""""""""""""
+----------------------------
OCRmyPDF checks the system ``PATH`` for the ``tesseract`` binary.
-Some relevant environment variables that influence Tesseract's behavior include:
+Some relevant environment variables that influence Tesseract's behavior
+include:
.. envvar:: TESSDATA_PREFIX
- Overrides the path to Tesseract's data files. This can allow simultaneous installation of the "best" and "fast" training data sets. OCRmyPDF does not manage this environment variable.
+ Overrides the path to Tesseract's data files. This can allow
+ simultaneous installation of the "best" and "fast" training data
+ sets. OCRmyPDF does not manage this environment variable.
.. envvar:: OMP_THREAD_LIMIT
- Controls the number of threads Tesseract will use. OCRmyPDF will manage this environment if it is not already set. (Currently, it will set it to 1 because this gives the best results in testing.)
+ Controls the number of threads Tesseract will use. OCRmyPDF will
+ manage this environment variable if it is not already set.
-For example, if you have a development build of Tesseract don't wish to use the system installation, you can launch OCRmyPDF as follows:
+For example, if you have a development build of Tesseract don't wish to
+use the system installation, you can launch OCRmyPDF as follows:
.. code-block:: bash
@@ -83,26 +137,34 @@ For example, if you have a development build of Tesseract don't wish to use the
TESSDATA_PREFIX=/home/user/src/tesseract \
ocrmypdf input.pdf output.pdf
-In this example ``TESSDATA_PREFIX`` is required to redirect Tesseract to an alternate folder for its "tessdata" files.
+In this example ``TESSDATA_PREFIX`` is required to redirect Tesseract to
+an alternate folder for its "tessdata" files.
Overriding other support programs
-"""""""""""""""""""""""""""""""""
+---------------------------------
In addition to tesseract, OCRmyPDF uses the following external binaries:
-* ``gs`` (Ghostscript)
-* ``unpaper``
-* ``qpdf``
-
-In each case OCRmyPDF will search the ``PATH`` environment variable to locate the binaries.
+- ``gs`` (Ghostscript)
+- ``unpaper``
+- ``pngquant``
+- ``jbig2``
+In each case OCRmyPDF will search the ``PATH`` environment variable to
+locate the binaries.
Changing tesseract configuration variables
-""""""""""""""""""""""""""""""""""""""""""
+------------------------------------------
-You can override tesseract's default `control parameters `_ with a configuration file.
+You can override tesseract's default `control
+parameters `__
+with a configuration file.
-As an example, this configuration will disable Tesseract's dictionary for current language. Normally the dictionary is helpful for interpolating words that are unclear, but it may interfere with OCR if the document does not contain many words (for example, a list of part numbers).
+As an example, this configuration will disable Tesseract's dictionary
+for current language. Normally the dictionary is helpful for
+interpolating words that are unclear, but it may interfere with OCR if
+the document does not contain many words (for example, a list of part
+numbers).
Create a file named "no-dict.cfg" with these contents:
@@ -120,11 +182,11 @@ then run ocrmypdf as follows (along with any other desired arguments):
.. warning::
- Some combinations of control parameters will break Tesseract or break assumptions that OCRmyPDF makes about Tesseract's output.
-
+ Some combinations of control parameters will break Tesseract or break
+ assumptions that OCRmyPDF makes about Tesseract's output.
Changing the PDF renderer
--------------------------
+=========================
rasterizing
Converting a PDF to an image for display.
@@ -132,42 +194,63 @@ rasterizing
rendering
Creating a new PDF from other data (such as an existing PDF).
-
-OCRmyPDF has these PDF renderers: ``sandwich`` and ``hocr``. The renderer may be selected using ``--pdf-renderer``. The default is ``auto`` which lets OCRmyPDF select the renderer to use. Currently, ``auto`` always selects ``sandwich``.
+OCRmyPDF has these PDF renderers: ``sandwich`` and ``hocr``. The
+renderer may be selected using ``--pdf-renderer``. The default is
+``auto`` which lets OCRmyPDF select the renderer to use. Currently,
+``auto`` always selects ``sandwich``.
The ``sandwich`` renderer
-"""""""""""""""""""""""""
+-------------------------
-The ``sandwich`` renderer uses Tesseract's new text-only PDF feature, which produces a PDF page that lays out the OCR in invisible text. This page is then "sandwiched" onto the original PDF page, allowing lossless application of OCR even to PDF pages that contain other vector objects.
+The ``sandwich`` renderer uses Tesseract's new text-only PDF feature,
+which produces a PDF page that lays out the OCR in invisible text. This
+page is then "sandwiched" onto the original PDF page, allowing lossless
+application of OCR even to PDF pages that contain other vector objects.
-Currently this is the best renderer for most uses, however it is implemented in Tesseract so OCRmyPDF cannot influence it. Currently some problematic PDF viewers like Mozilla PDF.js and macOS Preview have problems with segmenting its text output, and mightrunseveralwordstogether.
+Currently this is the best renderer for most uses, however it is
+implemented in Tesseract so OCRmyPDF cannot influence it. Currently some
+problematic PDF viewers like Mozilla PDF.js and macOS Preview have
+problems with segmenting its text output, and
+mightrunseveralwordstogether.
-When image preprocessing features like ``--deskew`` are used, the original PDF will be rendered as a full page and the OCR layer will be placed on top.
+When image preprocessing features like ``--deskew`` are used, the
+original PDF will be rendered as a full page and the OCR layer will be
+placed on top.
The ``hocr`` renderer
-"""""""""""""""""""""
+---------------------
-The ``hocr`` renderer works with older versions of Tesseract. The image layer is copied from the original PDF page if possible, avoiding potentially lossy transcoding or loss of other PDF information. If preprocessing is specified, then the image layer is a new PDF.
+The ``hocr`` renderer works with older versions of Tesseract. The image
+layer is copied from the original PDF page if possible, avoiding
+potentially lossy transcoding or loss of other PDF information. If
+preprocessing is specified, then the image layer is a new PDF.
-Unlike ``sandwich`` this renderer is implemented within OCRmyPDF; anyone looking to customize how OCR is presented should look here. A major disadvantage of this renderer is it not capable of correctly handling text outside the Latin alphabet. Pull requests to improve the situation are welcome.
+Unlike ``sandwich`` this renderer is implemented within OCRmyPDF; anyone
+looking to customize how OCR is presented should look here. A major
+disadvantage of this renderer is it not capable of correctly handling
+text outside the Latin alphabet. Pull requests to improve the situation
+are welcome.
-Currently, this renderer has the best compatibility with Mozilla's PDF.js viewer.
+Currently, this renderer has the best compatibility with Mozilla's
+PDF.js viewer.
This works in all versions of Tesseract.
The ``tesseract`` renderer
-""""""""""""""""""""""""""
+--------------------------
-The ``tesseract`` renderer was removed. OCRmyPDF's new approach to text layer grafting makes it functionally equivalent to ``sandwich``.
+The ``tesseract`` renderer was removed. OCRmyPDF's new approach to text
+layer grafting makes it functionally equivalent to ``sandwich``.
Return code policy
-------------------
+==================
-OCRmyPDF writes all messages to ``stderr``. ``stdout`` is reserved for piping
-output files. ``stdin`` is reserved for piping input files.
+OCRmyPDF writes all messages to ``stderr``. ``stdout`` is reserved for
+piping output files. ``stdin`` is reserved for piping input files.
-The return codes generated by the OCRmyPDF are considered part of the stable
-user interface. They may be imported from ``ocrmypdf.exceptions``.
+The return codes generated by the OCRmyPDF are considered part of the
+stable user interface. They may be imported from
+``ocrmypdf.exceptions``.
.. list-table:: Return codes
:widths: 5 35 60
@@ -218,22 +301,44 @@ user interface. They may be imported from ``ocrmypdf.exceptions``.
Debugging the intermediate files
---------------------------------
+================================
-OCRmyPDF normally saves its intermediate results to a temporary folder and deletes this folder when it exits, whether it succeeded or failed.
+OCRmyPDF normally saves its intermediate results to a temporary folder
+and deletes this folder when it exits, whether it succeeded or failed.
-If the ``-k`` argument is issued on the command line, OCRmyPDF will keep the temporary folder and print the location, whether it succeeded or failed (provided the Python interpreter did not crash). An example message is:
+If the ``-k`` argument is issued on the command line, OCRmyPDF will keep
+the temporary folder and print the location, whether it succeeded or
+failed (provided the Python interpreter did not crash). An example
+message is:
.. code-block:: none
- Temporary working files saved at:
- /tmp/com.github.ocrmypdf.u20wpz07
+ Temporary working files retained at:
+ /tmp/ocrmypdf.io.u20wpz07
-The organization of this folder is an implementation detail and subject to change between releases. However the general organization is that working files on a per page basis have the page number as a prefix (starting with page 1), an infix indicates the processing stage, and a suffix indicates the file type. Some important files include:
+The organization of this folder is an implementation detail and subject
+to change between releases. However the general organization is that
+working files on a per page basis have the page number as a prefix
+(starting with page 1), an infix indicates the processing stage, and a
+suffix indicates the file type. Some important files include:
-* ``.page.png`` - what the input page looks like
-* ``.image`` - the image we will show the user if we are in a mode that changes the final appearance; may be in one of several image formats
-* ``.text.pdf`` - the OCR file; this will load as a blank page but should have visible text if checked with a tool like pdftotext or pdfminder.six
-* ``.ocr.png`` - the file that is sent to Tesseract for OCR; depending on arguments this may differ from the presentation image
-* ``layers.rendered.pdf`` - the composite PDF, before metadata repair and optimization
-* ``images/*`` - images extracted during the optimization process; here the prefix indicates a PDF object ID not a page number
+- ``_rasterize.png`` - what the input page looks like
+- ``_ocr.png`` - the file that is sent to Tesseract for OCR; depending
+ on arguments this may differ from the presentation image
+- ``_pp_deskew.png`` - the image, after deskewing
+- ``_pp_clean.png`` - the image, after cleaning with unpaper
+- ``_ocr_tess.pdf`` - the OCR file; appears as a blank page with invisible
+ text embedded
+- ``_ocr_tess.txt`` - the OCR text (not necessarily all text on the page,
+ if the page is mixed format)
+- ``fix_docinfo.pdf`` - a temporary file created to fix the PDF DocumentInfo
+ data structure
+- ``graft_layers.pdf`` - the rendered PDF with OCR layers grafted on
+- ``pdfa.pdf`` - ``graft_layers.pdf`` after conversion to PDF/A
+- ``pdfa.ps`` - a PostScript file used by Ghostscript for PDF/A conversion
+- ``optimize.pdf`` - the PDF generated before optimization
+- ``optimize.out.pdf`` - the PDF generated by optimization
+- ``origin`` - the input file
+- ``origin.pdf`` - the input file or the input image converted to PDF
+- ``images/*`` - images extracted during the optimization process; here
+ the prefix indicates a PDF object ID not a page number
diff --git a/docs/api.rst b/docs/api.rst
new file mode 100644
index 00000000..3459e8b8
--- /dev/null
+++ b/docs/api.rst
@@ -0,0 +1,117 @@
+======================
+Using the OCRmyPDF API
+======================
+
+OCRmyPDF originated as a command line program and continues to have this
+legacy, but parts of it can be imported and used in other Python
+applications.
+
+Some applications may want to consider running ocrmypdf from a
+subprocess call anyway, as this provides isolation of its activities.
+
+Example
+=======
+
+OCRmyPDF one high-level function to run its main engine from an
+application. The parameters are symmetric to the command line arguments
+and largely have the same functions.
+
+.. code-block:: python
+
+ import ocrmypdf
+
+ if __name__ == '__main__': # To ensure correct behavior on Windows and macOS
+ ocrmypdf.ocr('input.pdf', 'output.pdf', deskew=True)
+
+With a few exceptions, all of the command line arguments are available
+and may be passed as equivalent keywords.
+
+A few differences are that ``verbose`` and ``quiet`` are not available.
+Instead, output should be managed by configuring logging.
+
+Parent process requirements
+---------------------------
+
+The :func:`ocrmypdf.ocr` function runs OCRmyPDF similar to command line
+execution. To do this, it will:
+
+- create a monitoring thread
+- create worker processes (on Linux, forking itself; on Windows and macOS, by
+ spawning)
+- manage the signal flags of its worker processes
+- execute other subprocesses (forking and executing other programs)
+
+The Python process that calls ``ocrmypdf.ocr()`` must be sufficiently
+privileged to perform these actions.
+
+There is no currently no option to manage how jobs are scheduled other
+than the argument ``jobs=`` which will limit the number of worker
+processes.
+
+Creating a child process to call ``ocrmypdf.ocr()`` is suggested. That
+way your application will survive and remain interactive even if
+OCRmyPDF fails for any reason.
+
+Programs that call ``ocrmypdf.ocr()`` should also install a SIGBUS signal
+handler (except on Windows), to raise an exception if access to a memory
+mapped file fails. OCRmyPDF may use memory mapping.
+
+``ocrmypdf.ocr()`` will take a threading lock to prevent multiple runs of itself
+in the same Python interpreter process. This is not thread-safe, because of how
+OCRmyPDF's plugins and Python's library import system work. If you need to parallelize
+OCRmyPDF, use processes.
+
+.. warning::
+
+ On Windows and macOS, the script that calls ``ocrmypdf.ocr()`` must be
+ protected by an "ifmain" guard (``if __name__ == '__main__'``). If you do
+ not take at least one of these steps, process semantics will prevent
+ OCRmyPDF from working correctly.
+
+Logging
+-------
+
+OCRmyPDF will log under loggers named ``ocrmypdf``. In addition, it
+imports ``pdfminer`` and ``PIL``, both of which post log messages under
+those logging namespaces.
+
+You can configure the logging as desired for your application or call
+:func:`ocrmypdf.configure_logging` to configure logging the same way
+OCRmyPDF itself does. The command line parameters such as ``--quiet``
+and ``--verbose`` have no equivalents in the API; you must use the
+provided configuration function or do configuration in a way that suits
+your use case.
+
+Progress monitoring
+-------------------
+
+OCRmyPDF uses the ``tqdm`` package to implement its progress bars.
+:func:`ocrmypdf.configure_logging` will set up logging output to
+``sys.stderr`` in a way that is compatible with the display of the
+progress bar. Use ``ocrmypdf.ocr(...progress_bar=False)`` to disable
+the progress bar.
+
+Exceptions
+----------
+
+OCRmyPDF may throw standard Python exceptions, ``ocrmypdf.exceptions.*``
+exceptions, some exceptions related to multiprocessing, and
+``KeyboardInterrupt``. The parent process should provide an exception
+handler. OCRmyPDF will clean up its temporary files and worker processes
+automatically when an exception occurs.
+
+Programs that call OCRmyPDF should consider trapping KeyboardInterrupt
+so that they allow OCR to terminate with the whole program terminating.
+
+When OCRmyPDF succeeds conditionally, it returns an integer exit code.
+
+Reference
+---------
+
+.. autofunction:: ocrmypdf.ocr
+
+.. autoclass:: ocrmypdf.Verbosity
+ :members:
+ :undoc-members:
+
+.. autofunction:: ocrmypdf.configure_logging
diff --git a/docs/apiref.rst b/docs/apiref.rst
new file mode 100644
index 00000000..5a3bd488
--- /dev/null
+++ b/docs/apiref.rst
@@ -0,0 +1,55 @@
+=============
+API Reference
+=============
+
+This page summarizes the rest of the public API. Generally speaking this
+should mainly of interest to plugin developers.
+
+ocrmypdf
+========
+
+.. autoclass:: ocrmypdf.PageContext
+ :members:
+
+.. autoclass:: ocrmypdf.PdfContext
+ :members:
+
+ocrmypdf.exceptions
+===================
+
+.. automodule:: ocrmypdf.exceptions
+ :members:
+ :undoc-members:
+
+ocrmypdf.helpers
+================
+
+.. automodule:: ocrmypdf.helpers
+ :members:
+ :noindex: deprecated
+
+ .. autodecorator:: deprecated
+
+ocrmypdf.hocrtransform
+======================
+
+.. automodule:: ocrmypdf.hocrtransform
+ :members:
+
+ocrmypdf.pdfa
+=============
+
+.. automodule:: ocrmypdf.pdfa
+ :members:
+
+ocrmypdf.quality
+================
+
+.. automodule:: ocrmypdf.quality
+ :members:
+
+ocrmypdf.subprocess
+===================
+
+.. automodule:: ocrmypdf.subprocess
+ :members:
diff --git a/docs/batch.rst b/docs/batch.rst
index 6883e992..e8e97374 100644
--- a/docs/batch.rst
+++ b/docs/batch.rst
@@ -1,225 +1,217 @@
+================
Batch processing
================
-This article provides information about running OCRmyPDF on multiple files or configuring it as a service triggered by file system events.
+This article provides information about running OCRmyPDF on multiple
+files or configuring it as a service triggered by file system events.
Batch jobs
-----------
+==========
-Consider using the excellent `GNU Parallel `_ to apply OCRmyPDF to multiple files at once.
+Consider using the excellent `GNU
+Parallel `__ to apply OCRmyPDF
+to multiple files at once.
-Both ``parallel`` and ``ocrmypdf`` will try to use all available processors. To maximize parallelism without overloading your system with processes, consider using ``parallel -j 2`` to limit parallel to running two jobs at once.
+Both ``parallel`` and ``ocrmypdf`` will try to use all available
+processors. To maximize parallelism without overloading your system with
+processes, consider using ``parallel -j 2`` to limit parallel to running
+two jobs at once.
-This command will run all ocrmypdf all files named ``*.pdf`` in the current directory and write them to the previous created ``output/`` folder. It will not search subdirectories.
+This command will run all ocrmypdf all files named ``*.pdf`` in the
+current directory and write them to the previous created ``output/``
+folder. It will not search subdirectories.
-The ``--tag`` argument tells parallel to print the filename as a prefix whenever a message is printed, so that one can trace any errors to the file that produced them.
+The ``--tag`` argument tells parallel to print the filename as a prefix
+whenever a message is printed, so that one can trace any errors to the
+file that produced them.
.. code-block:: bash
- parallel --tag -j 2 ocrmypdf '{}' 'output/{}' ::: *.pdf
+ parallel --tag -j 2 ocrmypdf '{}' 'output/{}' ::: *.pdf
-OCRmyPDF automatically repairs PDFs before parsing and gathering information from them.
+OCRmyPDF automatically repairs PDFs before parsing and gathering
+information from them.
Directory trees
----------------
+===============
-This will walk through a directory tree and run OCR on all files in place, printing the output in a way that makes
+This will walk through a directory tree and run OCR on all files in
+place, printing the output in a way that makes
.. code-block:: bash
- find . -printf '%p' -name '*.pdf' -exec ocrmypdf '{}' '{}' \;
-
-Alternatively, with a docker container (mounts a volume to the container where the PDFs are stored):
+ find . -printf '%p' -name '*.pdf' -exec ocrmypdf '{}' '{}' \;
+
+Alternatively, with a docker container (mounts a volume to the container
+where the PDFs are stored):
.. code-block:: bash
- find . -printf '%p' -name '*.pdf' -exec docker run --rm -v : jbarlow83/ocrmypdf-alpine '/{}' '/{}' \;
+ find . -printf '%p' -name '*.pdf' -exec docker run --rm -v : jbarlow83/ocrmypdf '/{}' '/{}' \;
-This only runs one ``ocrmypdf`` process at a time. This variation uses ``find`` to create a directory list and ``parallel`` to parallelize runs of ``ocrmypdf``, again updating files in place.
+This only runs one ``ocrmypdf`` process at a time. This variation uses
+``find`` to create a directory list and ``parallel`` to parallelize runs
+of ``ocrmypdf``, again updating files in place.
.. code-block:: bash
- find . -name '*.pdf' | parallel --tag -j 2 ocrmypdf '{}' '{}'
+ find . -name '*.pdf' | parallel --tag -j 2 ocrmypdf '{}' '{}'
+In a Windows batch file, use
+
+.. code-block:: bat
+
+ for /r %%f in (*.pdf) do ocrmypdf %%f %%f
Sample script
-"""""""""""""
+-------------
-This user contributed script also provides an example of batch processing.
-
-.. code-block:: python
-
- #!/usr/bin/env python3
- # Walk through directory tree, replacing all files with OCR'd version
- # Contributed by DeliciousPickle@github
-
- import logging
- import os
- import subprocess
- import sys
-
- script_dir = os.path.dirname(os.path.realpath(__file__))
- print(script_dir + '/ocr-tree.py: Start')
-
- if len(sys.argv) > 1:
- start_dir = sys.argv[1]
- else:
- start_dir = '.'
-
- if len(sys.argv) > 2:
- log_file = sys.argv[2]
- else:
- log_file = script_dir + '/ocr-tree.log'
-
- logging.basicConfig(
- level=logging.INFO, format='%(asctime)s %(message)s',
- filename=log_file, filemode='w')
-
- 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
- print(full_path)
- cmd = ["ocrmypdf", "--deskew", filename, filename]
- logging.info(cmd)
- proc = subprocess.run(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- result = proc.stdout
- if proc.returncode == 6:
- print("Skipped document because it already contained text")
- elif proc.returncode == 0:
- print("OCR complete")
- logging.info(result)
-
-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.)
+This user contributed script also provides an example of batch
+processing.
+.. literalinclude:: ../misc/batch.py
+ :caption: misc/batch.py
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.run(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. Consulting work related to OCRmyPDF helps fund this open source project and all inquiries are appreciated.
-
-Hot (watched) folders
---------------------
-To set up a "hot folder" that will trigger OCR for every file inserted, use a program like Python `watchdog `_ (supports all major OS).
+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.
-One could then configure a scanner to automatically place scanned files in a hot folder, so that they will be queued for OCR and copied to the destination.
+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:: bash
+.. literalinclude:: ../misc/synology.py
+ :caption: misc/synology.py - Sample script for Synology DiskStations
- pip install watchdog
-
-watchdog installs the command line program ``watchmedo``, which can be told to run ``ocrmypdf`` on any .pdf added to the current directory (``.``) and place the result in the previously created ``out/`` folder.
-
-.. code-block:: bash
-
- cd hot-folder
- mkdir out
- watchmedo shell-command \
- --patterns="*.pdf" \
- --ignore-directories \
- --command='ocrmypdf "${watch_src_path}" "out/${watch_src_path}" ' \
- . # don't forget the final dot
-
-For more complex behavior you can write a Python script around to use the watchdog API.
-
-On file servers, you could configure watchmedo as a system service so it will run all the time.
-
-Caveats
-"""""""
-
-* ``watchmedo`` may not work properly on a networked file system, depending on the capabilities of the file system client and server.
-* This simple recipe does not filter for the type of file system event, so file copies, deletes and moves, and directory operations, will all be sent to ocrmypdf, producing errors in several cases. Disable your watched folder if you are doing anything other than copying files to it.
-* If the source and destination directory are the same, watchmedo may create an infinite loop.
-* On BSD, FreeBSD and older versions of macOS, you may need to increase the number of file descriptors to monitor more files, using ``ulimit -n 1024`` to watch a folder of up to 1024 files.
-
-Alternatives
-""""""""""""
-
-* `Watchman `_ is a more powerful alternative to ``watchmedo``.
-
-macOS Automator
+Huge batch jobs
---------------
-You can use the Automator app with macOS, to create a Workflow or Quick Action. Use a *Run Shell Script* action in your workflow. In the context of Automator, the ``PATH`` may be set differently your Terminal's ``PATH``; you may need to explicitly set the PATH to include ``ocrmypdf``. The following example may serve as a starting point:
+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.
-.. image:: images/macos-workflow.png
- :alt: Example macOS Automator script
+Hot (watched) folders
+=====================
+
+Watched folders with watcher.py
+-------------------------------
+
+OCRmyPDF has a folder watcher called watcher.py, which is currently included in source
+distributions but not part of the main program. It may be used natively or may run
+in a Docker container. Native instances tend to give better performance. watcher.py
+works on all platforms.
+
+Users may need to customize the script to meet their requirements.
+
+.. code-block:: bash
+
+ pip3 install -r requirements/watcher.txt
+
+ env OCR_INPUT_DIRECTORY=/mnt/input-pdfs \
+ OCR_OUTPUT_DIRECTORY=/mnt/output-pdfs \
+ OCR_OUTPUT_DIRECTORY_YEAR_MONTH=1 \
+ python3 watcher.py
+
+.. csv-table:: watcher.py environment variables
+ :header: "Environment variable", "Description"
+ :widths: 50, 50
+
+ "OCR_INPUT_DIRECTORY", "Set input directory to monitor (recursive)"
+ "OCR_OUTPUT_DIRECTORY", "Set output directory (should not be under input)"
+ "OCR_ON_SUCCESS_DELETE", "This will delete the input file if the exit code is 0 (OK)"
+ "OCR_OUTPUT_DIRECTORY_YEAR_MONTH", "This will place files in the output in ``{output}/{year}/{month}/{filename}``"
+ "OCR_DESKEW", "Apply deskew to crooked input PDFs"
+ "OCR_JSON_SETTINGS", "A JSON string specifying any other arguments for ``ocrmypdf.ocr``, e.g. ``'OCR_JSON_SETTINGS={""rotate_pages"": true}'``."
+ "OCR_POLL_NEW_FILE_SECONDS", "Polling interval"
+ "OCR_LOGLEVEL", "Level of log messages to report"
+
+One could configure a networked scanner or scanning computer to drop files in the
+watched folder.
+
+Watched folders with Docker
+---------------------------
+
+The watcher service is included in the OCRmyPDF Docker image. To run it:
+
+.. code-block:: bash
+
+ docker run \
+ -v :/input \
+ -v :/output \
+ -e OCR_OUTPUT_DIRECTORY_YEAR_MONTH=1 \
+ -e OCR_ON_SUCCESS_DELETE=1 \
+ -e OCR_DESKEW=1 \
+ -e PYTHONUNBUFFERED=1 \
+ -it --entrypoint python3 \
+ jbarlow83/ocrmypdf \
+ watcher.py
+
+This service will watch for a file that matches ``/input/\*.pdf`` and will
+convert it to a OCRed PDF in ``/output/``. The parameters to this image are:
+
+.. csv-table:: watcher.py parameters for Docker
+ :header: "Parameter", "Description"
+ :widths: 50, 50
+
+ "``-v :/input``", "Files placed in this location will be OCRed"
+ "``-v :/output``", "This is where OCRed files will be stored"
+ "``-e OCR_OUTPUT_DIRECTORY_YEAR_MONTH=1``", "Define environment variable OCR_OUTPUT_DIRECTORY_YEAR_MONTH=1"
+ "``-e OCR_ON_SUCCESS_DELETE=1``", "Define environment variable"
+ "``-e OCR_DESKEW=1``", "Define environment variable"
+ "``-e PYTHONBUFFERED=1``", "This will force STDOUT to be unbuffered and allow you to see messages in docker logs"
+
+This service relies on polling to check for changes to the filesystem. It
+may not be suitable for some environments, such as filesystems shared on a
+slow network.
+
+A configuration manager such as Docker Compose could be used to ensure that the
+service is always available.
+
+.. literalinclude:: ../misc/docker-compose.example.yml
+ :language: yaml
+ :caption: misc/docker-compose.example.yml
+
+Caveats
+-------
+
+- ``watchmedo`` may not work properly on a networked file system,
+ depending on the capabilities of the file system client and server.
+- This simple recipe does not filter for the type of file system event,
+ so file copies, deletes and moves, and directory operations, will all
+ be sent to ocrmypdf, producing errors in several cases. Disable your
+ watched folder if you are doing anything other than copying files to
+ it.
+- If the source and destination directory are the same, watchmedo may
+ create an infinite loop.
+- On BSD, FreeBSD and older versions of macOS, you may need to increase
+ the number of file descriptors to monitor more files, using
+ ``ulimit -n 1024`` to watch a folder of up to 1024 files.
+
+Alternatives
+------------
+
+- On Linux, `systemd user services `__
+ can be configured to automatically perform OCR on a collection of files.
+
+- `Watchman `__ is a more
+ powerful alternative to ``watchmedo``.
+
+macOS Automator
+===============
+
+You can use the Automator app with macOS, to create a Workflow or Quick
+Action. Use a *Run Shell Script* action in your workflow. In the context
+of Automator, the ``PATH`` may be set differently your Terminal's
+``PATH``; you may need to explicitly set the PATH to include
+``ocrmypdf``. The following example may serve as a starting point:
+
+.. figure:: images/macos-workflow.png
+ :alt: Example macOS Automator workflow
You may customize the command sent to ocrmypdf.
diff --git a/docs/conf.py b/docs/conf.py
index f1f32a01..4a6dc0ac 100755
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
#
# ocrmypdf documentation build configuration file, created by
# sphinx-quickstart on Sun Sep 4 14:29:43 2016.
@@ -21,6 +20,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))
+"""isort:skip_file"""
+
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@@ -30,9 +31,9 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
-extensions = [
- # 'sphinx.ext.mathjax',
-]
+extensions = ['sphinx.ext.napoleon']
+
+napoleon_use_rtype = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -53,7 +54,7 @@ master_doc = 'index'
# General information about the project.
project = 'ocrmypdf'
copyright = (
- '2019, James R. Barlow. Licensed under Creative Commons Attribution-ShareAlike 4.0.'
+ '2020, James R. Barlow. Licensed under Creative Commons Attribution-ShareAlike 4.0.'
)
author = 'James R. Barlow'
@@ -92,6 +93,7 @@ from pkg_resources import get_distribution, DistributionNotFound
release = get_distribution('ocrmypdf').version
version = '.'.join(release.split('.')[:2])
+
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
@@ -176,7 +178,7 @@ html_theme_options = {'display_version': False}
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#
-# html_logo = None
+# html_logo = "images/logo.svg" # looks bad
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
diff --git a/docs/contributing.rst b/docs/contributing.rst
new file mode 100644
index 00000000..6c928933
--- /dev/null
+++ b/docs/contributing.rst
@@ -0,0 +1,67 @@
+=======================
+Contributing guidelines
+=======================
+
+Contributions are welcome!
+
+Big changes
+===========
+
+Please open a new issue to discuss or propose a major change. Not only is it fun
+to discuss big ideas, but we might save each other's time too. Perhaps some of the
+work you're contemplating is already half-done in a development branch.
+
+Code style
+==========
+
+We use PEP8, ``black`` for code formatting and ``isort`` for import sorting. The
+settings for these programs are in ``pyproject.toml`` and ``setup.cfg``. Pull
+requests should follow the style guide. One difference we use from "black" style
+is that strings shown to the user are always in double quotes (``"``) and strings
+for internal uses are in single quotes (``'``).
+
+Tests
+=====
+
+New features should come with tests that confirm their correctness.
+
+New Python dependencies
+=======================
+
+If you are proposing a change that will require a new Python dependency, we
+prefer dependencies that are already packaged by Debian or Red Hat. This makes
+life much easier for our downstream package maintainers.
+
+Python dependencies must also be license-compatible. GPLv3 or AGPLv3 are likely
+incompatible with the project's license, but LGPLv3 is compatible.
+
+New non-Python dependencies
+===========================
+
+OCRmyPDF uses several external programs (Tesseract, Ghostscript and others) for
+its functionality. In general we prefer to avoid adding new external programs.
+
+Style guide: Is it OCRmyPDF or ocrmypdf?
+========================================
+
+The program/project is OCRmyPDF and the name of the executable or library is ocrmypdf.
+
+Known ports/packagers
+=====================
+
+OCRmyPDF has been ported to many platforms already. If you are interesting in
+porting to a new platform, check with
+`Repology `__ to see the status
+of that platform.
+
+Packager maintainers, please ensure that the command line completion scripts in
+``misc/`` are installed.
+
+Copyright and license
+=====================
+
+For contributions over 10 lines of code, please include your name to list of
+copyright holders for that file. The core program is licensed under MPL-2.0,
+test files and documentation under CC-BY-SA 4.0, and miscellaneous files under
+MIT. Please contribute code only that you wrote and you have the permission to
+contribute or license to us.
diff --git a/docs/cookbook.rst b/docs/cookbook.rst
index 3ea153aa..8ee4d8fd 100644
--- a/docs/cookbook.rst
+++ b/docs/cookbook.rst
@@ -1,11 +1,12 @@
+========
Cookbook
========
Basic examples
---------------
+==============
Help!
-^^^^^
+-----
ocrmypdf has built-in help.
@@ -13,30 +14,29 @@ ocrmypdf has built-in help.
ocrmypdf --help
-
Add an OCR layer and convert to PDF/A
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-------------------------------------
.. code-block:: bash
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
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
Modify a file in place
-^^^^^^^^^^^^^^^^^^^^^^
+----------------------
The file will only be overwritten if OCRmyPDF is successful.
@@ -45,48 +45,76 @@ The file will only be overwritten if OCRmyPDF is successful.
ocrmypdf myfile.pdf myfile.pdf
Correct page rotation
-^^^^^^^^^^^^^^^^^^^^^
+---------------------
-OCR will attempt to automatic correct the rotation of each page. This can help fix a scanning job that contains a mix of landscape and portrait pages.
+OCR will attempt to automatic correct the rotation of each page. This
+can help fix a scanning job that contains a mix of landscape and
+portrait pages.
.. code-block:: bash
ocrmypdf --rotate-pages myfile.pdf myfile.pdf
-You can increase (decrease) the parameter ``--rotate-pages-threshold`` to make page rotation more (less) aggressive.
+You can increase (decrease) the parameter ``--rotate-pages-threshold``
+to make page rotation more (less) aggressive. The threshold number is the ratio
+of how confidence the OCR engine is that the document image should be changed,
+compared to kept the same. The default value is quite conservative; on some files
+it may not attempt rotations at all unless it is very confident that the current
+rotation is wrong. A lower value of ``2.0`` will produce more rotations, and
+more false positives. Run with ``-v1`` to see the confidence level for each
+page to see if there may be a better value for your files.
-If the page is "just a little off horizontal", like a crooked picture, then you want ``--deskew``. ``--rotate-pages`` is for when the cardinal angle is wrong.
+If the page is "just a little off horizontal", like a crooked picture,
+then you want ``--deskew``. ``--rotate-pages`` is for when the cardinal
+angle is wrong.
OCR languages other than English
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+--------------------------------
-OCRmyPDF assumes the document is in English unless told otherwise. OCR quality may be poor if the wrong language is used.
+OCRmyPDF assumes the document is in English unless told otherwise. OCR
+quality may be poor if the wrong language is used.
.. code-block:: bash
ocrmypdf -l fra LeParisien.pdf LeParisien.pdf
ocrmypdf -l eng+fra Bilingual-English-French.pdf Bilingual-English-French.pdf
-Language packs must be installed for all languages specified. See :ref:`Installing additional language packs `.
+Language packs must be installed for all languages specified. See
+:ref:`Installing additional language packs `.
-Unfortunately, the Tesseract OCR engine has no ability to detect the language when it is unknown.
+Unfortunately, the Tesseract OCR engine has no ability to detect the
+language when it is unknown.
Produce PDF and text file containing OCR text
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+---------------------------------------------
-This produces a file named "output.pdf" and a companion text file named "output.txt".
+This produces a file named "output.pdf" and a companion text file named
+"output.txt".
.. code-block:: bash
ocrmypdf --sidecar output.txt input.pdf output.pdf
+.. note::
+
+ The sidecar file contains the **OCR text** found by OCRmyPDF. If the document
+ contains pages that already have text, that text will not appear in the
+ sidecar. If the option ``--pages`` is used, only those pages on which OCR
+ was performed will be included in the sidecar. If certain pages were skipped
+ because of options like ``--skip-big`` or ``--tesseract-timeout``, those pages
+ will not be in the sidecar.
+
+ To extract all text from a PDF, whether generated from OCR or otherwise,
+ use a program like Poppler's ``pdftotext`` or ``pdfgrep``.
+
OCR images, not PDFs
-^^^^^^^^^^^^^^^^^^^^
+--------------------
Option: use Tesseract
-"""""""""""""""""""""
+~~~~~~~~~~~~~~~~~~~~~
-If you are starting with images, you can just use Tesseract directly to convert images to PDFs:
+If you are starting with images, you can just use Tesseract directly to
+convert images to PDFs:
.. code-block:: bash
@@ -97,62 +125,88 @@ If you are starting with images, you can just use Tesseract directly to convert
# When there are multiple images
tesseract text-file-containing-list-of-image-filenames.txt output-prefix pdf
-Tesseract's PDF output is quite good – OCRmyPDF uses it internally, in some cases. However, OCRmyPDF has many features not available in Tesseract like image processing, metadata control, and PDF/A generation.
+Tesseract's PDF output is quite good – OCRmyPDF uses it internally, in
+some cases. However, OCRmyPDF has many features not available in
+Tesseract like image processing, metadata control, and PDF/A generation.
Option: use img2pdf
-"""""""""""""""""""
+~~~~~~~~~~~~~~~~~~~
-You can also use a program like `img2pdf `_ to convert your images to PDFs, and then pipe the results to run ocrmypdf. The ``-`` tells ocrmypdf to read standard input.
+You can also use a program like
+`img2pdf `__ to convert
+your images to PDFs, and then pipe the results to run ocrmypdf. The
+``-`` tells ocrmypdf to read standard input.
.. code-block:: bash
img2pdf my-images*.jpg | ocrmypdf - myfile.pdf
-``img2pdf`` is recommended because it does an excellent job at generating PDFs without transcoding images.
+``img2pdf`` is recommended because it does an excellent job at
+generating PDFs without transcoding images.
Option: use OCRmyPDF (single images only)
-"""""""""""""""""""""""""""""""""""""""""
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-For convenience, OCRmyPDF can also convert single images to PDFs on its own. If the resolution (dots per inch, DPI) of an image is not set or is incorrect, it can be overridden with ``--image-dpi``. (As 1 inch is 2.54 cm, 1 dpi = 0.39 dpcm).
+For convenience, OCRmyPDF can also convert single images to PDFs on its
+own. If the resolution (dots per inch, DPI) of an image is not set or is
+incorrect, it can be overridden with ``--image-dpi``. (As 1 inch is 2.54
+cm, 1 dpi = 0.39 dpcm).
.. code-block:: bash
ocrmypdf --image-dpi 300 image.png myfile.pdf
-If you have multiple images, you must use ``img2pdf`` to convert the images to PDF.
+If you have multiple images, you must use ``img2pdf`` to convert the
+images to PDF.
Not recommended
-"""""""""""""""
+~~~~~~~~~~~~~~~
-We caution against using ImageMagick or Ghostscript to convert images to PDF, since they may transcode images or produce downsampled images, sometimes without warning.
+We caution against using ImageMagick or Ghostscript to convert images to
+PDF, since they may transcode images or produce downsampled images,
+sometimes without warning.
Image processing
-----------------
+================
-OCRmyPDF perform some image processing on each page of a PDF, if desired. The same processing is applied to each page. It is suggested that the user review files after image processing as these commands might remove desirable content, especially from poor quality scans.
+OCRmyPDF perform some image processing on each page of a PDF, if
+desired. The same processing is applied to each page. It is suggested
+that the user review files after image processing as these commands
+might remove desirable content, especially from poor quality scans.
-* ``--rotate-pages`` attempts to determine the correct orientation for each page and rotates the page if necessary.
-
-* ``--remove-background`` attempts to detect and remove a noisy background from grayscale or color images. Monochrome images are ignored. This should not be used on documents that contain color photos as it may remove them.
-
-* ``--deskew`` will correct pages were scanned at a skewed angle by rotating them back into place. Skew determination and correction is performed using `Postl's variance of line sums `_ algorithm as implemented in `Leptonica `_.
-
-* ``--clean`` uses `unpaper `_ to clean up pages before OCR, but does not alter the final output. This makes it less likely that OCR will try to find text in background noise.
-
-* ``--clean-final`` uses unpaper to clean up pages before OCR and inserts the page into the final output. You will want to review each page to ensure that unpaper did not remove something important.
-
-* ``--mask-barcodes`` will suppress any barcodes detected in a page image. Barcodes are known to confuse Tesseract OCR and interfere with the recognition of text on the same baseline as a barcode. The output file will contain the unaltered image of the barcode.
+- ``--rotate-pages`` attempts to determine the correct orientation for
+ each page and rotates the page if necessary.
+- ``--remove-background`` attempts to detect and remove a noisy
+ background from grayscale or color images. Monochrome images are
+ ignored. This should not be used on documents that contain color
+ photos as it may remove them.
+- ``--deskew`` will correct pages were scanned at a skewed angle by
+ rotating them back into place. Skew determination and correction is
+ performed using `Postl's variance of line
+ sums `__ algorithm as
+ implemented in `Leptonica `__.
+- ``--clean`` uses
+ `unpaper `__ to clean up
+ pages before OCR, but does not alter the final output. This makes it
+ less likely that OCR will try to find text in background noise.
+- ``--clean-final`` uses unpaper to clean up pages before OCR and
+ inserts the page into the final output. You will want to review each
+ page to ensure that unpaper did not remove something important.
.. 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.
Example: OCR and correct document skew (crooked scan)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-----------------------------------------------------
Deskew:
@@ -160,55 +214,118 @@ Deskew:
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).
+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
-
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.
+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
+Optimize images without performing OCR
+--------------------------------------
+
+You can also optimize all images without performing any OCR:
+
+.. code-block:: bash
+
+ ocrmypdf --tesseract-timeout=0 --optimize 3 --skip-text input.pdf output.pdf
+
+Perform OCR only certain pages
+------------------------------
+
+You can ask OCRmyPDF to only apply OCR to certain pages.
+
+.. code-block:: bash
+
+ ocrmypdf --pages 2,3,13-17 input.pdf output.pdf
+
+Hyphens denote a range of pages and commas separate page numbers. If you prefer
+to use spaces, quote all of the page numbers: ``--pages '2, 3, 5, 7'``.
+
+OCRmyPDF will warn if your list of page numbers contains duplicates or
+overlap pages. OCRmyPDF does not currently account for document page numbers,
+such as an introduction section of a book that uses Roman numerals. It simply
+counts the number of virtual pieces of paper since the start.
+
+Regardless of the argument to ``--pages``, OCRmyPDF will optimize all pages in
+the file and convert it to PDF/A, unless you disable those options. In this
+example, we want to OCR only the title and otherwise change the PDF as little
+as possible:
+
+.. code-block:: bash
+
+ ocrmypdf --pages 1 --output-type pdf --optimize 0 input.pdf output.pdf
Redo existing OCR
------------------
+=================
-To redo OCR on a file OCRed with other OCR software or a previous version of OCRmyPDF and/or Tesseract, you may use the ``--redo-ocr`` argument. (Normally, OCRmyPDF will exit with an error if asked to modify a file with OCR.)
+To redo OCR on a file OCRed with other OCR software or a previous
+version of OCRmyPDF and/or Tesseract, you may use the ``--redo-ocr``
+argument. (Normally, OCRmyPDF will exit with an error if asked to modify
+a file with OCR.)
-This may be helpful for users who want to take advantage of accuracy improvements in Tesseract 4.0 for files they previously OCRed with an earlier version of Tesseract and OCRmyPDF.
+This may be helpful for users who want to take advantage of accuracy
+improvements in Tesseract 4.0 for files they previously OCRed with an
+earlier version of Tesseract and OCRmyPDF.
.. code-block:: bash
ocrmypdf --redo-ocr input.pdf output.pdf
-This method will replace OCR without rasterizing, reducing quality or removing vector content. If a file contains a mix of pure digital text and OCR, digital text will be ignored and OCR will be replaced. As such this mode is incompatible with image processing options, since they alter the appearance of the file.
+This method will replace OCR without rasterizing, reducing quality or
+removing vector content. If a file contains a mix of pure digital text
+and OCR, digital text will be ignored and OCR will be replaced. As such
+this mode is incompatible with image processing options, since they
+alter the appearance of the file.
-In some cases, existing OCR cannot be detected or replaced. Files produced by OCRmyPDF v2.2 or earlier, for example, are internally represented as having visible text with an opaque image drawn on top. This situation cannot be detected.
+In some cases, existing OCR cannot be detected or replaced. Files
+produced by OCRmyPDF v2.2 or earlier, for example, are internally
+represented as having visible text with an opaque image drawn on top.
+This situation cannot be detected.
-If ``--redo-ocr`` does not work, you can use ``--force-ocr``, which will force rasterization of all pages, potentially reducing quality or losing vector content.
+If ``--redo-ocr`` does not work, you can use ``--force-ocr``, which will
+force rasterization of all pages, potentially reducing quality or losing
+vector content.
Improving OCR quality
----------------------
+=====================
-The `Image processing`_ features can improve OCR quality.
+The `Image processing <#image-processing>`__ features can improve OCR
+quality.
-Rotating pages and deskewing helps to ensure that the page orientation is correct before OCR begins. Removing the background and/or cleaning the page can also improve results. The ``--oversample DPI`` argument can be specified to resample images to higher resolution before attempting OCR; this can improve results as well.
+Rotating pages and deskewing helps to ensure that the page orientation
+is correct before OCR begins. Removing the background and/or cleaning
+the page can also improve results. The ``--oversample DPI`` argument can
+be specified to resample images to higher resolution before attempting
+OCR; this can improve results as well.
-OCR quality will suffer if the resolution of input images is not correct (since the range of pixel sizes that will be checked for possible fonts will also be incorrect).
+OCR quality will suffer if the resolution of input images is not correct
+(since the range of pixel sizes that will be checked for possible fonts
+will also be incorrect).
PDF optimization
-----------------
+================
-By default OCRmyPDF will attempt to perform lossless optimizations on the images inside PDFs after OCR is complete. Optimization is performed even if no OCR text is found.
+By default OCRmyPDF will attempt to perform lossless optimizations on
+the images inside PDFs after OCR is complete. Optimization is performed
+even if no OCR text is found.
-The ``--optimize N`` (short form ``-O``) argument controls optimization, where ``N`` ranges from 0 to 3 inclusive, analogous to the optimization levels in the GCC compiler.
+The ``--optimize N`` (short form ``-O``) argument controls optimization,
+where ``N`` ranges from 0 to 3 inclusive, analogous to the optimization
+levels in the GCC compiler.
.. list-table::
:widths: auto
@@ -227,9 +344,15 @@ The ``--optimize N`` (short form ``-O``) argument controls optimization, where `
* - ``--optimize 3``
- All of the above, and enables more aggressive optimizations and targets lower image quality.
-Optimization is improved when a JBIG2 encoder is available and when ``pngquant`` is installed. If either of these components are missing, then some types of images cannot be optimized.
+Optimization is improved when a JBIG2 encoder is available and when
+``pngquant`` is installed. If either of these components are missing,
+then some types of images cannot be optimized.
-The types of optimization available may expand over time. By default, OCRmyPDF compresses data streams inside PDFs, and will change inefficient compression modes to more modern versions. A program like ``qpdf`` can be used to change encodings, e.g. to inspect the internals fo a PDF.
+The types of optimization available may expand over time. By default,
+OCRmyPDF compresses data streams inside PDFs, and will change
+inefficient compression modes to more modern versions. A program like
+``qpdf`` can be used to change encodings, e.g. to inspect the internals
+fo a PDF.
.. code-block:: bash
diff --git a/docs/docker.rst b/docs/docker.rst
index 73f0a3e8..16eccb7c 100644
--- a/docs/docker.rst
+++ b/docs/docker.rst
@@ -1,155 +1,196 @@
+.. _docker:
+
+=====================
OCRmyPDF Docker image
=====================
-OCRmyPDF is also available in a Docker image that packages recent versions of all dependencies.
+OCRmyPDF is also available in a Docker image that packages recent
+versions of all dependencies.
-For users who already have Docker installed this may be an easy and convenient option. However, it is less performant than a system installation and may require Docker engine configuration.
+For users who already have Docker installed this may be an easy and
+convenient option. However, it is less performant than a system
+installation and may require Docker engine configuration.
-OCRmyPDF needs a generous amount of RAM, CPU cores, and temporary storage space.
+OCRmyPDF needs a generous amount of RAM, CPU cores, temporary storage
+space, whether running in a Docker container or on its own. It may be
+necessary to ensure the container is provisioned with additional
+resources.
.. _docker-install:
Installing the Docker image
----------------------------
+===========================
-If you have `Docker `_ installed on your system, you can install a Docker image of the latest release.
+If you have `Docker `__ installed on your
+system, you can install a Docker image of the latest release.
-The recommended OCRmyPDF Docker image is currently named ``ocrmypdf-alpine``:
+If you can run this command successfully, your system is ready to download and
+execute the image:
.. code-block:: bash
- docker pull jbarlow83/ocrmypdf-alpine
+ docker run hello-world
-Follow the Docker installation instructions for your platform. If you can run this command successfully, your system is ready to download and execute the image:
+The recommended OCRmyPDF Docker image is currently named ``ocrmypdf``:
.. code-block:: bash
- docker run hello-world
+ docker pull jbarlow83/ocrmypdf
-OCRmyPDF will use all available CPU cores. By default, the VirtualBox machine instance on Windows and macOS has only a single CPU core enabled. Use the VirtualBox Manager to determine the name of your Docker engine host, and then follow these optional steps to enable multiple CPUs:
+
+OCRmyPDF will use all available CPU cores. By default, the VirtualBox
+machine instance on Windows and macOS has only a single CPU core
+enabled. Use the VirtualBox Manager to determine the name of your Docker
+engine host, and then follow these optional steps to enable multiple
+CPUs:
.. code-block:: bash
- # Optional step for Mac OS X users
- docker-machine stop "yourVM"
- VBoxManage modifyvm "yourVM" --cpus 2 # or whatever number of core is desired
- docker-machine start "yourVM"
- eval $(docker-machine env "yourVM")
+ # Optional step for Mac OS X users
+ docker-machine stop "yourVM"
+ VBoxManage modifyvm "yourVM" --cpus 2 # or whatever number of core is desired
+ docker-machine start "yourVM"
+ eval $(docker-machine env "yourVM")
+
+See the Docker documentation for
+`adjusting memory and CPU on other platforms `__.
Using the Docker image on the command line
-------------------------------------------
+==========================================
-**Unlike typical Docker containers**, in this mode we are using the OCRmyPDF Docker container is intended to be emphemeral – it runs for one OCR job and then terminates, just like a command line program. We are using Docker as a way of delivering an application, not a server.
+**Unlike typical Docker containers**, in this section the OCRmyPDF Docker
+container is emphemeral – it runs for one OCR job and terminates, just like a
+command line program. We are using Docker to deliver an application (as opposed
+to the more conventional case, where a Docker container runs as a server).
To start a Docker container (instance of the image):
.. code-block:: bash
- docker tag jbarlow83/ocrmypdf-alpine ocrmypdf
- docker run --rm ocrmypdf (... all other arguments here...)
+ docker tag jbarlow83/ocrmypdf ocrmypdf
+ docker run --rm -i ocrmypdf (... all other arguments here...) - -
-For convenience, create a shell alias to hide the Docker command:
+For convenience, create a shell alias to hide the Docker command. It is
+easier to send the input file as stdin and read the output from
+stdout – **this avoids the messy permission issues with Docker entirely**.
.. code-block:: bash
- alias ocrmypdf='docker run --rm -v "$(pwd):/home/docker" ocrmypdf'
- ocrmypdf --version # runs docker version
+ alias docker_ocrmypdf='docker run --rm -i ocrmypdf'
+ docker_ocrmypdf --version # runs docker version
+ docker_ocrmypdf - - output.pdf
-Or in the wonderful `fish shell `_:
+Or in the wonderful `fish shell `__:
.. code-block:: fish
- alias ocrmypdf 'docker run --rm ocrmypdf'
- funcsave ocrmypdf
+ alias docker_ocrmypdf 'docker run --rm ocrmypdf'
+ funcsave docker_ocrmypdf
+
+Alternately, you could mount the local current working directory as a
+Docker volume:
+
+.. code-block:: bash
+
+ alias docker_ocrmypdf='docker run --rm -i --user "$(id -u):$(id -g)" --workdir /data -v "$PWD:/data" ocrmypdf'
+ docker_ocrmypdf /data/input.pdf /data/output.pdf
.. _docker-lang-packs:
Adding languages to the Docker image
-------------------------------------
+====================================
-By default the Docker image includes English, German and Simplified Chinese, the most popular languages for OCRmyPDF users based on feedback. You may add other languages by creating a new Dockerfile based on the public one:
+By default the Docker image includes English, German, Simplified Chinese,
+French, Portuguese and Spanish, the most popular languages for OCRmyPDF
+users based on feedback. You may add other languages by creating a new
+Dockerfile based on the public one.
.. code-block:: dockerfile
- FROM jbarlow83/ocrmypdf-alpine
+ FROM jbarlow83/ocrmypdf
- # Add French
- RUN apk add tesseract-ocr-data-fra
+ # Example: add Italian
+ RUN apt install tesseract-ocr-ita
+
+To install language packs (training data) such as the
+`tessdata_best `_ suite or
+custom data, you first need to determine the version of Tesseract data files, which
+may differ from the Tesseract program version. Use this command to determine the data
+file version:
+
+.. code-block:: bash
+
+ docker run -i --rm --entrypoint /bin/ls jbarlow83/ocrmypdf /usr/share/tesseract-ocr
+
+As of 2021, the data file version is probably ``4.00``.
+
+You can then add new data with either a Dockerfile:
+
+.. code-block:: dockerfile
+
+ FROM jbarlow83/ocrmypdf
+
+ # Example: add a tessdata_best file
+ COPY chi_tra_vert.traineddata /usr/share/tesseract-ocr//tessdata/
+
+Alternately, you can copy training data into a Docker container as follows:
+
+.. code-block:: bash
+
+ docker cp mycustomtraining.traineddata name_of_container:/usr/share/tesseract-ocr//tessdata/
Executing the test suite
-------------------------
+========================
-The OCRmyPDF test suite is installed with image. To run it:
+The OCRmyPDF test suite is installed with image. To run it:
.. code-block:: bash
- docker run --entrypoint python3 jbarlow83/ocrmypdf-alpine setup.py test
+ docker run --entrypoint python3 jbarlow83/ocrmypdf -m pytest
+
+Accessing the shell
+===================
+
+To use the bash shell in the Docker image:
+
+.. code-block:: bash
+
+ docker run -it --entrypoint bash jbarlow83/ocrmypdf
Using the OCRmyPDF web service wrapper
---------------------------------------
+======================================
-The OCRmyPDF Docker image includes an example, barebones HTTP web service. The webservice may be launched as follows:
+The OCRmyPDF Docker image includes an example, barebones HTTP web
+service. The webservice may be launched as follows:
.. code-block:: bash
- docker run --entrypoint python3 -p 5000:5000 jbarlow83/ocrmypdf-alpine webservice.py
+ docker run --entrypoint python3 -p 5000:5000 jbarlow83/ocrmypdf webservice.py
-Unlike command line usage this program will open a socket and wait for connections.
+This will configure the machine to listen on port 5000. On Linux machines
+this is port 5000 of localhost. On macOS or Windows machines running
+Docker, this is port 5000 of the virtual machine that runs your Docker
+images. You can find its IP address using the command ``docker-machine ip``.
+
+Unlike command line usage this program will open a socket and wait for
+connections.
.. warning::
- The OCRmyPDF web service wrapper is intended for demonstration or development. It provides no security, no authentication, no protection against denial of service attacks, and no load balancing. The default Flask WSGI server is used, which is intended for development only. The server is single-threaded and so can respond to only one client at a time. It cannot respond to clients while busy with OCR.
+ The OCRmyPDF web service wrapper is intended for demonstration or
+ development. It provides no security, no authentication, no
+ protection against denial of service attacks, and no load balancing.
+ The default Flask WSGI server is used, which is intended for
+ development only. The server is single-threaded and so can respond to
+ only one client at a time. While running OCR, it cannot respond to
+ any other clients.
-Clients must keep their open connection while waiting for OCR to complete. This may entail setting a long timeout; this interface is more useful for internal HTTP API calls.
+Clients must keep their open connection while waiting for OCR to
+complete. This may entail setting a long timeout; this interface is more
+useful for internal HTTP API calls.
-Unlike the rest of OCRmyPDF, this web service is licensed under the Affero GPLv3 (AGPLv3) since Ghostscript, a dependency of OCRmyPDF, is also licensed in this way.
+Unlike the rest of OCRmyPDF, this web service is licensed under the
+Affero GPLv3 (AGPLv3) since Ghostscript is also licensed in this way.
-In addition to the above, please read our :ref:`general remarks on using OCRmyPDF as a service `.
-
-Legacy Ubuntu Docker images
----------------------------
-
-Previously OCRmyPDF was delivered in several Docker images for different purposes, based on Ubuntu.
-
-The Ubuntu-based images will be maintained for some time but should not be used for new deployments. They are as follows:
-
-.. list-table::
- :widths: auto
- :header-rows: 1
-
- * - Image name
- - Download command
- - Notes
- * - ocrmypdf
- - ``docker pull jbarlow83/ocrmypdf``
- - Latest ocrmypdf with Tesseract 4.0.0-beta1 on Ubuntu 18.04. Includes English, French, German, Spanish, Portugeuse and Simplified Chinese.
- * - ocrmypdf-polyglot
- - ``docker pull jbarlow83/ocrmypdf-polyglot``
- - As above, with all available language packs.
- * - ocrmypdf-webservice
- - ``docker pull jbarlow83/ocrmypdf-webservice``
- - All language packs, and a simple HTTP wrapper allowing OCRmyPDF to be used as a web service. Note that this component is licensed under AGPLv3.
-
-To execute the Ubuntu-based OCRmyPDF on a local file, you must `provide a writable volume to the Docker image `_, and both the input and output file must be inside the writable volume. This limitation applies only to the legacy images.
-
-This example command uses the current working directory as the writable volume:
-
-.. code-block:: bash
-
- docker run --rm -v "$(pwd):/home/docker" ocrmypdf
-
-In this worked example, the current working directory contains an input file called ``test.pdf`` and the output will go to ``output.pdf``:
-
-.. code-block:: bash
-
- docker run --rm -v "$(pwd):/home/docker" ocrmypdf --skip-text test.pdf output.pdf
-
-.. note:: The working directory should be a writable local volume or Docker may not have permission to access it.
-
-Note that ``ocrmypdf`` has its own separate ``-v VERBOSITYLEVEL`` argument to control debug verbosity. All Docker arguments should before the ``ocrmypdf`` image name and all arguments to ``ocrmypdf`` should be listed after.
-
-In some environments the permissions associated with Docker can be complex to configure. The process that executes Docker may end up not having the permissions to write the specified file system. In that case one can stream the file into and out of the Docker process and avoid all permission hassles, using ``-`` as the input and output filename:
-
-.. code-block:: bash
-
- docker run --rm -i ocrmypdf - - output.pdf
+In addition to the above, please read our
+:ref:`general remarks on using OCRmyPDF as a service `.
diff --git a/docs/errors.rst b/docs/errors.rst
index 44bc5732..bf0b53d0 100644
--- a/docs/errors.rst
+++ b/docs/errors.rst
@@ -1,33 +1,53 @@
+=====================
Common error messages
=====================
Page already has text
----------------------
+=====================
-.. code::
+.. code-block::
- ERROR - 1: page already has text! – aborting (use --force-ocr to force OCR)
+ ERROR - 1: page already has text! – aborting (use --force-ocr to force OCR)
-You ran ocrmypdf on a file that already contains printable text or a hidden OCR text layer (it can't quite tell the difference). You probably don't want to do this, because the file is already searchable.
+You ran ocrmypdf on a file that already contains printable text or a
+hidden OCR text layer (it can't quite tell the difference). You probably
+don't want to do this, because the file is already searchable.
As the error message suggests, your options are:
-- ``ocrmypdf --force-ocr`` to :ref:`rasterize ` all vector content and run OCR on the images. This is useful if a previous OCR program failed, or if the document contains a text watermark.
-
-- ``ocrmypdf --skip-text`` to skip OCR and other processing on any pages that contain text. Text pages will be copied into the output PDF without modification.
+- ``ocrmypdf --force-ocr`` to :ref:`rasterize ` all
+ vector content and run OCR on the images. This is useful if a
+ previous OCR program failed, or if the document contains a text
+ watermark.
+- ``ocrmypdf --skip-text`` to skip OCR and other processing on any
+ pages that contain text. Text pages will be copied into the output
+ PDF without modification.
+- ``ocrmypdf --redo-ocr`` to scan the file for any existing OCR
+ (non-printing text), remove it, and do OCR again. This is one way
+ to take advantage of improvements in OCR accuracy. Printable vector
+ text is excluded from OCR, so this can be used on files that contain
+ a mix of digital and scanned files.
Input file 'filename' is not a valid PDF
-----------------------------------------
+========================================
-OCRmyPDF passes files through qpdf, a program that fixes errors in PDFs, before it tries to work on them. In most cases this happens because the PDF is corrupt and
-truncated (incomplete file copying) and not much can be done.
+OCRmyPDF checks files with pikepdf, a library that in turn uses libqpdf to fixes
+errors in PDFs, before it tries to work on them. In most cases this happens
+because the PDF is corrupt and truncated (incomplete file copying) and not much
+can be done.
-You can try rewriting the file with Ghostscript or pdftk:
+You can try rewriting the file with Ghostscript:
-- ``gs -o output.pdf -dSAFER -sDEVICE=pdfwrite input.pdf``
+.. code-block:: bash
-- ``pdftk input.pdf cat output output.pdf``
+ gs -o output.pdf -dSAFER -sDEVICE=pdfwrite input.pdf
-Sometimes Acrobat can repair PDFs with its `Preflight tool `_.
+``pdftk`` can also rewrite PDFs:
+.. code-block:: bash
+
+ pdftk input.pdf cat output output.pdf
+
+Sometimes Acrobat can repair PDFs with its `Preflight
+tool `__.
diff --git a/docs/images/logo-social.png b/docs/images/logo-social.png
new file mode 100644
index 00000000..21354b9d
Binary files /dev/null and b/docs/images/logo-social.png differ
diff --git a/docs/images/logo.svg b/docs/images/logo.svg
new file mode 100644
index 00000000..5d5c7a7f
--- /dev/null
+++ b/docs/images/logo.svg
@@ -0,0 +1,75 @@
+
+
+
diff --git a/docs/index.rst b/docs/index.rst
index 3329eea8..91eac433 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,15 +1,12 @@
-.. ocrmypdf documentation master file, created by
- sphinx-quickstart on Sun Sep 4 14:29:43 2016.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
-
OCRmyPDF documentation
======================
-OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to
-be searched.
+OCRmyPDF adds an optical character recognition (OCR) text layer to scanned PDF
+files, allowing them to be searched.
-PDF is the best format for storing and exchanging scanned documents. Unfortunately, PDFs can be difficult to modify. OCRmyPDF makes it easy to apply image processing and OCR to existing PDFs.
+PDF is the best format for storing and exchanging scanned documents.
+Unfortunately, PDFs can be difficult to modify. OCRmyPDF makes it easy to apply
+image processing and OCR to existing PDFs.
.. toctree::
:maxdepth: 1
@@ -17,6 +14,7 @@ PDF is the best format for storing and exchanging scanned documents. Unfortunat
introduction
release_notes
installation
+ optimizer
languages
jbig2
@@ -28,9 +26,18 @@ PDF is the best format for storing and exchanging scanned documents. Unfortunat
docker
advanced
batch
- security
+ performance
+ pdfsecurity
errors
+.. toctree::
+ :caption: Developers
+ :maxdepth: 2
+
+ api
+ plugins
+ apiref
+ contributing
Indices and tables
==================
diff --git a/docs/installation.rst b/docs/installation.rst
index 59f9d58e..6d096996 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -1,3 +1,4 @@
+===================
Installing OCRmyPDF
===================
@@ -7,21 +8,38 @@ Installing OCRmyPDF
|latest|
The easiest way to install OCRmyPDF is to follow the steps for your operating
-system/platform, although sometimes this version may be out of date.
+system/platform. This version may be out of date, however.
-If you want to use the latest version of OCRmyPDF, your best bet is to install
-the most recent version your platform provides, and then upgrade that version by
-installing the Python binary wheels.
+These platforms have one-liner installs:
+
++-------------------------------+-------------------------------+
+| Debian, Ubuntu | ``apt install ocrmypdf`` |
++-------------------------------+-------------------------------+
+| Windows Subsystem for Linux | ``apt install ocrmypdf`` |
++-------------------------------+-------------------------------+
+| Fedora | ``dnf install ocrmypdf`` |
++-------------------------------+-------------------------------+
+| macOS | ``brew install ocrmypdf`` |
++-------------------------------+-------------------------------+
+| LinuxBrew | ``brew install ocrmypdf`` |
++-------------------------------+-------------------------------+
+| FreeBSD | ``pkg install py37-ocrmypdf`` |
++-------------------------------+-------------------------------+
+| Conda (WSL, macOS, Linux) | ``conda install ocrmypdf`` |
++-------------------------------+-------------------------------+
+
+More detailed procedures are outlined below. If you want to do a manual
+install, or install a more recent version than your platform provides, read on.
.. contents:: Platform-specific steps
:depth: 2
:local:
Installing on Linux
--------------------
+===================
-Debian and Ubuntu 16.10 or newer
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Debian and Ubuntu 18.04 or newer
+--------------------------------
.. |deb-stable| image:: https://repology.org/badge/version-for-repo/debian_stable/ocrmypdf.svg
:alt: Debian 9 stable ("stretch")
@@ -32,118 +50,178 @@ Debian and Ubuntu 16.10 or newer
.. |deb-unstable| image:: https://repology.org/badge/version-for-repo/debian_unstable/ocrmypdf.svg
:alt: Debian unstable
-.. |ubu-1710| image:: https://repology.org/badge/version-for-repo/ubuntu_17_10/ocrmypdf.svg
- :alt: Ubuntu 17.10
-
.. |ubu-1804| image:: https://repology.org/badge/version-for-repo/ubuntu_18_04/ocrmypdf.svg
:alt: Ubuntu 18.04 LTS
-.. |ubu-1810| image:: https://repology.org/badge/version-for-repo/ubuntu_18_10/ocrmypdf.svg
- :alt: Ubuntu 18.10
+.. |ubu-2004| image:: https://repology.org/badge/version-for-repo/ubuntu_20_04/ocrmypdf.svg
+ :alt: Ubuntu 20.04 LTS
+.. |ubu-2010| image:: https://repology.org/badge/version-for-repo/ubuntu_20_10/ocrmypdf.svg
+ :alt: Ubuntu 20.10
-+-------------------------------------------+
-| **OCRmyPDF versions in Debian & Ubuntu** |
-+-------------------------------------------+
-| |latest| |
-+-------------------------------------------+
-| |deb-stable| |deb-testing| |deb-unstable| |
-+-------------------------------------------+
-| |ubu-1710| |ubu-1804| |ubu-1810| |
-+-------------------------------------------+
++-----------------------------------------------+
+| **OCRmyPDF versions in Debian & Ubuntu** |
++-----------------------------------------------+
+| |latest| |
++-----------------------------------------------+
+| |deb-stable| |deb-testing| |deb-unstable| |
++-----------------------------------------------+
+| |ubu-1804| |ubu-2004| |ubu-2010| |
++-----------------------------------------------+
-Users of Debian 9 ("stretch") or later or Ubuntu 16.10 or later may simply
+Users of Debian 9 ("stretch") or later, or Ubuntu 18.04 or later, including users
+of Windows Subsystem for Linux, may simply
.. code-block:: bash
apt-get install ocrmypdf
-As indicated in the table above, Debian and Ubuntu releases may lag behind the latest version. If the version available for your platform is out of date, you could opt to install the latest version from source. See `Installing HEAD revision from sources`_.
+As indicated in the table above, Debian and Ubuntu releases may lag
+behind the latest version. If the version available for your platform is
+out of date, you could opt to install the latest version from source.
+See `Installing HEAD revision from
+sources <#installing-head-revision-from-sources>`__. Ubuntu 16.10 to 17.10
+inclusive also had ocrmypdf, but these versions are end of life.
-For full details on version availability for your platform, check the `Debian Package Tracker `_ or `Ubuntu launchpad.net `_.
+For full details on version availability for your platform, check the
+`Debian Package Tracker `__ or
+`Ubuntu launchpad.net `__.
.. note::
- OCRmyPDF for Debian and Ubuntu currently omit the JBIG2 encoder. OCRmyPDF works fine without it but will produce larger output files. If you build jbig2enc from source, ocrmypdf 7.0.0 and later will automatically detect it (specifically the ``jbig2`` binary) on the ``PATH``. To add JBIG2 encoding, see :ref:`jbig2`.
+ OCRmyPDF for Debian and Ubuntu currently omit the JBIG2 encoder.
+ OCRmyPDF works fine without it but will produce larger output files.
+ If you build jbig2enc from source, ocrmypdf 7.0.0 and later will
+ automatically detect it (specifically the ``jbig2`` binary) on the
+ ``PATH``. To add JBIG2 encoding, see :ref:`jbig2`.
-Fedora 29 or newer
-^^^^^^^^^^^^^^^^^^
+Fedora
+------
-.. |fedora-29| image:: https://repology.org/badge/version-for-repo/fedora29/ocrmypdf.svg
- :alt: Fedora 29
+.. |fedora-32| image:: https://repology.org/badge/version-for-repo/fedora_32/ocrmypdf.svg
+ :alt: Fedora 32
+
+.. |fedora-33| image:: https://repology.org/badge/version-for-repo/fedora_33/ocrmypdf.svg
+ :alt: Fedora 33
.. |fedora-rawhide| image:: https://repology.org/badge/version-for-repo/fedora_rawhide/ocrmypdf.svg
:alt: Fedore Rawhide
++-----------------------------------------------+
+| **OCRmyPDF version** |
++-----------------------------------------------+
+| |latest| |
++-----------------------------------------------+
+| |fedora-32| |fedora-33| |fedora-rawhide| |
++-----------------------------------------------+
-+------------------------------+
-| **OCRmyPDF version** |
-+------------------------------+
-| |latest| |
-+------------------------------+
-| |fedora-29| |fedora-rawhide| |
-+------------------------------+
-
-Users of Fedora 29 later may simply
+Users of Fedora 29 or later may simply
.. code-block:: bash
dnf install ocrmypdf
-For full details on version availability, check the `Fedora Package Tracker
-`_.
+For full details on version availability, check the `Fedora Package
+Tracker `__.
-If the version available for your platform is out of date, you could opt to
-install the latest version from source. See `Installing HEAD revision from
-sources`_.
+If the version available for your platform is out of date, you could opt
+to install the latest version from source. See `Installing HEAD revision
+from sources <#installing-head-revision-from-sources>`__.
.. note::
- OCRmyPDF for Fedora currently omits the JBIG2 encoder due to patent issues.
- OCRmyPDF works fine without it but will produce larger output files. If you
- build jbig2enc from source, ocrmypdf 7.0.0 and later will automatically
- detect it on the ``PATH``. To add JBIG2 encoding, see `Installing the JBIG2
- encoder `_.
+ OCRmyPDF for Fedora currently omits the JBIG2 encoder due to patent
+ issues. OCRmyPDF works fine without it but will produce larger output
+ files. If you build jbig2enc from source, ocrmypdf 7.0.0 and later
+ will automatically detect it on the ``PATH``. To add JBIG2 encoding,
+ see `Installing the JBIG2 encoder `__.
-Installing the latest version on Ubuntu 18.04 LTS
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. _ubuntu-lts-latest:
-Ubuntu 18.04 includes ocrmypdf 6.1.2. To install a more recent version, first
-install the system version to get most of the dependencies:
+Installing the latest version on Ubuntu 20.04 LTS
+-------------------------------------------------
+
+Ubuntu 20.04 includes ocrmypdf 9.6.0 - you can install that with ``apt``. To
+install a more recent version, uninstall the system-provided version of
+ocrmypdf, and install the following dependencies:
.. code-block:: bash
- sudo apt-get update
- sudo apt-get install \
- ocrmypdf \
- python3-pip
+ sudo apt-get -y remove ocrmypdf # remove system ocrmypdf, if installed
+ sudo apt-get -y update
+ sudo apt-get -y install \
+ ghostscript \
+ icc-profiles-free \
+ liblept5 \
+ libxml2 \
+ pngquant \
+ python3-pip \
+ tesseract-ocr \
+ zlib1g
-There are a few dependency changes between ocrmypdf 6.1.2 and 7.x. Let's get
-these, too.
+To install ocrmypdf for the system:
.. code-block:: bash
- sudo apt-get install \
- libexempi3 \
- pngquant
+ pip3 install ocrmypdf
-Then install the most recent ocrmypdf for the local user and set the user's ``PATH`` to check for the user's Python packages.
+To install for the current user only:
.. code-block:: bash
export PATH=$HOME/.local/bin:$PATH
pip3 install --user ocrmypdf
+Ubuntu 18.04 LTS
+----------------
+
+Ubuntu 18.04 includes ocrmypdf 6.1.2 - you can install that with ``apt``, but
+it is quite old now. To install a more recent version, uninstall the old version
+of ocrmypdf, and install the following dependencies:
+
+.. code-block:: bash
+
+ sudo apt-get -y remove ocrmypdf
+ sudo apt-get -y update
+ sudo apt-get -y install \
+ ghostscript \
+ icc-profiles-free \
+ liblept5 \
+ libxml2 \
+ pngquant \
+ python3-cffi \
+ python3-distutils \
+ python3-pkg-resources \
+ python3-reportlab \
+ qpdf \
+ tesseract-ocr \
+ zlib1g \
+ unpaper
+
+We will need a newer version of ``pip`` then was available for Ubuntu 18.04:
+
+.. code-block:: bash
+
+ wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
+
+Then install the most recent ocrmypdf for the local user and set the
+user's ``PATH`` to check for the user's Python packages.
+
+.. code-block:: bash
+
+ export PATH=$HOME/.local/bin:$PATH
+ python3 -m pip install --user ocrmypdf
+
To add JBIG2 encoding, see :ref:`jbig2`.
Ubuntu 16.04 LTS
-^^^^^^^^^^^^^^^^
+----------------
-No package is available for Ubuntu 16.04. OCRmyPDF 8.0 and newer require Python
-3.6. Ubuntu 16.04 ships Python 3.5, but you can install Python 3.6 on it. Or,
-you can skip Python 3.6 and install OCRmyPDF 7.x or older - for that procedure,
-please see the installation documentation for the version of OCRmyPDF you plan
-to use.
+No package is available for Ubuntu 16.04. OCRmyPDF 8.0 and newer require
+Python 3.6. Ubuntu 16.04 ships Python 3.5, but you can install Python
+3.6 on it. Or, you can skip Python 3.6 and install OCRmyPDF 7.x or older
+- for that procedure, please see the installation documentation for the
+version of OCRmyPDF you plan to use.
**Install system packages for OCRmyPDF**
@@ -165,13 +243,13 @@ to use.
tesseract-ocr \
unpaper
-This will install a Python 3.6 binary at ``/usr/bin/python3.6`` alongside the
-system's Python 3.5. Do not remove the system Python. This will also install
-Tesseract 4.0 from a PPA, since the version available in Ubuntu 16.04 is too old
-for OCRmyPDF.
+This will install a Python 3.6 binary at ``/usr/bin/python3.6``
+alongside the system's Python 3.5. Do not remove the system Python. This
+will also install Tesseract 4.0 from a PPA, since the version available
+in Ubuntu 16.04 is too old for OCRmyPDF.
-Now install pip for Python 3.6. This will install the Python 3.6 version of
-``pip`` at ``/usr/local/bin/pip``.
+Now install pip for Python 3.6. This will install the Python 3.6 version
+of ``pip`` at ``/usr/local/bin/pip``.
.. code-block:: bash
@@ -179,8 +257,9 @@ Now install pip for Python 3.6. This will install the Python 3.6 version of
**Install OCRmyPDF**
-OCRmyPDF requires the locale to be set for UTF-8. **On some minimal Ubuntu
-installations systems**, it may be necessary to set the locale.
+OCRmyPDF requires the locale to be set for UTF-8. **On some minimal
+Ubuntu installations**, such as the Ubuntu 16.04 Docker images it may be
+necessary to set the locale.
.. code-block:: bash
@@ -194,111 +273,161 @@ environment variable contains ``$HOME/.local/bin``.
.. code-block:: bash
export PATH=$HOME/.local/bin:$PATH
- pip3 install --user ocrmypdf
+ pip3.6 install --user ocrmypdf
To add JBIG2 encoding, see :ref:`jbig2`.
-Ubuntu 14.04 LTS
-^^^^^^^^^^^^^^^^
-
-Installing on Ubuntu 14.04 LTS (trusty) is more difficult than some other
-options, because of its age. Several backports are required. For explanations of
-some steps of this procedure, see the similar steps for Ubuntu 16.04.
-
-Install system dependencies:
-
-.. code-block:: bash
-
- sudo apt-get update
- sudo apt-get install \
- software-properties-common python-software-properties \
- zlib1g-dev \
- libexempi3 \
- libjpeg-dev \
- libffi-dev \
- pngquant \
- 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.4.
-
-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-dev \
- ghostscript \
- tesseract-ocr \
- tesseract-ocr-eng \
- libavformat56 libavcodec56 libavutil54 \
- wget
-
-Now we need to install ``pip`` and let it install ocrmypdf:
-
-.. code-block:: bash
-
- curl https://bootstrap.pypa.io/ez_setup.py -o - | python3.6 && python3.6 -m easy_install pip
- 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):
-
-.. code-block:: bash
-
- wget -q 'https://www.dropbox.com/s/vaq0kbwi6e6au80/unpaper_6.1-1.deb?raw=1' -O unpaper_6.1-1.deb
- sudo dpkg -i unpaper_6.1-1.deb
-
-To add JBIG2 encoding, see :ref:`jbig2`.
-
-ArchLinux (AUR)
-^^^^^^^^^^^^^^^
+Arch Linux (AUR)
+----------------
.. image:: https://repology.org/badge/version-for-repo/aur/ocrmypdf.svg
:alt: ArchLinux
:target: https://repology.org/metapackage/ocrmypdf
-There is an `ArchLinux User Repository package for ocrmypdf `_. You can use the following command.
+There is an `Arch User Repository (AUR) package for OCRmyPDF
+`__.
+
+Installing AUR packages as root is not allowed, so you must first `setup a
+non-root user
+`__ and
+`configure sudo `__.
+The standard Docker image, ``archlinux/base:latest``, does **not** have a
+non-root user configured, so users of that image must follow these guides. If
+you are using a VM image, such as `the official Vagrant image
+`__, this work may already
+be completed for you.
+
+Next you should install the `base-devel package group
+`__. This includes the
+standard tooling needed to build packages, such as a compiler and binary tools.
.. code-block:: bash
- yaourt -S ocrmypdf
+ sudo pacman -S base-devel
-If you have any difficulties with installation, check the repository package page.
+Now you are ready to install the OCRmyPDF package.
+
+.. code-block:: bash
+
+ curl -O https://aur.archlinux.org/cgit/aur.git/snapshot/ocrmypdf.tar.gz
+ tar xvzf ocrmypdf.tar.gz
+ cd ocrmypdf
+ makepkg -sri
+
+At this point you will have a working install of OCRmyPDF, but the Tesseract
+install won’t include any OCR language data. You can install `the
+tesseract-data package group
+`__ to add all supported
+languages, or use that package listing to identify the appropriate package for
+your desired language.
+
+.. code-block:: bash
+
+ sudo pacman -S tesseract-data-eng
+
+As an alternative to this manual procedure, consider using an `AUR helper
+`__. Such a tool will
+automatically fetch, build and install the AUR package, resolve dependencies
+(including dependencies on AUR packages), and ease the upgrade procedure.
+
+If you have any difficulties with installation, check the repository package
+page.
+
+.. note::
+
+ The OCRmyPDF AUR package currently omits the JBIG2 encoder. OCRmyPDF works
+ fine without it but will produce larger output files. The encoder is
+ available from `the jbig2enc-git AUR package
+ `__ and may be installed
+ using the same series of steps as for the installation OCRmyPDF AUR
+ package. Alternatively, it may be built manually from source following the
+ instructions in `Installing the JBIG2 encoder `__. If JBIG2 is
+ installed, OCRmyPDF 7.0.0 and later will automatically detect it.
+
+Alpine Linux
+------------
+
+.. image:: https://repology.org/badge/version-for-repo/alpine_edge/ocrmypdf.svg
+ :alt: Alpine Linux
+ :target: https://repology.org/metapackage/ocrmypdf
+
+To install OCRmyPDF for Alpine Linux:
+
+.. code-block:: bash
+
+ apk add ocrmypdf
+
+Mageia 7
+--------
+
+There is no OS-level packaging available for Mageia, so you must install the
+dependencies:
+
+.. code-block:: bash
+
+ # As root user
+ urpmi.update -a
+ urpmi \
+ ghostscript \
+ icc-profiles-openicc \
+ jbig2dec \
+ lib64leptonica5 \
+ pngquant \
+ python3-pip \
+ python3-cffi \
+ python3-distutils-extra \
+ python3-pkg-resources \
+ python3-reportlab \
+ qpdf \
+ tesseract \
+ tesseract-osd \
+ tesseract-eng \
+ tesseract-fra
+
+To install ocrmypdf for the system:
+
+.. code-block:: bash
+
+ # As root user
+ pip3 install ocrmypdf
+ ldconfig
+
+Or, to install for the current user only:
+
+.. code-block:: bash
+
+ export PATH=$HOME/.local/bin:$PATH
+ pip3 install --user ocrmypdf
Other Linux packages
-^^^^^^^^^^^^^^^^^^^^
+--------------------
-See the `Repology `_ page.
+See the
+`Repology `__ page.
-In general, first install the OCRmyPDF package for your system, then optionally use the procedure `Installing with Python pip`_ to install a more recent version.
+In general, first install the OCRmyPDF package for your system, then
+optionally use the procedure `Installing with Python
+pip <#installing-with-python-pip>`__ to install a more recent version.
Installing on macOS
--------------------
+===================
Homebrew
-^^^^^^^^
+--------
.. image:: https://img.shields.io/homebrew/v/ocrmypdf.svg
:alt: homebrew
:target: http://brewformulas.org/Ocrmypdf
-OCRmyPDF is now a standard `Homebrew `_ formula. To install on macOS:
+OCRmyPDF is now a standard `Homebrew `__ formula. To
+install on macOS:
.. code-block:: bash
brew install ocrmypdf
-This will include only the English language pack. If you need other languages you can optionally install them all:
+This will include only the English language pack. If you need other
+languages you can optionally install them all:
.. code-block:: bash
@@ -306,18 +435,26 @@ This will include only the English language pack. If you need other languages yo
.. note::
- Users who previously installed OCRmyPDF on macOS using ``pip install ocrmypdf`` should remove the pip version (``pip3 uninstall ocrmypdf``) before switching to the Homebrew version.
+ Users who previously installed OCRmyPDF on macOS using
+ ``pip install ocrmypdf`` should remove the pip version
+ (``pip3 uninstall ocrmypdf``) before switching to the Homebrew
+ version.
.. note::
- Users who previously installed OCRmyPDF from the private tap should switch to the mainline version (``brew untap jbarlow83/ocrmypdf``) and install from there.
+ Users who previously installed OCRmyPDF from the private tap should
+ switch to the mainline version (``brew untap jbarlow83/ocrmypdf``)
+ and install from there.
Manual installation on macOS
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+----------------------------
-These instructions probably work on all macOS supported by Homebrew.
+These instructions probably work on all macOS supported by Homebrew, and are
+for installing a more current version of OCRmyPDF than is available from
+Homebrew. Note that the Homebrew versions usually track the release versions
+fairly closely.
-If it's not already present, `install Homebrew `_.
+If it's not already present, `install Homebrew `__.
Update Homebrew:
@@ -325,20 +462,18 @@ Update Homebrew:
brew update
-Install or upgrade the required Homebrew packages, if any are missing. To do this, download the ``Brewfile`` that lists all of the dependencies to the current directory, and run ``brew bundle`` to process them (installing or upgrading as needed). ``Brewfile`` is a plain text file.
+Install or upgrade the required Homebrew packages, if any are missing.
+To do this, use ``brew edit ocrmypdf`` to obtain a recent list of Homebrew
+dependencies. You could also check the ``.workflows/build.yml``.
-.. code-block:: bash
-
- wget https://github.com/jbarlow83/OCRmyPDF/raw/master/.travis/Brewfile
- brew bundle
-
-This will include the English, French, German and Spanish language packs. If you need other languages you can optionally install them all:
+This will include the English, French, German and Spanish language
+packs. If you need other languages you can optionally install them all:
.. _macos-all-languages:
-.. code-block:: bash
+ .. code-block:: bash
- brew install tesseract --with-all-languages # Option 2: for all language packs
+ brew install tesseract-lang # Option 2: for all language packs
Update the homebrew pip:
@@ -364,94 +499,285 @@ The command line program should now be available:
ocrmypdf --help
-Installing the Docker image
+Installing on Windows
+=====================
+
+Native Windows
+--------------
+
+.. note::
+
+ Administrator privileges will be required for some of these steps.
+
+You must install the following for Windows:
+
+* Python 3.7 (64-bit) or later
+* Tesseract 4.0 or later
+* Ghostscript 9.50 or later
+
+Using the `Chocolatey `_ package manager, install the
+following when running in an Administrator command prompt:
+
+* ``choco install python3``
+* ``choco install --pre tesseract``
+* ``choco install ghostscript``
+* ``choco install pngquant`` (optional)
+
+The commands above will install Python 3.x (latest version), Tesseract, Ghostscript
+and pngquant. Chocolatey may also need to install the Windows Visual C++ Runtime
+DLLs or other Windows patches, and may require a reboot.
+
+You may then use ``pip`` to install ocrmypdf. (This can performed by a user or
+Administrator.):
+
+* ``pip install ocrmypdf``
+
+Chocolatey automatically selects appropriate versions of these applications. If you
+are installing them manually, please install 64-bit versions of all applications for
+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
+for third party software it needs (specifically, Tesseract and Ghostscript). To
+override the versions OCRmyPDF selects, you can modify the ``PATH`` environment
+variable. `Follow these directions `_
+to change the PATH.
+
+.. warning::
+
+ As of early 2021, users have reported problems with the Microsoft Store version of
+ Python and OCRmyPDF. These issues affect many other third party Python packages.
+ Please download Python from Python.org or Chocolatey instead, and do not use the
+ Microsoft Store version.
+
+Windows Subsystem for Linux
---------------------------
-For some users, installing the Docker image will be easier than installing all of OCRmyPDF's dependencies. For Windows, it is the only option.
+#. Install Ubuntu 18.04 for Windows Subsystem for Linux, if not already installed.
+#. Follow the procedure to install :ref:`OCRmyPDF on Ubuntu 18.04 `.
+#. Open the Windows command prompt and create a symlink:
-See `OCRmyPDF Docker Image `_ for more information.
+.. code-block:: powershell
-Installing on Windows
----------------------
+ wsl sudo ln -s /home/$USER/.local/bin/ocrmypdf /usr/local/bin/ocrmypdf
-Direct installation on Windows is not possible. `Install the Docker `_ container as described above. Ensure that your command prompt can run the docker "hello world" container.
+Then confirm that the expected version from PyPI (|latest|) is installed:
-It would probably not be too difficult to port on Windows. The main reason this has been avoided is the difficulty of packaging and installing the various non-Python dependencies: Tesseract, QPDF, Ghostscript, Leptonica. Pull requests to add or improve Windows support would be quite welcome.
+.. code-block:: powershell
+
+ wsl ocrmypdf --version
+
+You can then run OCRmyPDF in the Windows command prompt or Powershell, prefixing
+``wsl``, and call it from Windows programs or batch files.
+
+Cygwin64
+--------
+
+First install the the following prerequisite Cygwin packages using ``setup-x86_64.exe``::
+
+ python36 (or later)
+ python3?-devel
+ python3?-pip
+ python3?-lxml
+ python3?-imaging
+
+ (where 3? means match the version of python3 you installed)
+
+ gcc-g++
+ ghostscript (<=9.50 or >=9.52-2 see note below)
+ libexempi3
+ libexempi-devel
+ libffi6
+ libffi-devel
+ pngquant
+ qpdf
+ libqpdf-devel
+ tesseract-ocr
+ tesseract-ocr-devel
+
+.. note::
+
+ The Cygwin package for Ghostscript in versions 9.52 and
+ 9.52-1 contained a bug that caused an exception to occur when
+ ocrmypdf invoked gs. Make sure you have either 9.50 (or earlier)
+ or 9.52-2 (or later).
+
+Then open a Cygwin terminal (i.e. ``mintty``), run the following commands. Note
+that if you are using the version of ``pip`` that was installed with the Cygwin
+Python package, the command name will be ``pip3``. If you have since updated
+``pip`` (with, for instance ``pip3 install --upgrade pip``) the the command is
+likely just ``pip`` instead of ``pip3``:
+
+.. code-block:: bash
+
+ pip3 install wheel
+ pip3 install ocrmypdf
+
+The optional dependency "unpaper" that is currently not available under Cygwin.
+Without it, certain options such as ``--clean`` will produce an error message.
+However, the OCR-to-text-layer functionality is available.
+
+Docker
+------
+
+You can also :ref:`Install the Docker ` container on Windows. Ensure that
+your command prompt can run the docker "hello world" container.
+
+Installing on FreeBSD
+=====================
+
+.. image:: https://repology.org/badge/version-for-repo/freebsd/python:ocrmypdf.svg
+ :alt: FreeBSD
+ :target: https://repology.org/project/python:ocrmypdf/versions
+
+FreeBSD 11.3, 12.0, 12.1-RELEASE and 13.0-CURRENT are supported. Other
+versions likely work but have not been tested.
+
+.. code-block:: bash
+
+ pkg install py37-ocrmypdf
+
+To install a more recent version, you could attempt to first install the system
+version with ``pkg``, then use ``pip install --user ocrmypdf``.
+
+Installing the Docker image
+===========================
+
+For some users, installing the Docker image will be easier than
+installing all of OCRmyPDF's dependencies.
+
+See :ref:`docker` for more information.
Installing with Python pip
---------------------------
+==========================
-OCRmyPDF is delivered by PyPI because it is a convenient way to install the latest version. However, PyPI and ``pip`` cannot address the fact that ``ocrmypdf`` depends on certain non-Python system libraries and programs being instsalled.
+OCRmyPDF is delivered by PyPI because it is a convenient way to install
+the latest version. However, PyPI and ``pip`` cannot address the fact
+that ``ocrmypdf`` depends on certain non-Python system libraries and
+programs being installed.
-For best results, first install `your platform's version `_ of ``ocrmypdf``, using the instructions elsewhere in this document. Then you can use ``pip`` to get the latest version if your platform version is out of date. Chances are that this will satisfy most dependencies.
+.. warning::
+
+ Debian and Ubuntu users: unfortunately, Debian and Ubuntu customize
+ Python in non-standard ways, and the nature of these customizations
+ varies from release to release. This can make for a frustrating
+ user experience. The instructions below work on almost all platforms that
+ have Python installed, except for Debian and Ubuntu, where you may need
+ to take additional steps. For best results on Debian and Ubuntu, use the
+ ``apt`` packages; or if these are too old, run
+ ``apt install python3-pip python3-venv``, create a virtual environment,
+ and install OCRmyPDF in that environment.
+
+ `See here for more inforation on Debian-Python issues
+ `__.
+
+For best results, first install `your platform's
+version `__ of
+``ocrmypdf``, using the instructions elsewhere in this document. Then
+you can use ``pip`` to get the latest version if your platform version
+is out of date. Chances are that this will satisfy most dependencies.
Use ``ocrmypdf --version`` to confirm what version was installed.
-Then you can install the latest OCRmyPDF from the Python wheels. First try:
+Then you can install the latest OCRmyPDF from the Python wheels. First
+try:
.. code-block:: bash
pip3 install --user ocrmypdf
-You should then be able to run ``ocrmypdf --version`` and see that the latest version was located.
+You should then be able to run ``ocrmypdf --version`` and see that the
+latest version was located.
-Since ``pip3 install --user`` does not work correctly on some platforms, notably Ubuntu 16.04 and older, and the Homebrew version of Python, instead use this for a system wide installation:
+Since ``pip3 install --user`` does not work correctly on some platforms,
+notably Ubuntu 16.04 and older, and the Homebrew version of Python,
+instead use this for a system wide installation:
.. code-block:: bash
pip3 install ocrmypdf
+.. note::
+
+ AArch64 (ARM64) users: this process will be difficult because most
+ Python packages are not available as binary wheels for your platform.
+ You're probably better off using a platform install on Debian, Ubuntu,
+ or Fedora.
+
Requirements for pip and HEAD install
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+-------------------------------------
-OCRmyPDF currently requires these external programs and libraries to be installed, and must be satisfied using the operating system package manager. ``pip`` cannot provide them.
+OCRmyPDF currently requires these external programs and libraries to be
+installed, and must be satisfied using the operating system package
+manager. ``pip`` cannot provide them.
-- Python 3.6 or newer
-- Ghostscript 9.15 or newer
-- qpdf 8.1.0 or newer
-- Tesseract 4.0.0-alpha or newer
+- Python 3.6 or newer
+- Ghostscript 9.15 or newer
+- qpdf 8.1.0 or newer
+- Tesseract 4.0.0-beta or newer
As of ocrmypdf 7.2.1, the following versions are recommended:
-- Python 3.7
-- Ghostscript 9.23 or newer
-- qpdf 8.2.1
-- Tesseract 4.0.0 or newer
-- jbig2enc 0.29 or newer
-- pngquant 2.5 or newer
-- unpaper 6.1
+- Python 3.7 or 3.8
+- Ghostscript 9.23 or newer
+- qpdf 8.2.1
+- Tesseract 4.0.0 or newer
+- jbig2enc 0.29 or newer
+- pngquant 2.5 or newer
+- unpaper 6.1
-jbig2enc, pngquant, and unpaper are optional. If missing certain features are disabled. OCRmyPDF will discover them as soon as they are available.
+jbig2enc, pngquant, and unpaper are optional. If missing certain
+features are disabled. OCRmyPDF will discover them as soon as they are
+available.
-**jbig2enc**, if present, will be used to optimize the encoding of monochrome images. This can significantly reduce the file size of the output file. It is not required. `jbig2enc `_ is not generally available for Ubuntu or Debian due to lingering concerns about patent issues, but can easily be built from source. To add JBIG2 encoding, see :ref:`jbig2`.
+**jbig2enc**, if present, will be used to optimize the encoding of
+monochrome images. This can significantly reduce the file size of the
+output file. It is not required.
+`jbig2enc `__ is not generally
+available for Ubuntu or Debian due to lingering concerns about patent
+issues, but can easily be built from source. To add JBIG2 encoding, see
+:ref:`jbig2`.
-**pngquant**, if present, is optionally used to optimize the encoding of PNG-style images in PDFs (actually, any that are that losslessly encoded) by lossily quantizing to a smaller color palette. It is only activated then the ``--optimize`` argument is ``2`` or ``3``.
+**pngquant**, if present, is optionally used to optimize the encoding of
+PNG-style images in PDFs (actually, any that are that losslessly
+encoded) by lossily quantizing to a smaller color palette. It is only
+activated then the ``--optimize`` argument is ``2`` or ``3``.
-**unpaper**, if present, enables the ``--clean`` and ``--clean-final`` command line options.
-
-These are in addition to the Python packaging dependencies, meaning that unfortunately, the ``pip install`` command cannot satisfy all of them.
+**unpaper**, if present, enables the ``--clean`` and ``--clean-final``
+command line options.
+These are in addition to the Python packaging dependencies, meaning that
+unfortunately, the ``pip install`` command cannot satisfy all of them.
Installing HEAD revision from sources
--------------------------------------
+=====================================
-If you have ``git`` and Python 3.6 or newer installed, you can install from source. When the ``pip`` installer runs, it will alert you if dependencies are missing.
+If you have ``git`` and Python 3.6 or newer installed, you can install
+from source. When the ``pip`` installer runs, it will alert you if
+dependencies are missing.
-If you prefer to build every from source, you will need to `build pikepdf from source `_. First ensure you can build and install pikepdf.
+If you prefer to build every from source, you will need to `build
+pikepdf from
+source `__.
+First ensure you can build and install pikepdf.
-To install the HEAD revision from sources in the current Python 3 environment:
+To install the HEAD revision from sources in the current Python 3
+environment:
.. code-block:: bash
pip3 install git+https://github.com/jbarlow83/OCRmyPDF.git
-Or, to install in `development mode `_, allowing customization of OCRmyPDF, use the ``-e`` flag:
+Or, to install in `development
+mode `__,
+allowing customization of OCRmyPDF, use the ``-e`` flag:
.. code-block:: bash
pip3 install -e git+https://github.com/jbarlow83/OCRmyPDF.git
-You may find it easiest to install in a virtual environment, rather than system-wide:
+You may find it easiest to install in a virtual environment, rather than
+system-wide:
.. code-block:: bash
@@ -461,8 +787,8 @@ You may find it easiest to install in a virtual environment, rather than system-
cd OCRmyPDF
pip3 install .
-However, ``ocrmypdf`` will only be accessible on the system PATH
-when you activate the virtual environment.
+However, ``ocrmypdf`` will only be accessible on the system PATH when
+you activate the virtual environment.
To run the program:
@@ -476,7 +802,7 @@ dependencies. Older version than the ones mentioned in the release notes
are likely not to be compatible to OCRmyPDF.
For development
-^^^^^^^^^^^^^^^
+---------------
To install all of the development and test requirements:
@@ -492,15 +818,17 @@ To install all of the development and test requirements:
To add JBIG2 encoding, see :ref:`jbig2`.
Shell completions
------------------
+=================
Completions for ``bash`` and ``fish`` are available in the project's
``misc/completion`` folder. The ``bash`` completions are likely ``zsh``
-compatible but this has not been confirmed. Package maintainers, please install
-these at the appropriate locations for your system.
+compatible but this has not been confirmed. Package maintainers, please
+install these at the appropriate locations for your system.
-To manually install the ``bash`` completion, copy ``misc/completion/ocrmypdf.bash`` to
-``/etc/bash_completion.d/ocrmypdf`` (rename the file).
+To manually install the ``bash`` completion, copy
+``misc/completion/ocrmypdf.bash`` to ``/etc/bash_completion.d/ocrmypdf``
+(rename the file).
-To manually install the ``fish`` completion, copy ``misc/completion/ocrmypdf.fish`` to
+To manually install the ``fish`` completion, copy
+``misc/completion/ocrmypdf.fish`` to
``~/.config/fish/completions/ocrmypdf.fish``.
diff --git a/docs/introduction.rst b/docs/introduction.rst
index f7f80568..360d57ec 100644
--- a/docs/introduction.rst
+++ b/docs/introduction.rst
@@ -1,119 +1,233 @@
+============
Introduction
============
-OCRmyPDF is a Python 3 package that adds OCR layers to PDFs.
+
+OCRmyPDF is a Python 3 application and library that adds OCR layers to PDFs.
About OCR
----------
+=========
-`Optical character recognition `_ is technology that converts images of typed or handwritten text, such as in a scanned document, to computer text that can be searched and copied.
+`Optical character
+recognition `__
+is technology that converts images of typed or handwritten text, such as
+in a scanned document, to computer text that can be selected, searched and copied.
-OCRmyPDF uses `Tesseract `_, the best available open source OCR engine, to perform OCR.
+OCRmyPDF uses
+`Tesseract `__, the best
+available open source OCR engine, to perform OCR.
.. _raster-vector:
About PDFs
-----------
+==========
-PDFs are page description files that attempts to preserve a layout exactly. They contain `vector graphics `_ that can contain raster objects such as scanned images. Because PDFs can contain multiple pages (unlike many image formats) and can contain fonts and text, it is a good formats for exchanging scanned documents.
+PDFs are page description files that attempts to preserve a layout
+exactly. They contain `vector
+graphics `__
+that can contain raster objects such as scanned images. Because PDFs can
+contain multiple pages (unlike many image formats) and can contain fonts
+and text, it is a good formats for exchanging scanned documents.
-.. image:: images/bitmap_vs_svg.svg
+|image|
-A PDF page might contain multiple images, even if it only appears to have one image. Some scanners or scanning software will segment pages into monochromatic text and color regions for example, to improve the compression ratio and appearance of the page.
-
-Rasterizing a PDF is the process of generating an image suitable for display or analyzing with an OCR engine. OCR engines like Tesseract work with images, not vector objects.
+A PDF page might contain multiple images, even if it only appears to
+have one image. Some scanners or scanning software will segment pages
+into monochromatic text and color regions for example, to improve the
+compression ratio and appearance of the page.
+Rasterizing a PDF is the process of generating an image suitable for
+display or analyzing with an OCR engine. OCR engines like Tesseract work
+with images, not vector objects.
About PDF/A
------------
+===========
-`PDF/A `_ is an ISO-standardized subset of the full PDF specification that is designed for archiving (the 'A' stands for Archive). PDF/A differs from PDF primarily by omitting features that would make it difficult to read the file in the future, such as embedded Javascript, video, audio and references to external fonts. All fonts and resources needed to interpret the PDF must be contained within it. Because PDF/A disables Javascript and other types of embedded content, it is probably more secure.
+`PDF/A `__ is an ISO-standardized
+subset of the full PDF specification that is designed for archiving (the
+'A' stands for Archive). PDF/A differs from PDF primarily by omitting
+features that would make it difficult to read the file in the future,
+such as embedded Javascript, video, audio and references to external
+fonts. All fonts and resources needed to interpret the PDF must be
+contained within it. Because PDF/A disables Javascript and other types
+of embedded content, it is probably more secure.
There are various conformance levels and versions, such as "PDF/A-2b".
-Generally speaking, the best format for scanned documents is PDF/A. Some governments and jurisdictions, US Courts in particular, `mandate the use of PDF/A `_ for scanned documents.
+Generally speaking, the best format for scanned documents is PDF/A. Some
+governments and jurisdictions, US Courts in particular, `mandate the use
+of PDF/A `__ for scanned
+documents.
-Since most people who scan documents are interested in reading them indefinitely into the future, OCRmyPDF generates PDF/A-2b by default.
-
-PDF/A has a few drawbacks. Some PDF viewers include an alert that the file is a PDF/A, which may confuse some users. It also tends to produce larger files than PDF, because it embeds certain resources even if they are commonly available. PDF/A files can be digitally signed, but may not be encrypted, to ensure they can be read in the future. Fortunately, converting from PDF/A to a regular PDF is trivial, and any PDF viewer can view PDF/A.
+Since most people who scan documents are interested in reading them
+indefinitely into the future, OCRmyPDF generates PDF/A-2b by default.
+PDF/A has a few drawbacks. Some PDF viewers include an alert that the
+file is a PDF/A, which may confuse some users. It also tends to produce
+larger files than PDF, because it embeds certain resources even if they
+are commonly available. PDF/A files can be digitally signed, but may not
+be encrypted, to ensure they can be read in the future. Fortunately,
+converting from PDF/A to a regular PDF is trivial, and any PDF viewer
+can view PDF/A.
What OCRmyPDF does
-------------------
+==================
-OCRmyPDF analyzes each page of a PDF to determine the colorspace and resolution (DPI) needed to capture all of the information on that page without losing content. It uses `Ghostscript `_ to rasterize the page, and then performs on OCR on the rasterized image to create an OCR "layer". The layer is then grafted back onto the original PDF.
+OCRmyPDF analyzes each page of a PDF to determine the colorspace and
+resolution (DPI) needed to capture all of the information on that page
+without losing content. It uses
+`Ghostscript `__ to rasterize the page, and
+then performs on OCR on the rasterized image to create an OCR "layer".
+The layer is then grafted back onto the original PDF.
-While one can use a program like Ghostscript or ImageMagick to get an image and put the image through Tesseract, that actually creates a new PDF and many details may be lost. OCRmyPDF can produce a minimally changed PDF as output.
+While one can use a program like Ghostscript or ImageMagick to get an
+image and put the image through Tesseract, that actually creates a new
+PDF and many details may be lost. OCRmyPDF can produce a minimally
+changed PDF as output.
-OCRmyPDF also some image processing options like deskew which improve the appearance of files and quality of OCR. When these are used, the OCR layer is grafted onto the processed image instead.
-
-By default, OCRmyPDF produces archival PDFs – PDF/A, which are a stricter subset of PDF features designed for long term archives. If regular PDFs are desired, this can be disabled with ``--output-type pdf``.
+OCRmyPDF also some image processing options like deskew which improve
+the appearance of files and quality of OCR. When these are used, the OCR
+layer is grafted onto the processed image instead.
+By default, OCRmyPDF produces archival PDFs – PDF/A, which are a
+stricter subset of PDF features designed for long term archives. If
+regular PDFs are desired, this can be disabled with
+``--output-type pdf``.
Why you shouldn't do this manually
-----------------------------------
+==================================
-A PDF is similar to an HTML file, in that it contains document structure along with images. Sometimes a PDF does nothing more than present a full page image, but often there is additional content that would be lost.
+A PDF is similar to an HTML file, in that it contains document structure
+along with images. Sometimes a PDF does nothing more than present a full
+page image, but often there is additional content that would be lost.
A manual process could work like either of these:
-1. Rasterize each page as an image, OCR the images, and combine the output into a PDF. This preserves the layout of each page, but resamples all images (possibly losing quality, increasing file size, introducing compression artifacts, etc.).
+1. Rasterize each page as an image, OCR the images, and combine the
+ output into a PDF. This preserves the layout of each page, but
+ resamples all images (possibly losing quality, increasing file size,
+ introducing compression artifacts, etc.).
+2. Extract each image, OCR, and combine the output into a PDF. This
+ loses the context in which images are used in the PDF, meaning that
+ cropping, rotation and scaling of pages may be lost. Some scanned
+ PDFs use multiple images segmented into black and white, grayscale
+ and color regions, with stencil masks to prevent overlap, as this can
+ enhance the appearance of a file while reducing file size. Clearly,
+ reassembling these images will be easy. This also loses and text or
+ vector art on any pages in a PDF with both scanned and pure digital
+ content.
-2. Extract each image, OCR, and combine the output into a PDF. This loses the context in which images are used in the PDF, meaning that cropping, rotation and scaling of pages may be lost. Some scanned PDFs use multiple images segmented into black and white, grayscale and color regions, with stencil masks to prevent overlap, as this can enhance the appearance of a file while reducing file size. Clearly, reassembling these images will be easy. This also loses and text or vector art on any pages in a PDF with both scanned and pure digital content.
+In the case of a PDF that is nothing other than a container of images
+(no rotation, scaling, cropping, one image per page), the second
+approach can be lossless.
-In the case of a PDF that is nothing other than a container of images (no rotation, scaling, cropping, one image per page), the second approach can be lossless.
-
-OCRmyPDF uses several strategies depending on input options and the input PDF itself, but generally speaking it rasterizes a page for OCR and then grafts the OCR back onto the original. As such it can handle complex PDFs and still preserve their contents as much as possible.
-
-OCRmyPDF also supports a many, many edge cases that have cropped over several years of development. We support PDF features like images inside of Form XObjects, and pages with UserUnit scaling. We support rare image formats like non-monochrome 1-bit images. We warn about files you may not to OCR. Thanks to pikepdf and QPDF, we auto-repair PDFs that are damaged. (Not that you need to know what any of these are! You should be able to throw any PDF at it.)
+OCRmyPDF uses several strategies depending on input options and the
+input PDF itself, but generally speaking it rasterizes a page for OCR
+and then grafts the OCR back onto the original. As such it can handle
+complex PDFs and still preserve their contents as much as possible.
+OCRmyPDF also supports a many, many edge cases that have cropped over
+several years of development. We support PDF features like images inside
+of Form XObjects, and pages with UserUnit scaling. We support rare image
+formats like non-monochrome 1-bit images. We warn about files you may
+not to OCR. Thanks to pikepdf and QPDF, we auto-repair PDFs that are
+damaged. (Not that you need to know what any of these are! You should be
+able to throw any PDF at it.)
Limitations
------------
+===========
-OCRmyPDF is limited by the Tesseract OCR engine. As such it experiences these limitations, as do any other programs that rely on Tesseract:
+OCRmyPDF is limited by the Tesseract OCR engine. As such it experiences
+these limitations, as do any other programs that rely on Tesseract:
-* The OCR is not as accurate as commercial solutions such as Abbyy.
-* It is not capable of recognizing handwriting.
-* It may find gibberish and report this as OCR output.
-* If a document contains languages outside of those given in the ``-l LANG`` arguments, results may be poor.
-* It is not always good at analyzing the natural reading order of documents. For example, it may fail to recognize that a document contains two columns, and may try to join text across columns.
-* Poor quality scans may produce poor quality OCR. Garbage in, garbage out.
-* It does not expose information about what font family text belongs to.
+- The OCR is not as accurate as commercial solutions such as Abbyy.
+- It is not capable of recognizing handwriting.
+- It may find gibberish and report this as OCR output.
+- If a document contains languages outside of those given in the
+ ``-l LANG`` arguments, results may be poor.
+- It is not always good at analyzing the natural reading order of
+ documents. For example, it may fail to recognize that a document
+ contains two columns, and may try to join text across columns.
+- Poor quality scans may produce poor quality OCR. Garbage in, garbage
+ out.
+- It does not expose information about what font family text belongs
+ to.
OCRmyPDF is also limited by the PDF specification:
-* PDF encodes the position of text glyphs but does not encode document structure. There is no markup that divides a document in sections, paragraphs, sentences, or even words (since blank spaces are not represented). As such all elements of document structure including the spaces between words must be derived heuristically. Some PDF viewers do a better job of this than others.
-* Because some popular open source PDF viewers have a particularly hard time with spaces betweem words, OCRmyPDF appends a space to each text element as a workaround (when using ``--pdf-renderer hocr``). While this mixes document structure with graphical information that ideally should be left to the PDF viewer to interpret, it improves compatibility with some viewers and does not cause problems for better ones.
+- PDF encodes the position of text glyphs but does not encode document
+ structure. There is no markup that divides a document in sections,
+ paragraphs, sentences, or even words (since blank spaces are not
+ represented). As such all elements of document structure including
+ the spaces between words must be derived heuristically. Some PDF
+ viewers do a better job of this than others.
+- Because some popular open source PDF viewers have a particularly hard
+ time with spaces between words, OCRmyPDF appends a space to each text
+ element as a workaround (when using ``--pdf-renderer hocr``). While
+ this mixes document structure with graphical information that ideally
+ should be left to the PDF viewer to interpret, it improves
+ compatibility with some viewers and does not cause problems for
+ better ones.
Ghostscript also imposes some limitations:
-* PDFs containing JBIG2-encoded content will be converted to CCITT Group4 encoding, which has lower compression ratios, if Ghostscript PDF/A is enabled.
-* PDFs containing JPEG 2000-encoded content will be converted to JPEG encoding, which may introduce compression artifacts, if Ghostscript PDF/A is enabled.
-* Ghostscript may transcode grayscale and color images, either lossy to lossless or lossless to lossy, based on an internal algorithm. This behavior can be suppressed by setting ``--pdfa-image-compression`` to ``jpeg`` or ``lossless`` to set all images to one type or the other. Ghostscript has no option to maintain the input image's format. (Ghostscript 9.25+ can copy JPEG images without transcoding them; earlier versions will transcode.)
-* Ghostscript's PDF/A conversion removes any XMP metadata that is not one of the standard XMP metadata namespaces for PDFs. In particular, PRISM Metdata is removed.
+- PDFs containing JBIG2-encoded content will be converted to CCITT
+ Group4 encoding, which has lower compression ratios, if Ghostscript
+ PDF/A is enabled.
+- PDFs containing JPEG 2000-encoded content will be converted to JPEG
+ encoding, which may introduce compression artifacts, if Ghostscript
+ PDF/A is enabled.
+- Ghostscript may transcode grayscale and color images, either lossy to
+ lossless or lossless to lossy, based on an internal algorithm. This
+ behavior can be suppressed by setting ``--pdfa-image-compression`` to
+ ``jpeg`` or ``lossless`` to set all images to one type or the other.
+ Ghostscript has no option to maintain the input image's format.
+ (Ghostscript 9.25+ can copy JPEG images without transcoding them;
+ earlier versions will transcode.)
+- Ghostscript's PDF/A conversion removes any XMP metadata that is not
+ one of the standard XMP metadata namespaces for PDFs. In particular,
+ PRISM Metdata is removed.
+- Ghostscript's PDF/A conversion seems to remove or deactivate
+ hyperlinks and other active content.
+
+You can use ``--output-type pdf`` to disable PDF/A conversion and produce
+a standard, non-archival PDF.
Regarding OCRmyPDF itself:
-* PDFs that use transparency are not currently represented in the test suite
-* The Python API exported by ``import ocrmypdf`` is design to help scripts that use OCRmyPDF but is not currently capable of running OCRmyPDF jobs due to limitations in an underlying library.
+- PDFs that use transparency are not currently represented in the test
+ suite
Similar programs
-----------------
+================
-To the author's knowledge, OCRmyPDF is the most feature-rich and thoroughly tested command line OCR PDF conversion tool. If it does not meet your needs, contributions and suggestions are welcome. If not, consider one of these similar open source programs:
+To the author's knowledge, OCRmyPDF is the most feature-rich and
+thoroughly tested command line OCR PDF conversion tool. If it does not
+meet your needs, contributions and suggestions are welcome. If not,
+consider one of these similar open source programs:
-* pdf2pdfocr
-* pdfsandwich
-* pypdfocr
-* pdfbeads
+- pdf2pdfocr
+- pdfsandwich
+- pypdfocr
+- pdfbeads
Web front-ends
---------------
+==============
-The Docker image ``ocrmypdf-alpine`` provides a web service front-end that allows files to submitted over HTTP and the results "downloaded". This is an HTTP server intended to simplify web services deployments; it is not intended to be deployed on the public internet and no real security measures to speak of.
+The Docker image ``ocrmypdf`` provides a web service front-end
+that allows files to submitted over HTTP and the results "downloaded".
+This is an HTTP server intended to simplify web services deployments; it
+is not intended to be deployed on the public internet and no real
+security measures to speak of.
In addition, the following third-party integrations are available:
-* `Nextcloud OCR `_ is a free software plugin for the Nextcloud private cloud software
+- `Nextcloud OCR `__ is a free software
+ plugin for the Nextcloud private cloud software
-OCRmyPDF is not designed to be secure against malware-bearing PDFs (see `Using OCRmyPDF online `_). Users should ensure they comply with OCRmyPDF's licenses and the licenses of all dependencies. In particular, OCRmyPDF requires Ghostscript, which is licensed under AGPLv3.
+OCRmyPDF is not designed to be secure against malware-bearing PDFs (see
+`Using OCRmyPDF online `__). Users should ensure they
+comply with OCRmyPDF's licenses and the licenses of all dependencies. In
+particular, OCRmyPDF requires Ghostscript, which is licensed under
+AGPLv3.
+
+.. |image| image:: images/bitmap_vs_svg.svg
diff --git a/docs/jbig2.rst b/docs/jbig2.rst
index 3ee524ca..81789b6f 100644
--- a/docs/jbig2.rst
+++ b/docs/jbig2.rst
@@ -1,35 +1,55 @@
.. _jbig2:
+============================
Installing the JBIG2 encoder
============================
-Most Linux distributions do not include a JBIG2 encoder since JBIG2 encoding was patented for a long time. All known JBIG2 US patents have expired as of 2017, but it is possible that unknown patents exist.
+Most Linux distributions do not include a JBIG2 encoder since JBIG2
+encoding was patented for a long time. All known JBIG2 US patents have
+expired as of 2017, but it is possible that unknown patents exist.
-JBIG2 encoding is recommended for OCRmyPDF and is used to losslessly create smaller PDFs. If JBIG2 encoding not available, lower quality encodings will be used.
+JBIG2 encoding is recommended for OCRmyPDF and is used to losslessly
+create smaller PDFs. If JBIG2 encoding not available, lower quality
+encodings will be used.
-JBIG2 decoding is not patented and is performed automatically by most PDF viewers. It is widely supported has been part of the PDF specification since 2001.
+JBIG2 decoding is not patented and is performed automatically by most
+PDF viewers. It is widely supported has been part of the PDF
+specification since 2001.
-On macOS, Homebrew packages jbig2enc and OCRmyPDF includes it by default. The Docker image for OCRmyPDF also builds its own JBIG2 encoder from source.
+On macOS, Homebrew packages jbig2enc and OCRmyPDF includes it by
+default. The Docker image for OCRmyPDF also builds its own JBIG2 encoder
+from source.
For all other Linux, you must build a JBIG2 encoder from source:
.. code-block:: bash
- git clone https://github.com/agl/jbig2enc
- cd jbig2enc
- ./autogen.sh
- ./configure && make
- [sudo] make install
+ git clone https://github.com/agl/jbig2enc
+ cd jbig2enc
+ ./autogen.sh
+ ./configure && make
+ [sudo] make install
.. _jbig2-lossy:
Lossy mode JBIG2
-----------------
+================
-OCRmyPDF provides lossy mode JBIG2 as an advanced feature. Users should `review the technical concerns with JBIG2 in lossy mode `_ and decide if this feature is acceptable for their use case.
+OCRmyPDF provides lossy mode JBIG2 as an advanced feature. Users should
+`review the technical concerns with JBIG2 in lossy
+mode `__
+and decide if this feature is acceptable for their use case.
-JBIG2 lossy mode does achieve higher compression ratios than any other monochrome (bitonal) compression technology; for large text documents the savings are considerable. JBIG2 lossless still gives great compression ratios and is a major improvement over the older CCITT G4 standard. As explained above, there is some risk of substitution errors.
+JBIG2 lossy mode does achieve higher compression ratios than any other
+monochrome (bitonal) compression technology; for large text documents
+the savings are considerable. JBIG2 lossless still gives great
+compression ratios and is a major improvement over the older CCITT G4
+standard. As explained above, there is some risk of substitution errors.
-To turn on JBIG2 lossy mode, add the argument ``--jbig2-lossy``. ``--optimize {1,2,3}`` are necessary for the argument to take effect also required. Also, a JBIG2 encoder must be installed as described in the previous section.
+To turn on JBIG2 lossy mode, add the argument ``--jbig2-lossy``.
+``--optimize {1,2,3}`` are necessary for the argument to take effect
+also required. Also, a JBIG2 encoder must be installed as described in
+the previous section.
-*Due to an oversight, ocrmypdf v7.0 and v7.1 used lossy mode by default.*
+*Due to an oversight, ocrmypdf v7.0 and v7.1 used lossy mode by
+default.*
diff --git a/docs/languages.rst b/docs/languages.rst
index 5b5a8853..45dfac6f 100644
--- a/docs/languages.rst
+++ b/docs/languages.rst
@@ -1,16 +1,29 @@
.. _lang-packs:
+====================================
Installing additional language packs
====================================
-OCRmyPDF uses Tesseract for OCR, and relies on its language packs for languages other than English.
+OCRmyPDF uses Tesseract for OCR, and relies on its language packs for all languages.
+On most platforms, English is installed with Tesseract by default, but not always.
-Tesseract supports `most languages `_.
+Tesseract supports `most
+languages `__.
+Languages are identified by standardized three-letter codes (called ISO 639-2 Alpha-3).
+Tesseract's documentation also lists the three-letter code for your language.
+Some are anglicized, e.g. Spanish is ``spa`` rather than ``esp``, while others
+are not, e.g. German is ``deu`` and French is ``fra``.
-For Linux users, you can often find packages that provide language packs:
+After you have installed a language pack, you can use it with ``ocrmypdf -l ``,
+for example ``ocrmypdf -l spa``. For multilingual documents, you can specify
+all languages to be expected, e.g. ``ocrmypdf -l eng+fra`` for English and French.
+English is assumed by default unless other language(s) are specified.
+
+For Linux users, you can often find packages that provide language
+packs:
Debian and Ubuntu users
------------------------
+=======================
.. code-block:: bash
@@ -20,11 +33,13 @@ Debian and Ubuntu users
# Install Chinese Simplified language pack
apt-get install tesseract-ocr-chi-sim
-You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as to what languages it should search for. Multiple
-languages can be requested using either ``-l eng+fre`` (English and French) or ``-l eng -l fre``.
+You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as
+to what languages it should search for. Multiple languages can be
+requested using either ``-l eng+fra`` (English and French) or
+``-l eng -l fra``.
Fedora users
-------------
+============
.. code-block:: bash
@@ -34,16 +49,28 @@ Fedora users
# Install Chinese Simplified language pack
dnf install tesseract-langpack-chi_sim
-You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as to
-what languages it should search for. Multiple languages can be requested using
-either ``-l eng+fre`` (English and French) or ``-l eng -l fre``.
+You can then pass the ``-l LANG`` argument to OCRmyPDF to give a hint as
+to what languages it should search for. Multiple languages can be
+requested using either ``-l eng+fra`` (English and French) or
+``-l eng -l fra``.
macOS users
------------
+===========
-You can install additional language packs by :ref:`installing Tesseract using Homebrew with all language packs `.
+You can install additional language packs by
+:ref:`installing Tesseract using Homebrew with all language packs `.
Docker users
-------------
+============
-Users of the OCRmyPDF Docker image should install language packs into a derived Docker image as :ref:`described in that section `.
+Users of the OCRmyPDF Docker image should install language packs into a
+derived Docker image as
+:ref:`described in that section `.
+
+Windows users
+=============
+
+The Tesseract installer provided by Chocolatey currently includes only English language.
+To install other languages, download the respective language pack (``.traineddata`` file)
+from https://github.com/tesseract-ocr/tessdata/ and place it in
+``C:\\Program Files\\Tesseract-OCR\\tessdata`` (or wherever Tesseract OCR is installed).
diff --git a/docs/optimizer.rst b/docs/optimizer.rst
new file mode 100644
index 00000000..02f0be21
--- /dev/null
+++ b/docs/optimizer.rst
@@ -0,0 +1,75 @@
+================
+PDF optimization
+================
+
+OCRmyPDF includes an image-oriented PDF optimizer. By default, the optimizer
+runs with safe settings with the goal of improving compression at no loss of
+quality. At higher optimization levels, lossy optimizations may be applied and
+tuned. Optimization occurs after OCR, and only if OCR succeeded. It does not
+perform other possible optimizations such as deduplicating resources,
+consolidating fonts, simplifying vector drawings, or anything of that nature.
+
+Optimization ranges from ``-O0`` through ``-O3``, where ``0`` disables
+optimization and ``3`` implements all options. ``1``, the default, performs only
+safe and lossless optimizations. (This is similar to GCC's optimization
+parameter.) The exact type of optimizations performed will vary over time.
+
+PDF optimization requires third-party, optional tools for certain optimizations.
+If these are not installed or cannot be found by OCRmyPDF, optimization will not
+be as good.
+
+Optimizations that always occurs
+================================
+
+OCRmyPDF will automatically replace obsolete or inferior compression schemes
+such as RLE or LZW with superior schemes such as Deflate and converting
+monochrome images to CCITT G4. Since this is harmless it always occurs and there
+is no way to disable it. Other non-image compressed objects are compressed as
+well.
+
+Fast web view
+=============
+
+OCRmyPDF automatically optimizes PDFs for "fast web view" in Adobe Acrobat's
+parlance, or equivalently, linearizes PDFs so that the resources they reference
+are presented in the order a viewer needs them for sequential display. This
+reduces the latency of viewing a PDF both online and from local storage. This
+actually slightly increases the file size.
+
+To disable this optimization and all others, use ``ocrmypdf --optimize 0 ...``
+or the shorthand ``-O0``.
+
+Lossless optimizations
+======================
+
+At optimization level ``-O1`` (the default), OCRmyPDF will also attempt lossless
+image optimization.
+
+If a JBIG2 encoder is available, then monochrome images will be converted to
+JBIG2, with the potential for huge savings on large black and white images,
+since JBIG2 is far more efficient than any other monochrome (bi-level)
+compression. (All known US patents related to JBIG2 have probably expired, but
+it remains the responsibility of the user to supply a JBIG2 encoder such as
+`jbig2enc `__. OCRmyPDF does not implement
+JBIG2 encoding on its own.)
+
+OCRmyPDF currently does not attempt to recompress losslessly compressed objects
+more aggressively.
+
+Lossy optimizations
+===================
+
+At optimization level ``-O2`` and ``-O3``, OCRmyPDF will some attempt lossy
+image optimization.
+
+If ``pngquant`` is installed, OCRmyPDF will use it to perform quantize paletted
+images to reduce their size.
+
+The quality of JPEGs may be lowered, on the assumption that a lower quality
+image may be suitable for storage after OCR.
+
+It is not possible to optimize all image types. Uncommon image types may be
+skipped by the optimizer.
+
+OCRmyPDF provides :ref:`lossy mode JBIG2 ` as an advanced feature
+that additional requires the argument ``--jbig2-lossy``.
diff --git a/docs/pdfsecurity.rst b/docs/pdfsecurity.rst
new file mode 100644
index 00000000..04ad4e90
--- /dev/null
+++ b/docs/pdfsecurity.rst
@@ -0,0 +1,161 @@
+===================
+PDF security issues
+===================
+
+ OCRmyPDF should only be used on PDFs you trust. It is not designed to
+ protect you against malware.
+
+Recognizing that many users have an interest in handling PDFs and
+applying OCR to PDFs they did not generate themselves, this article
+discusses the security implications of PDFs and how users can protect
+themselves.
+
+The disclaimer applies: this software has no warranties of any kind.
+
+PDFs may contain malware
+========================
+
+PDF is a rich, complex file format. The official PDF 1.7 specification,
+ISO 32000:2008, is hundreds of pages long and references several annexes
+each of which are similar in length. PDFs can contain video, audio, XML,
+JavaScript and other programming, and forms. In some cases, they can
+open internet connections to pre-selected URLs. All of these possible
+attack vectors.
+
+In short, PDFs `may contain
+viruses `__.
+
+This
+`article `__
+describes a high-paranoia method which allows potentially hostile PDFs
+to be viewed and rasterized safely in a disposable virtual machine. A
+trusted PDF created in this manner is converted to images and loses all
+information making it searchable and losing all compression. OCRmyPDF
+could be used restore searchability.
+
+How OCRmyPDF processes PDFs
+===========================
+
+OCRmyPDF must open and interpret your PDF in order to insert an OCR
+layer. First, it runs all PDFs through
+`pikepdf `__, a library based on
+`qpdf `__, a program that repairs PDFs
+with syntax errors. This is done because, in the author's experience, a
+significant number of PDFs in the wild especially those created by
+scanners are not well-formed files. qpdf makes it more likely that
+OCRmyPDF will succeed, but offers no security guarantees. qpdf is also
+used to split the PDF into single page PDFs.
+
+Finally, OCRmyPDF rasterizes each page of the PDF using
+`Ghostscript `__ in ``-dSAFER`` mode.
+
+Depending on the options specified, OCRmyPDF may graft the OCR layer
+into the existing PDF or it may essentially reconstruct ("re-fry") a
+visually identical PDF that may be quite different at the binary level.
+That said, OCRmyPDF is not a tool designed for sanitizing PDFs.
+
+.. _ocr-service:
+
+Using OCRmyPDF online or as a service
+=====================================
+
+OCRmyPDF is not designed for use as a public web service where a
+malicious user could upload a chosen PDF. In particular, it is not
+necessarily secure against PDF malware or PDFs that cause denial of
+service. OCRmyPDF relies on Ghostscript, and therefore, if deployed
+online one should be prepared to comply with Ghostscript's Affero GPL
+license, and any other licenses.
+
+Setting aside these concerns, a side effect of OCRmyPDF is it may
+incidentally sanitize PDFs that contain certain types of malware. It
+repairs the PDF with pikepdf/libqpdf, which could correct malformed PDF
+structures that are part of an attack. When PDF/A output is selected
+(the default), the input PDF is partially reconstructed by Ghostscript.
+When ``--force-ocr`` is used, all pages are rasterized and reconverted
+to PDF, which could remove malware in embedded images.
+
+OCRmyPDF should be relatively safe to use in a trusted intranet, with
+some considerations:
+
+Limiting CPU usage
+------------------
+
+OCRmyPDF will attempt to use all available CPUs and storage, so
+executing ``nice ocrmypdf`` or limiting the number of jobs with the
+``-j`` argument may ensure the server remains available. Another option
+would be run OCRmyPDF jobs inside a Docker container, a virtual machine,
+or a cloud instance, which can impose its own limits on CPU usage and be
+terminated "from orbit" if it fails to complete.
+
+Temporary storage requirements
+------------------------------
+
+OCRmyPDF will use a large amount of temporary storage for its work,
+proportional to the total number of pixels needed to rasterize the PDF.
+The raster image of a 8.5×11" color page at 300 DPI takes 25 MB
+uncompressed; OCRmyPDF saves its intermediates as PNG, but that still
+means it requires about 9 MB per intermediate based on average
+compression ratios. Multiple intermediates per page are also required,
+depending on the command line given. A rule of thumb would be to allow
+100 MB of temporary storage per page in a file – meaning that a small
+cloud servers or small VM partitions should be provisioned with plenty
+of extra space, if say, a 500 page file might be sent.
+
+To check temporary storage usage on actual files, run
+``ocrmypdf -k ...`` which will preserve and print the path to temporary
+storage when the job is done.
+
+To change where temporary files are stored, change the ``TMPDIR``
+environment variable for ocrmypdf's environment. (Python's
+``tempfile.gettempdir()`` returns the root directory in which temporary
+files will be stored.) For example, one could redirect ``TMPDIR`` to a
+large RAM disk to avoid wear on HDD/SSD and potentially improve
+performance. On Amazon Web Services, ``TMPDIR`` can be set to `empheral
+storage `__.
+
+Timeouts
+--------
+
+To prevent excessively long OCR jobs consider setting
+``--tesseract-timeout`` and/or ``--skip-big`` arguments. ``--skip-big``
+is particularly helpful if your PDFs include documents such as reports
+on standard page sizes with large images attached - often large images
+are not worth OCR'ing anyway.
+
+Commercial alternatives
+-----------------------
+
+The author also provides professional services that include OCR and
+building databases around PDFs, and is happy to provide consultation.
+
+Abbyy Cloud OCR is a viable commercial alternative with a web services
+API.
+
+Password protection, digital signatures and certification
+=========================================================
+
+Password protected PDFs usually have two passwords, and owner and user
+password. When the user password is set to empty, PDF readers will open
+the file automatically and marked it as "(SECURED)". While not as
+reliable as a digital signature, this indicates that whoever set the
+password approved of the file at that time. When the user password is
+set, the document cannot be viewed without the password.
+
+Either way, OCRmyPDF does not remove passwords from PDFs and exits with
+an error on encountering them.
+
+``qpdf`` can remove passwords. If the owner and user password are set, a
+password is required for ``qpdf``. If only the owner password is set, then the
+password can be stripped, even if one does not have the owner password.
+
+After OCR is applied, password protection is not permitted on PDF/A
+documents but the file can be converted to regular PDF.
+
+Many programs exist which are capable of inserting an image of someone's
+signature. On its own, this offers no security guarantees. It is trivial
+to remove the signature image and apply it to other files. This practice
+offers no real security.
+
+Important documents can be digitally signed and certified to attest to
+their authorship. OCRmyPDF cannot do this. Open source tools such as
+pdfbox (Java) have this capability as does Adobe Acrobat.
diff --git a/docs/performance.rst b/docs/performance.rst
new file mode 100644
index 00000000..82625fc0
--- /dev/null
+++ b/docs/performance.rst
@@ -0,0 +1,22 @@
+===========
+Performance
+===========
+
+Some users have noticed that current versions of OCRmyPDF do not run as quickly
+as some older versions (specifically 6.x and older). This is because OCRmyPDF
+added image optimization as a postprocessing step, and it is enabled by default.
+
+Speed
+=====
+
+If running OCRmyPDF quickly is your main goal, you can use settings such as:
+
+* ``--optimize 0`` to disable file size optimization
+* ``--output-type pdf`` to disable PDF/A generation
+* ``--fast-web-view 0`` to disable fast web view optimization
+* ``--skip-big`` to skip large images, if some pages have large images
+
+You can also avoid:
+
+* ``--force-ocr``
+* Image preprocessing
diff --git a/docs/plugins.rst b/docs/plugins.rst
new file mode 100644
index 00000000..952af3fd
--- /dev/null
+++ b/docs/plugins.rst
@@ -0,0 +1,200 @@
+=======
+Plugins
+=======
+
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
+ NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
+ "OPTIONAL" in this document are to be interpreted as described in
+ RFC 2119.
+
+You can use plugins to customize the behavior of OCRmyPDF at certain points of
+interest.
+
+Currently, it is possible to:
+
+- add new command line arguments
+- override the decision for whether or not to perform OCR on a particular file
+- modify the image is about to be sent for OCR
+- modify the page image before it is converted to PDF
+- replace the Tesseract OCR with another OCR engine that has similar behavior
+- replace Ghostscript with another PDF to image converter (rasterizer) or
+ PDF/A generator
+
+OCRmyPDF plugins are based on the Python ``pluggy`` package and conform to its
+conventions. Note that: plugins installed with as setuptools entrypoints are
+not checked currently, because OCRmyPDF assumes you may not want to enable
+plugins for all files.
+
+Script plugins
+==============
+
+Script plugins may be called from the command line, by specifying the name of a file.
+Script plugins may be convenient for informal or "one-off" plugins, when a certain
+batch of files needs a special processing step for example.
+
+.. code-block:: bash
+
+ ocrmypdf --plugin ocrmypdf_example_plugin.py input.pdf output.pdf
+
+Multiple plugins may be installed by issuing the ``--plugin`` argument multiple times.
+
+Packaged plugins
+================
+
+Installed plugins may be installed into the same virtual environment as OCRmyPDF
+is installed into. They may be invoked using Python standard module naming.
+If you are intending to distribute a plugin, please package it.
+
+.. code-block:: bash
+
+ ocrmypdf --plugin ocrmypdf_fancypants.pockets.contents input.pdf output.pdf
+
+OCRmyPDF does not automatically import plugins, because the assumption is that
+plugins affect different files differently and you may not want them activated
+all the time. The command line or ``ocrmypdf.ocr(plugin='...')`` must call
+for them.
+
+Third parties that wish to distribute packages for ocrmypdf should package them
+as packaged plugins, and these modules should begin with the name ``ocrmypdf_``
+similar to ``pytest`` packages such as ``pytest-cov`` (the package) and
+``pytest_cov`` (the module).
+
+.. note::
+
+ We strongly recommend plugin authors name their plugins with the prefix
+ ``ocrmypdf-`` (for the package name on PyPI) and ``ocrmypdf_`` (for the
+ module), just like pytest plugins.
+
+Setuptools plugins
+==================
+
+You can also create a plugin that OCRmyPDF will always automatically load if both are
+installed in the same virtual environment, using a setuptools entrypoint.
+
+Your package's ``setup.py`` would need to contain the following, for a plugin
+named ``ocrmypdf-exampleplugin``:
+
+.. code-block:: python
+
+ # sample ./setup.py file
+ from setuptools import setup
+
+ setup(
+ name="ocrmypdf-exampleplugin",
+ packages=["exampleplugin"],
+ # the following makes a plugin available to pytest
+ entry_points={"ocrmypdf": ["exampleplugin = exampleplugin.pluginmodule"]},
+ )
+
+Plugin requirements
+===================
+
+OCRmyPDF generally uses multiple worker processes. When a new worker is started,
+Python will import all plugins again, including all plugins that were imported earlier.
+This means that the global state of a plugin in one worker will not be shared with
+other workers. As such, plugin hook implementations should be stateless, relying
+only on their inputs. Hook implementations may use their input parameters to
+to obtain a reference to shared state prepared by another hook implementation.
+Plugins must expect that other instances of the plugin will be running
+simultaneously.
+
+The ``context`` object that is passed to many hooks can be used to share information
+about a file being worked on. Plugins must write private, plugin-specific data to
+a subfolder named ``{options.work_folder}/ocrmypdf-plugin-name``. Plugins MAY
+read and write files in ``options.work_folder``, but should be aware that their
+semantics are subject to change.
+
+OCRmyPDF will delete ``options.work_folder`` when it has finished OCRing
+a file, unless invoked with ``--keep-temporary-files``.
+
+The documentation for some plugin hooks contain a detailed description of the
+execution context in which they will be called.
+
+Plugins should be prepared to work whether executed in worker threads or worker
+processes. Generally, OCRmyPDF uses processes, but has a semi-hidden threaded
+argument that simplifies debugging.
+
+
+Plugin hooks
+============
+
+A plugin may provide the following hooks. Hooks must be decorated with
+``ocrmypdf.hookimpl``, for example:
+
+.. code-block:: python
+
+ from ocrmpydf import hookimpl
+
+ @hookimpl
+ def add_options(parser):
+ pass
+
+The following is a complete list of hooks that are available, and when
+they are called.
+
+.. _firstresult:
+
+**Note on firstresult hooks**
+
+If multiple plugins install implementations for this hook, they will be called in
+the reverse of the order in which they are installed (i.e., last plugin wins).
+When each hook implementation is called in order, the first implementation that
+returns a value other than ``None`` will "win" and prevent execution of all other
+hooks. As such, you cannot "chain" a series of plugin filters together in this
+way. Instead, a single hook implementation should be responsible for any such
+chaining operations.
+
+Custom command line arguments
+-----------------------------
+
+.. autofunction:: ocrmypdf.pluginspec.add_options
+
+.. autofunction:: ocrmypdf.pluginspec.check_options
+
+Execution and progress reporting
+--------------------------------
+
+.. autoclass: ocrmypdf.pluginspec.Executor
+ :members:
+
+.. autofunction:: ocrmypdf.pluginspec.get_logging_console
+
+.. autofunction:: ocrmypdf.pluginspec.get_executor
+
+.. autofunction:: ocrmypdf.pluginspec.get_progressbar_class
+
+Applying special behavior before processing
+-------------------------------------------
+
+.. autofunction:: ocrmypdf.pluginspec.validate
+
+PDF page to image
+-----------------
+
+.. autofunction:: ocrmypdf.pluginspec.rasterize_pdf_page
+
+Modifying intermediate images
+-----------------------------
+
+.. autofunction:: ocrmypdf.pluginspec.filter_ocr_image
+
+.. autofunction:: ocrmypdf.pluginspec.filter_page_image
+
+.. autofunction:: ocrmypdf.pluginspec.filter_pdf_page
+
+OCR engine
+----------
+
+.. autofunction:: ocrmypdf.pluginspec.get_ocr_engine
+
+.. autoclass:: ocrmypdf.pluginspec.OcrEngine
+ :members:
+
+ .. automethod:: __str__
+
+.. autoclass:: ocrmypdf.pluginspec.OrientationConfidence
+
+PDF/A production
+----------------
+
+.. autofunction:: ocrmypdf.pluginspec.generate_pdfa
diff --git a/docs/release_notes.rst b/docs/release_notes.rst
index 6af0f263..2d171340 100644
--- a/docs/release_notes.rst
+++ b/docs/release_notes.rst
@@ -1,207 +1,1017 @@
+=============
Release notes
=============
-OCRmyPDF uses `semantic versioning `_ for its command line interface and its public API.
+OCRmyPDF uses `semantic versioning `__ for its
+command line interface and its public API.
-The ``ocrmypdf`` package may now be imported. The public API may be useful in scripts that launch OCRmyPDF processes or that wish to use some of its features for working with PDFs.
+OCRmyPDF's output messages are not considered part of the stable interface -
+that is, output messages may be improved at any release level, so parsing them
+may be unreliable. Use the API to depend on precise behavior.
-Unfortunately, the public API does **not** expose the ability to actually OCR a PDF. This is due to a limitation in an underlying library (ruffus) that makes OCRmyPDF non-reentrant.
+The public API may be useful in scripts that launch OCRmyPDF processes or that
+wish to use some of its features for working with PDFs.
-Note that it is licensed under GPLv3, so scripts that ``import ocrmypdf`` and are released publicly should probably also be licensed under GPLv3.
-.. Issue regex
- find: [^`]\#([0-9]{1,3})[^0-9]
- replace: `#$1 `_
+v12.0.2
+=======
-v8.3.0
-------
+- Fix exception thrown when using ``--remove-background`` on files containing small
+ images (#769).
+- Improve documentation for description of adding language packs to the Docker image
+ and corrected name of French language pack.
-- Improved the strategy for updating pages when a new image of the page was produced. We know attempt to preserve more content from the original file, for annotations in particular.
+v12.0.1
+=======
-- For PDFs with more than 100 pages and a sequence where one PDF page was replaced and one or more subsequent ones were skipped, an intermediate file would be corrupted while grafting OCR text, causing processing to fail.
+- Fix "invalid version number" for untagged tesseract versions (#770).
-- Previously, we resized the images produced by Ghostscript by a small number of pixels to ensure the output image size was an exactly what we wanted. Having discovered a way to get Ghostscript to produce the exact image sizes we require, we eliminated the resizing step.
-
-- Command line completions for ``bash`` are now available, in addition to ``fish``, both in ``misc/completion``. Package maintainers, please install these so users can take advantage.
-
-- Updated requirements.
-
-- pikepdf 1.3.0 is now required.
-
-v8.2.4
-------
-
-- Fixed a false positive while checking for a certain type of PDF that only Acrobat can read. We now more accurately detect Acrobat-only PDFs.
-
-- OCRmyPDF holds fewer open file handles and is more prompt about releasing those it no longer needs.
-
-- Minor optimization: we no longer traverse the table of contents to ensure all references in it are resolved, as changes to libqpdf have made this unnecessary.
-
-- pikepdf 1.2.0 is now required.
-
-v8.2.3
-------
-
-- Fixed that ``--mask-barcodes`` would occasionally leave a unwanted temporary file named ``junkpixt`` in the current working folder.
-
-- Fixed (hopefully) handling of Leptonica errors in an environment where a non-standard ``sys.stderr`` is present.
-
-- Improved help text for ``--verbose``.
-
-v8.2.2
-------
-
-- Fixed a regression from v8.2.0, an exception that occurred while attempting to report that ``unpaper`` or another optional dependency was unavailable.
-
-- In some cases, ``ocrmypdf [-c|--clean]`` failed to exit with an error when ``unpaper`` is not installed.
-
-v8.2.1
-------
-
-- This release was canceled.
-
-v8.2.0
-------
-
-- A major improvement to our Docker image is now available thanks to hard work contributed by @mawi12345. The new Docker image, ocrmypdf-alpine, is based on Alpine Linux, and includes most of the functionality of three existed images in a smaller package. This image will replace the main Docker image eventually but for now all are being built. `See documentation for details `_.
-
-- Documentation reorganized especially around the use of Docker images.
-
-- Fixed a problem with PDF image optimization, where the optimizer would unnecessarily decompress and recompress PNG images, in some cases losing the benefits of the quantization it just had just performed. The optimizer is now capable of embedding PNG images into PDFs without transcoding them.
-
-- Fixed a minor regression with lossy JBIG2 image optimization. All JBIG2 candidates images were incorrectly placed into a single optimization group for the whole file, instead of grouping pages together. This usually makes a larger JBIG2Globals dictionary and results in inferior compression, so it worked less well than designed. However, quality would not be impacted. Lossless JBIG2 was entirely unaffected.
-
-- Updated dependencies, including pikepdf to 1.1.0. This fixes `#358 `_.
-
-- The install-time version checks for certain external programs have been removed from setup.py. These tests are now performed at run-time.
-
-- The non-standard option to override install-time checks (``setup.py install --force``) is now deprecated and prints a warning. It will be removed in a future release.
-
-v8.1.0
-------
-
-- Added a feature, ``--unpaper-args``, which allows passing arbitrary arguments to ``unpaper`` when using ``--clean`` or ``--clean-final``. The default, very conservative unpaper settings are suppressed.
-
-- The argument ``--clean-final`` now implies ``--clean``. It was possible to issue ``--clean-final`` on its before this, but it would have no useful effect.
-
-- Fixed an exception on traversing corrupt table of contents entries (specifically, those with invalid destination objects)
-
-- Fixed an issue when using ``--tesseract-timeout`` and image processing features on a file with more than 100 pages. `#347 `_
-
-- OCRmyPDF now always calls ``os.nice(5)`` to signal to operating systems that it is a background process.
-
-v8.0.1
-------
-
-- Fixed an exception when parsing PDFs that are missing a required field. `#325 `_
-
-- pikepdf 1.0.5 is now required, to address some other PDF parsing issues.
-
-v8.0.0
-------
-
-No major features. The intent of this release is to sever support for older versions of certain dependencies.
+v12.0.0
+=======
**Breaking changes**
-- Dropped support for Tesseract 3.x. Tesseract 4.0 or newer is now required.
+- Due to recent security issues in pikepdf, Pillow and reportlab, we now require
+ newer versions of these libraries and some of their dependencies. (If necessary,
+ package maintainers may override these versions at their discretion; lower
+ versions will often work.)
+- We now use the "LeaveColorUnchanged" color conversion strategy when directing
+ Ghostscript to create a PDF/A. Generally this is faster than performing a
+ color conversion, which is not always necessary.
+- OCR text is now packaged in a Form XObject. This makes it easier to isolate
+ OCR from other document content. However, some poorly implemented PDF text
+ extraction algorithms may fail to detect the text.
+- Many API functions have stricter parameter checking or expect keyword arguments
+ were they previously did not.
+- Some deprecated functions in ``ocrmypdf.optimize`` were removed.
+- The ``ocrmypdf.leptonica`` module is now deprecated, due to difficulties with
+ the current strategy of ABI binding on newer platforms like Apple Silicon.
+ It will be removed and replaced, either by repackaging Leptonica as an
+ independent library using or using a different image processing library.
+- Continuous integration moved to GitHub Actions.
+- We no longer depend on ``pytest_helpers_namespace`` for testing.
-- Dropped support for Python 3.5.
+**New features**
-- Some ``ocrmypdf.pdfa`` APIs that were deprecated in v7.x were removed. This functionality has been moved to pikepdf.
+- New plugin hook: ``get_progressbar_class``, for progress reporting,
+ allowing developers to replace the standard console progress bar with some
+ other mechanism, such as updating a GUI progress bar.
+- New plugin hook: ``get_executor``, for replacing the concurrency model.
+ This is primarily to support execution on AWS Lambda, which does not support
+ standard Python ``multiprocessing`` due to its lack of shared memory.
+- New plugin hook: ``get_logging_console``, for replacing the standard
+ way OCRmyPDF outputs its messages.
+- New plugin hook: ``filter_pdf_page``, for modifying individual PDF
+ pages produced by OCRmyPDF.
+- OCRmyPDF now runs on nonstandard execution environments that do not have
+ interprocess semaphores, such as AWS Lambda and Android Termux. If the environment
+ does not have semaphores, OCRmyPDF will automatically select an alternate
+ process executor that does not use semaphores.
+- Continuous integration moved to GitHub Actions.
+- We now generate an ARM64-compatible Docker image alongside the x64 image.
+ Thanks to @andkrause for doing most of the work in a pull request several months
+ ago, which we were finally able to integrate now. Also thanks to @0x326 for
+ review comments.
+
+**Fixes**
+
+- Fixed a possible deadlock on attempting to flush ``sys.stderr`` when older
+ versions of Leptonica are in use.
+- Some worker processes inherited resources from their parents such as log
+ handlers that may have also lead to deadlocks. These resources are now released.
+- Improvements to test coverage.
+- Removed vestiges of support for Tesseract versions older than 4.0.0-beta1 (
+ which ships with Ubuntu 18.04).
+- OCRmyPDF can now parse all of Tesseract version numbers, since several
+ schemes have been in use.
+- Fixed an issue with parsing PDFs that contain images drawn at a scale of 0. (#761)
+- Removed a frequently repeated message about disabling mmap.
+
+v11.7.3
+=======
+
+- Exclude CCITT Group 3 images from being optimized. Some libraries
+ OCRmyPDF uses do not seem to handle this obscure compression format properly.
+ You may get errors or possible corrupted output images without this fix.
+
+v11.7.2
+=======
+
+- Updated pinned versions in main.txt, primarily to upgrade Pillow to 8.1.2, due
+ to recently disclosed security vulnerabilities in that software.
+- The ``--sidecar`` parameter now causes an exception if set to the same file as
+ the input or output PDF.
+
+v11.7.1
+=======
+
+- Some exceptions while attempting image optimization were only logged at the debug
+ level, causing them to be suppressed. These errors are now logged appropriately.
+- Improved the error message related to ``--unpaper-args``.
+- Updated documentation to mention the new conda distribution.
+
+v11.7.0
+=======
+
+- We now support using ``--sidecar`` in conjunction with ``--pages``; these arguments
+ used to be mutually exclusive. (#735)
+- Fixed a possible issue with PDF/A-1b generation. Acrobat complained that our PDFs use
+ object streams. More robust PDF/A validators like veraPDF don't consider this a
+ problem, but we'll honor Acrobat's objection from here on. This may increase file
+ size of PDF/A-1b files. PDF/A-2b files will not be affected.
+
+v11.6.2
+=======
+
+- Fixed a regression where the wrong page orientation would be produced when using
+ arguments such as ``--deskew --rotate-pages`` (#730).
+
+v11.6.1
+=======
+
+- Fixed an issue with attempting optimize unusually narrow-width images by excluding
+ these images from optimization (#732).
+- Remove an obsolete compatibility shim for a version of pikepdf that is no longer
+ supported.
+
+v11.6.0
+=======
+
+- OCRmyPDF will now automatically register plugins from the same virtual environment
+ with an appropriate setuptools entrypoint.
+- Refactor the plugin manager to remove unnecessary complications and make plugin
+ registration more automatic.
+- ``PageContext`` and ``PdfContext`` are now formally part of the API, as they
+ should have been, since they were part of ``ocrmypdf.pluginspec``.
+
+v11.5.0
+=======
+
+- Fixed an issue where the output page size might differ by a fractional amount
+ due to rounding, when ``--force-ocr`` was used and the page contained objects
+ with multiple resolutions.
+- When determining the resolution at which to rasterize a page, we now consider
+ printed text on the page as requiring a higher resolution. This fixes issues
+ with certain pages being rendered with unacceptably low resolution text, but
+ may increase output file sizes in some workflows where low resolution text
+ is acceptable.
+- Added a workaround to fix an exception that occurs when trying to
+ ``import ocrmypdf.leptonica`` on Apple ARM silicon (or potentially, other
+ platforms that do not permit write+executable memory).
+
+v11.4.5
+=======
+
+- Fixed an issue where files may not be closed when the API is used.
+- Improved ``setup.cfg`` with better settings for test coverage.
+
+v11.4.4
+=======
+
+- Fixed ``AttributeError: 'NoneType' object has no attribute 'userunit'``, issue #700,
+ related to OCRmyPDF not properly forwarded an error message from pdfminer.six.
+- Adjusted typing of some arguments.
+- ``ocrmypdf.ocr`` now takes a ``threading.Lock`` for reasons outlined in the
+ documentation.
+
+v11.4.3
+=======
+
+- Removed a redundant debug message.
+- Test suite now asserts that most patched functions are called when they should be.
+- Test suite now skips a test that fails on two particular versions of piekpdf.
+
+v11.4.2
+=======
+
+- Fixed support for Cygwin, hopefully.
+- watcher.py: Fixed an issue with the OCR_LOGLEVEL not being interpreted.
+
+v11.4.1
+=======
+
+- Fixed an issue where invalid pages ranges passed using the ``pages`` argument,
+ such as "1-0" would cause unhandled exceptions.
+- Accepted a user-contributed to the Synology demo script in misc/synology.py.
+- Clarified documentation about change of temporary file location ``ocrmypdf.io``.
+- Fixed Python wheel tag which was incorrectly set to py35 even though we long
+ since dropped support for Python 3.5.
+
+v11.4.0
+=======
+
+- When looking for Tesseract and Ghostscript, we now check the Windows Registry to
+ see if their installers registered the location of their executables. This should
+ help Windows users who have installed these programs to non-standard
+ locations.
+- We now report on the progress of PDF/A conversion, since this operation is
+ sometimes slow.
+- Improved command line completions.
+- The prefix of the temporary folder OCRmyPDF creates has been changed from
+ ``com.github.ocrmypdf`` to ``ocrmypdf.io``. Scripts that chose to depend on this
+ prefix may need to be adjusted. (This has always been an implementation detail so is
+ not considered part of the semantic versioning "contract".)
+- Fixed issue #692, where a particular file with malformed fonts would flood an
+ internal message cue by generating so many debug messages.
+- Fixed an exception on processing hOCR files with no page record. Tesseract
+ is not known to generate such files.
+
+v11.3.4
+=======
+
+- Fixed an error message 'called readLinearizationData for file that is not
+ linearized' that may occur when pikepdf 2.1.0 is used. (Upgrading to pikepdf
+ 2.1.1 also fixes the issue.)
+- File watcher now automatically includes ``.PDF`` in addition to ``.pdf`` to
+ better support case sensitive file systems.
+- Some documentation and comment improvements.
+
+v11.3.3
+=======
+
+- If unpaper outputs non-UTF-8 data, quietly fix this rather than choke on the
+ conversion. (Possibly addresses #671.)
+
+v11.3.2
+=======
+
+- Explicitly require pikepdf 2.0.0 or newer when running on Python 3.9. (There are
+ concerns about the stability of pybind11 2.5.x with Python 3.9, which is used in
+ pikepdf 1.x.)
+- Fixed another issue related to page rotation.
+- Fixed an issue where image marked as image masks were not properly considered
+ as optimization candidates.
+- On some systems, unpaper seems to be unable to process the PNGs we offer it
+ as input. We now convert the input to PNM format, which unpaper always accepts.
+ Fixes #665 and #667.
+- DPI sent to unpaper is now rounded to a more reasonable number of decimal digits.
+- Debug and error messages from unpaper were being suppressed.
+- Some documentation tweaks.
+
+v11.3.1
+=======
+
+- Declare support for new versions: pdfminer.six 20201018 and pikepdf 2.x
+- Fix warning related to ``--pdfa-image-compression`` that appears at the wrong
+ time.
+
+v11.3.0
+=======
+
+- The "OCR" step is describing as "Image processing" in the output messages when
+ OCR is disabled, to better explain the application's behavior.
+- Debug logs are now only created when run as a command line, and not when OCR
+ is performed for an API call. It is the calling application's responsibility
+ to set up logging.
+- For PDFs with a low number of pages, we gathered information about the input PDF
+ in a thread rather than process (when there are more pages). When run as a
+ thread, we did not close the file handle to the working PDF, leaking one file
+ handle per call of ``ocrmypdf.ocr``.
+- Fixed an issue where debug messages send by child worker processes did not match
+ the log settings of parent process, causing messages to be dropped. This affected
+ macOS and Windows only where the parent process is not forked.
+- Fixed the hookspec of rasterize_pdf_page to remove default parameters that
+ were not handled in an expected way by pluggy.
+- Fixed another issue with automatic page rotation (#658) due to the issue above.
+
+v11.2.1
+=======
+
+- Fixed an issue where optimization of a 1-bit image with a color palette or
+ associated ICC that was optimized to JBIG2 could have its colors inverted.
+
+v11.2.0
+=======
+
+- Fixed an issue with optimizing PNG-type images that had soft masks or image masks.
+ This is a regression introduced in (or about) v11.1.0.
+- Improved type checking of the ``plugins`` parameter for the ``ocrmypdf.ocr``
+ API call.
+
+v11.1.2
+=======
+
+- Fixed hOCR renderer writing the text in roughly reverse order. This should not
+ affect reasonably smart PDF readers that properly locate the position of all
+ text, but may confuse those that rely on the order of objects in the content
+ stream. (#642)
+
+v11.1.1
+=======
+
+- We now avoid using named temporary files when using pngquant allowing containerized
+ pngquant installs to be used.
+- Clarified an error message.
+- Highest number of 1's in a release ever!
+
+v11.1.0
+=======
+
+- Fixed page rotation issues: #634, #589.
+- Fixed some cases where optimization created an invalid image such as a
+ 1-bit "RGB" image: #629, #620.
+- Page numbers are now displayed in debug logs when pages are being grafted.
+- ocrmypdf.optimize.rewrite_png and ocrmypdf.optimize.rewrite_png_as_g4 were
+ marked deprecated. Strictly speaking these should have been internal APIs,
+ but they were never hidden.
+- As a precaution, pikepdf mmap-based file access has been disabled due to a
+ rare race condition that causes a crash when certain objects are deallocated.
+ The problem is likely in pikepdf's dependency pybind11.
+- Extended the example plugin to demonstrate conversion to mono.
+
+v11.0.2
+=======
+
+- Fixed issue #612, TypeError exception. Fixed by eliminating unnecessary repair of
+ input PDF metadata in memory.
+
+v11.0.1
+=======
+
+- Blacklist pdfminer.six 20200720, which has a regression fixed in 20200726.
+- Approve img2pdf 0.4 as it passes tests.
+- Clarify that the GPL-3 portion of pdfa.py was removed with the changes in v11.0.0;
+ the debian/copyright file did not properly annotate this change.
+
+v11.0.0
+=======
+
+- Project license changed to Mozilla Public License 2.0. Some miscellaneous
+ code is now under MIT license and non-code content/media remains under
+ CC-BY-SA 4.0. License changed with approval of all people who were found
+ to have contributed to GPLv3 licensed sections of the project. (#600)
+- Because the license changed, this is being treated as a major version number
+ change; however, there are no known breaking changes in functional behavior
+ or API compared to v10.x.
+
+v10.3.3
+=======
+
+- Fixed a "KeyError: 'dpi'" error message when using ``--threshold`` on an image.
+ (#607)
+
+v10.3.2
+=======
+
+- Fixed a case where we reported "no reason" for a file size increase, when we
+ could determine the reason.
+- Enabled support for pdfminer.six 20200726.
+
+v10.3.1
+=======
+
+- Fixed a number of test suite failures with pdfminer.six older than veresion 20200402.
+- Enabled support for pdfminer.six 20200720.
+
+v10.3.0
+=======
+
+- Fixed an issue where we would consider images that were already JBIG2-encoded
+ for optimization, potentially producing a less optimized image than the original.
+ We do not believe this issue would ever cause an image to loss fidelity.
+- Where available, pikepdf memory mapping is now used. This improves performance.
+- When Leptonica 1.79+ is installed, use its new error handling API to avoid
+ a "messy" redirection of stderr which was necessary to capture its error
+ messages.
+- For older versions of Leptonica, added a new thread level lock. This fixes a
+ possible race condition in handling error conditions in Leptonica (although
+ there is no evidence it ever caused issues in practice).
+- Documentation improvements and more type hinting.
+
+v10.2.1
+=======
+
+- Disabled calculation of text box order with pdfminer. We never needed this result
+ and it is expensive to calculate on files with complex pre-existing text.
+- Fixed plugin manager to accept ``Path(plugin)`` as a path to a plugin.
+- Fixed some typing errors.
+- Documentation improvements.
+
+v10.2.0
+=======
+
+- Update Docker image to use Ubuntu 20.04.
+- Fixed issue PDF/A acquires title "Untitled" after conversion. (#582)
+- Fixed a problem where, when using ``--pdf-renderer hocr``, some text would
+ be missing from the output when using a more recent version of Tesseract.
+ Tesseract began adding more detailed markup about the semantics of text
+ that our HOCR transform did not recognize, so it ignored them. This option is
+ not the default. If necessary ``--redo-ocr`` also redoing OCR to fix such issues.
+- Fixed an error in Python 3.9 beta, due to removal of deprecated
+ ``Element.getchildren()``. (#584)
+- Implemented support using the API with ``BytesIO`` and other file stream objects.
+ (#545)
+
+v10.1.1
+=======
+
+- Fixed ``OMP_THREAD_LIMIT`` set to invalid value error messages on some input
+ files. (The error was harmless, apart from less than optimal performance in
+ some cases.)
+
+v10.1.0
+=======
+
+- Previously, we ``--clean-final`` would cause an unpaper-cleaned page image to
+ be produced twice, which was necessary in some cases but not in general. We
+ now take this optimization opportunity and reuse the image if possible.
+- We now provide PNG files as input to unpaper, since it accepts them, instead
+ of generating PPM files which can be very large. This can improve performance
+ and temporary disk usage.
+- Documentation updated for plugins.
+
+v10.0.1
+=======
+
+- Fixed regression when ``-l lang1+lang2`` is used from command line.
+
+v10.0.0
+=======
+
+**Breaking changes**
+
+- Support for pdfminer.six version 20181108 has been dropped, along with a
+ monkeypatch that made this version work.
+- Output messages are now displayed in color (when supported by the terminal)
+ and prefixes describing the severity of the message are removed. As such
+ programs that parse OCRmyPDF's log message will need to be revised. (Please
+ consider using OCRmyPDF as a library instead.)
+- The minimum version for certain dependencies has increased.
+- Many API changes; see developer changes.
+- The Python libraries pluggy and coloredlogs are now required.
+
+**New features and improvements**
+
+- PDF page scanning is now parallelized across CPUs, speeding up this phase
+ dramatically for files with a high page counts.
+- PDF page scanning is optimized, addressing some performance regressions.
+- PDF page scanning is no longer run on pages that are not selected when the
+ ``--pages`` argument is used.
+- PDF page scanning is now independent of Ghostscript, ending our past reliance
+ on this occasionally unstable feature in Ghostscript.
+- A plugin architecture has been added, currently allowing one to more easily
+ use a different OCR engine or PDF renderer from Tesseract and Ghostscript,
+ respectively. A plugin can also override some decisions, such changing
+ the OCR settings after initial scanning.
+- Colored log messages.
+
+**Developer changes**
+
+- The test spoofing mechanism, used to test correct handling of failures in
+ Tesseract and Ghostscript, has been removed in favor of using plugins for
+ testing. The spoofing mechanism was fairly complex and required many special
+ hacks for Windows.
+- Code describing the resolution in DPI of images was refactored into a
+ ``ocrmypdf.helpers.Resolution`` class.
+- The module ``ocrmypdf._exec`` is now private to OCRmyPDF.
+- The ``ocrmypdf.hocrtransform`` module has been updated to follow PEP8 naming
+ conventions.
+- Ghostscript is no longer used for finding the location of text in PDFs, and
+ APIs related to this feature have been removed.
+- Lots of internal reorganization to support plugins.
+
+v9.8.2
+======
+
+- Fixed an issue where OCRmyPDF would ignore text inside Form XObject when
+ making certain decisions about whether a document already had text.
+- Fixed file size increase warning to take overhead of small files into account.
+- Added instructions for installing on Cygwin.
+
+v9.8.1
+======
+
+- Fixed an issue where unexpected files in the ``%PROGRAMFILES%\gs`` directory
+ (Windows) caused an exception.
+- Mark pdfminer.six 20200517 as supported.
+- If jbig2enc is missing and optimization is requested, a warning is issued
+ instead of an error, which was the intended behavior.
+- Documentation updates.
+
+v9.8.0
+======
+
+- Fixed issue where only the first PNG (FlateDecode) image in a file would be
+ considered for optimization. File sizes should be improved from here on.
+- Fixed a startup crash when the chosen language was Japanese (#543).
+- Added options to configure polling and log level to watcher.py.
+
+v9.7.2
+======
+
+- Fixed an issue with ``ocrmypdf.ocr(...language=)`` not accepting a list of
+ languages as documented.
+- Updated setup.py to confirm that pdfminer.six version 20200402 is supported.
+
+v9.7.1
+======
+
+- Fixed version check failing when used with qpdf 10.0.0.
+- Added some missing type annotations.
+- Updated documentation to warn about need for "ifmain" guard and Windows.
+
+v9.7.0
+======
+
+- Fixed an error in watcher.py if ``OCR_JSON_SETTINGS`` was not defined.
+- Ghostscript 9.51 is now blacklisted, due to numerous problems with this version.
+- Added a workaround for a problem with "txtwrite" in Ghostscript 9.52.
+- Fixed an issue where the incorrect number of threads used was shown when
+ ``OMP_THREAD_LIMIT`` was manipulated.
+- Removed a possible performance bottlenecks for files that use hundreds to
+ thousands of images on the same page.
+- Documentation improvements.
+- Optimization will now be applied to some monochrome images that have a color
+ profile defined instead of only black and white.
+- ICC profiles are consulted when determining the simplified colorspace of an
+ image.
+
+v9.6.1
+======
+
+- Documentation improvements - thanks to many users for their contributions!
+
+ - Fixed installation instructions for ArchLinux (@pigmonkey)
+ - Updated installation instructions for FreeBSD and other OSes (@knobix)
+ - Added instructions for using Docker Compose with watchdog (@ianalexander,
+ @deisi)
+ - Other miscellany (@mb720, @toy, @caiofacchinato)
+ - Some scripts provided in the documentation have been migrated out so that
+ they can be copied out as whole files, and to ensure syntax checking
+ is maintained.
+
+- Fixed an error that caused bash completions to fail on macOS. (#502, #504;
+ @AlexanderWillner)
+- Fixed a rare case where OCRmyPDF threw an exception while processing a PDF
+ with the wrong object type in its ``/Trailer /Info``. The error is now logged
+ and incorrect object is ignored. (#497)
+- Removed potentially non-free file ``enron1.pdf`` and simplified the test that
+ used it.
+- Removed potentially non-free file ``misc/media/logo.afdesign``.
+
+v9.6.0
+======
+
+- Fixed a regression with transferring metadata from the input PDF to the output
+ PDF in certain situations.
+- pdfminer.six is now supported up to version 2020-01-24.
+- Messages are explaining page rotation decisions are now shown at the standard
+ verbosity level again when ``--rotate-pages``. In some previous version they
+ were set to debug level messages that only appeared with the parameter ``-v1``.
+- Improvements to ``misc/watcher.py``. Thanks to @ianalexander and @svenihoney.
+- Documentation improvements.
+
+v9.5.0
+======
+
+- Added API functions to measure OCR quality.
+- Modest improvements to handling PDFs with difficult/non compliant metadata.
+
+v9.4.0
+======
+
+- Updated recommended dependency versions.
+- Improvements to test coverage and changes to facilitate better measurement of
+ test coverage, such as when tests run in subprocesses.
+- Improvements to error messages when Leptonica is not installed correctly.
+- Fixed use of pytest "session scope" that may have caused some intermittent
+ CI failures.
+- When the argument ``--keep-temporary-files`` or verbosity is set to ``-v1``,
+ a debug log file is generated in the working temporary folder.
+
+v9.3.0
+======
+
+- Improved native Windows support: we now check in the obvious places in
+ the "Program Files" folders installations of Tesseract and Ghostscript,
+ rather than relying on the user to edit ``PATH`` to specify their location.
+ The ``PATH`` environment variable can still be used to differentiate when
+ multiple installations are present or the programs are installed to non-
+ standard locations.
+- Fixed an exception on parsing Ghostscript error messages.
+- Added an improved example demonstrating how to set up a watched folder
+ for automated OCR processing (thanks to @ianalexander for the contribution).
+
+v9.2.0
+======
+
+- Native Windows is now supported.
+- Continuous integration moved to Azure Pipelines.
+- Improved test coverage and speed of tests.
+- Fixed an issue where a page that was originally a JPEG would be saved as a
+ PNG, increasing file size. This occurred only when a preprocessing option
+ was selected along with ``--output-type=pdf`` and all images on the original
+ page were JPEGs. Regression since v7.0.0.
+- OCRmyPDF no longer depends on the QPDF executable ``qpdf`` or ``libqpdf``.
+ It uses pikepdf (which in turn depends on ``libqpdf``). Package maintainers
+ should adjust dependencies so that OCRmyPDF no longer calls for libqpdf on
+ its own. For users of Python binary wheels, this change means a separate
+ installation of QPDF is no longer necessary. This change is mainly to
+ simplify installation on Windows.
+- Fixed a rare case where log messages from Tesseract would be discarded.
+- Fixed incorrect function signature for pixFindPageForeground, causing
+ exceptions on certain platforms/Leptonica versions.
+
+v9.1.1
+======
+
+- Expand the range of pdfminer.six versions that are supported.
+- Fixed Docker build when using pikepdf 1.7.0.
+- Fixed documentation to recommend using pip from get-pip.py.
+
+v9.1.0
+======
+
+- Improved diagnostics when file size increases at output. Now warns if JBIG2
+ or pngquant were not available.
+- pikepdf 1.7.0 is now required, to pick up changes that remove the need for
+ a source install on Linux systems running Python 3.8.
+
+v9.0.5
+======
+
+- The Alpine Docker image (jbarlow83/ocrmypdf-alpine) has been dropped due to
+ the difficulties of supporting Alpine Linux.
+- The primary Docker image (jbarlow83/ocrmypdf) has been improved to take on
+ the extra features that used to be exclusive to the Alpine image.
+- No changes to application code.
+- pdfminer.six version 20191020 is now supported.
+
+v9.0.4
+======
+
+- Fixed compatibility with Python 3.8 (but requires source install for the moment).
+- Fixed Tesseract settings for ``--user-words`` and ``--user-patterns``.
+- Changed to pikepdf 1.6.5 (for Python 3.8).
+- Changed to Pillow 6.2.0 (to mitigate a security vulnerability in earlier Pillow).
+- A debug message now mentions when English is automatically selected if the locale
+ is not English.
+
+v9.0.3
+======
+
+- Embed an encoded version of the sRGB ICC profile in the intermediate
+ Postscript file (used for PDF/A conversion). Previously we included the
+ filename, which required Postscript to run with file access enabled. For
+ security, Ghostscript 9.28 enables ``-dSAFER`` and as such, no longer
+ permits access to any file by default. This fix is necessary for
+ compatibility with Ghostscript 9.28.
+- Exclude a test that sometimes times out and fails in continuous integration
+ from the standard test suite.
+
+v9.0.2
+======
+
+- The image optimizer now skips optimizing flate (PNG) encoded images in some
+ situations where the optimization effort was likely wasted.
+- The image optimizer now ignores images that specify arbitrary decode arrays,
+ since these are rare.
+- Fixed an issue that caused inversion of black and white in monochrome images.
+ We are not certain but the problem seems to be linked to Leptonica 1.76.0 and
+ older.
+- Fixed some cases where the test suite failed if
+ English or German Tesseract language packs were not installed.
+- Fixed a runtime error if the Tesseract English language is not installed.
+- Improved explicit closing of Pillow images after use.
+- Actually fixed of Alpine Docker image build.
+- Changed to pikepdf 1.6.3.
+
+v9.0.1
+======
+
+- Fixed test suite failing when either of optional dependencies unpaper and
+ pngquant were missing.
+- Attempted fix of Alpine Docker image build.
+- Documented that FreeBSD ports are now available.
+- Changed to pikepdf 1.6.1.
+
+v9.0.0
+======
+
+**Breaking changes**
+
+- The ``--mask-barcodes`` experimental feature has been dropped due to poor
+ reliability and occasional crashes, both due to the underlying library that
+ implements this feature (Leptonica).
+- The ``-v`` (verbosity level) parameter now accepts only ``0``, ``1``, and
+ ``2``.
+- Dropped support for Tesseract 4.00.00-alpha releases. Tesseract 4.0 beta and
+ later remain supported.
+- Dropped the ``ocrmypdf-polyglot`` and ``ocrmypdf-webservice`` images.
+
+**New features**
+
+- Added a high level API for applications that want to integrate OCRmyPDF.
+ Special thanks to Martin Wind (@mawi1988) whose made significant contributions
+ to this effort.
+- Added progress bars for long-running steps. ■■■■■■■□□
+- We now create linearized ("fast web view") PDFs by default. The new parameter
+ ``--fast-web-view`` provides control over when this feature is applied.
+- Added a new ``--pages`` feature to limit OCR to only a specific page range.
+ The list may contain commas or single pages, such as ``1, 3, 5-11``.
+- When the number of pages is small compared to the number of allowed jobs, we
+ run Tesseract in multithreaded (OpenMP) mode when available. This should
+ improve performance on files with low page counts.
+- Removed dependency on ``ruffus``, and with that, the non-reentrancy
+ restrictions that previous made an API impossible.
+- Output and logging messages overhauled so that ocrmypdf may be integrated
+ into applications that use the logging module.
+- pikepdf 1.6.0 is required.
+- Added a logo. 😊
+
+**Bug fixes**
+
+- Pages with vector artwork are treated as full color. Previously, vectors
+ were ignored when considering the colorspace needed to cover a page, which
+ could cause loss of color under certain settings.
+- Test suite now spawns processes less frequently, allowing more accurate
+ measurement of code coverage.
+- Improved test coverage.
+- Fixed a rare division by zero (if optimization produced an invalid file).
+- Updated Docker images to use newer versions.
+- Fixed images encoded as JBIG2 with a colorspace other than ``/DeviceGray``
+ were not interpreted correctly.
+- Fixed a OCR text-image registration (i.e. alignment) problem when the page
+ when MediaBox had a nonzero corner.
+
+v8.3.2
+======
+
+- Dropped workaround for macOS that allowed it work without pdfminer.six,
+ now a proper sdist release of pdfminer.six is available.
+
+- pikepdf 1.5.0 is now required.
+
+v8.3.1
+======
+
+- Fixed an issue where PDFs with malformed metadata would be rendered as
+ blank pages. `#398 `_.
+
+v8.3.0
+======
+
+- Improved the strategy for updating pages when a new image of the page
+ was produced. We now attempt to preserve more content from the
+ original file, for annotations in particular.
+- For PDFs with more than 100 pages and a sequence where one PDF page
+ was replaced and one or more subsequent ones were skipped, an
+ intermediate file would be corrupted while grafting OCR text, causing
+ processing to fail. This is a regression, likely introduced in
+ v8.2.4.
+- Previously, we resized the images produced by Ghostscript by a small
+ number of pixels to ensure the output image size was an exactly what
+ we wanted. Having discovered a way to get Ghostscript to produce the
+ exact image sizes we require, we eliminated the resizing step.
+- Command line completions for ``bash`` are now available, in addition
+ to ``fish``, both in ``misc/completion``. Package maintainers, please
+ install these so users can take advantage.
+- Updated requirements.
+- pikepdf 1.3.0 is now required.
+
+v8.2.4
+======
+
+- Fixed a false positive while checking for a certain type of PDF that
+ only Acrobat can read. We now more accurately detect Acrobat-only
+ PDFs.
+- OCRmyPDF holds fewer open file handles and is more prompt about
+ releasing those it no longer needs.
+- Minor optimization: we no longer traverse the table of contents to
+ ensure all references in it are resolved, as changes to libqpdf have
+ made this unnecessary.
+- pikepdf 1.2.0 is now required.
+
+v8.2.3
+======
+
+- Fixed that ``--mask-barcodes`` would occasionally leave a unwanted
+ temporary file named ``junkpixt`` in the current working folder.
+- Fixed (hopefully) handling of Leptonica errors in an environment
+ where a non-standard ``sys.stderr`` is present.
+- Improved help text for ``--verbose``.
+
+v8.2.2
+======
+
+- Fixed a regression from v8.2.0, an exception that occurred while
+ attempting to report that ``unpaper`` or another optional dependency
+ was unavailable.
+- In some cases, ``ocrmypdf [-c|--clean]`` failed to exit with an error
+ when ``unpaper`` is not installed.
+
+v8.2.1
+======
+
+- This release was canceled.
+
+v8.2.0
+======
+
+- A major improvement to our Docker image is now available thanks to
+ hard work contributed by @mawi12345. The new Docker image,
+ ocrmypdf-alpine, is based on Alpine Linux, and includes most of the
+ functionality of three existed images in a smaller package. This
+ image will replace the main Docker image eventually but for now all
+ are being built. `See documentation for
+ details `__.
+- Documentation reorganized especially around the use of Docker images.
+- Fixed a problem with PDF image optimization, where the optimizer
+ would unnecessarily decompress and recompress PNG images, in some
+ cases losing the benefits of the quantization it just had just
+ performed. The optimizer is now capable of embedding PNG images into
+ PDFs without transcoding them.
+- Fixed a minor regression with lossy JBIG2 image optimization. All
+ JBIG2 candidates images were incorrectly placed into a single
+ optimization group for the whole file, instead of grouping pages
+ together. This usually makes a larger JBIG2Globals dictionary and
+ results in inferior compression, so it worked less well than
+ designed. However, quality would not be impacted. Lossless JBIG2 was
+ entirely unaffected.
+- Updated dependencies, including pikepdf to 1.1.0. This fixes
+ `#358 `__.
+- The install-time version checks for certain external programs have
+ been removed from setup.py. These tests are now performed at
+ run-time.
+- The non-standard option to override install-time checks
+ (``setup.py install --force``) is now deprecated and prints a
+ warning. It will be removed in a future release.
+
+v8.1.0
+======
+
+- Added a feature, ``--unpaper-args``, which allows passing arbitrary
+ arguments to ``unpaper`` when using ``--clean`` or ``--clean-final``.
+ The default, very conservative unpaper settings are suppressed.
+- The argument ``--clean-final`` now implies ``--clean``. It was
+ possible to issue ``--clean-final`` on its before this, but it would
+ have no useful effect.
+- Fixed an exception on traversing corrupt table of contents entries
+ (specifically, those with invalid destination objects)
+- Fixed an issue when using ``--tesseract-timeout`` and image
+ processing features on a file with more than 100 pages.
+ `#347 `__
+- OCRmyPDF now always calls ``os.nice(5)`` to signal to operating
+ systems that it is a background process.
+
+v8.0.1
+======
+
+- Fixed an exception when parsing PDFs that are missing a required
+ field. `#325 `__
+- pikepdf 1.0.5 is now required, to address some other PDF parsing
+ issues.
+
+v8.0.0
+======
+
+No major features. The intent of this release is to sever support for
+older versions of certain dependencies.
+
+**Breaking changes**
+
+- Dropped support for Tesseract 3.x. Tesseract 4.0 or newer is now
+ required.
+- Dropped support for Python 3.5.
+- Some ``ocrmypdf.pdfa`` APIs that were deprecated in v7.x were
+ removed. This functionality has been moved to pikepdf.
**Other changes**
-- Fixed an unhandled exception when attempting to mask barcodes. `#322 `_
-
-- It is now possible to use ocrmypdf without pdfminer.six, to support distributions that do not have it or cannot currently use it (e.g. Homebrew). Downstream maintainers should include pdfminer.six if possible.
-
-- A warning is now issue when PDF/A conversion removes some XMP metadata from the input PDF. (Only a "whitelist" of certain XMP metadata types are allowed in PDF/A.)
-
-- Fixed several issues that caused PDF/As to be produced with nonconforming XMP metadata (would fail validation with veraPDF).
-
-- Fixed some instances where invalid DocumentInfo from a PDF cause XMP metadata creation to fail.
-
-- Fixed a few documentation problems.
-
-- pikepdf 1.0.2 is now required.
+- Fixed an unhandled exception when attempting to mask barcodes.
+ `#322 `__
+- It is now possible to use ocrmypdf without pdfminer.six, to support
+ distributions that do not have it or cannot currently use it (e.g.
+ Homebrew). Downstream maintainers should include pdfminer.six if
+ possible.
+- A warning is now issue when PDF/A conversion removes some XMP
+ metadata from the input PDF. (Only a "whitelist" of certain XMP
+ metadata types are allowed in PDF/A.)
+- Fixed several issues that caused PDF/As to be produced with
+ nonconforming XMP metadata (would fail validation with veraPDF).
+- Fixed some instances where invalid DocumentInfo from a PDF cause XMP
+ metadata creation to fail.
+- Fixed a few documentation problems.
+- pikepdf 1.0.2 is now required.
v7.4.0
-------
+======
-- ``--force-ocr`` may now be used with the new ``--threshold`` and ``--mask-barcodes`` features
-
-- pikepdf >= 0.9.1 is now required.
-
-- Changed metadata handling to pikepdf 0.9.1. As a result, metadata handling of non-ASCII characters in Ghostscript 9.25 or later is fixed.
-
-- chardet >= 3.0.4 is temporarily listed as required. pdfminer.six depends on it, but the most recent release does not specify this requirement. (`#326 `_)
-
-- python-xmp-toolkit and libexempi are no longer required.
-
-- A new Docker image is now being provided for users who wish to access OCRmyPDF over a simple HTTP interface, instead of the command line.
-
-- Increase tolerance of PDFs that overflow or underflow the PDF graphics stack. (`#325 `_)
+- ``--force-ocr`` may now be used with the new ``--threshold`` and
+ ``--mask-barcodes`` features
+- pikepdf >= 0.9.1 is now required.
+- Changed metadata handling to pikepdf 0.9.1. As a result, metadata
+ handling of non-ASCII characters in Ghostscript 9.25 or later is
+ fixed.
+- chardet >= 3.0.4 is temporarily listed as required. pdfminer.six
+ depends on it, but the most recent release does not specify this
+ requirement.
+ (`#326 `__)
+- python-xmp-toolkit and libexempi are no longer required.
+- A new Docker image is now being provided for users who wish to access
+ OCRmyPDF over a simple HTTP interface, instead of the command line.
+- Increase tolerance of PDFs that overflow or underflow the PDF
+ graphics stack.
+ (`#325 `__)
v7.3.1
-------
-
-- Fixed performance regression from v7.3.0; fast page analysis was not selected when it should be.
-
-- Fixed a few exceptions related to the new ``--mask-barcodes`` feature and improved argument checking
-
-- Added missing detection of TrueType fonts that lack a Unicode mapping
+======
+- Fixed performance regression from v7.3.0; fast page analysis was not
+ selected when it should be.
+- Fixed a few exceptions related to the new ``--mask-barcodes`` feature
+ and improved argument checking
+- Added missing detection of TrueType fonts that lack a Unicode mapping
v7.3.0
-------
+======
-- Added a new feature ``--redo-ocr`` to detect existing OCR in a file, remove it, and redo the OCR. This may be particularly helpful for anyone who wants to take advantage of OCR quality improvements in Tesseract 4.0. Note that OCR added by OCRmyPDF before version 3.0 cannot be detected since it was not properly marked as invisible text in the earliest versions. OCR that constructs a font from visible text, such as Adobe Acrobat's ClearScan.
+- Added a new feature ``--redo-ocr`` to detect existing OCR in a file,
+ remove it, and redo the OCR. This may be particularly helpful for
+ anyone who wants to take advantage of OCR quality improvements in
+ Tesseract 4.0. Note that OCR added by OCRmyPDF before version 3.0
+ cannot be detected since it was not properly marked as invisible text
+ in the earliest versions. OCR that constructs a font from visible
+ text, such as Adobe Acrobat's ClearScan.
+- OCRmyPDF's content detection is generally more sophisticated. It
+ learns more about the contents of each PDF and makes better
+ recommendations:
-- OCRmyPDF's content detection is generally more sophisticated. It learns more about the contents of each PDF and makes better recommendations:
+ - OCRmyPDF can now detect when a PDF contains text that cannot be
+ mapped to Unicode (meaning it is readable to human eyes but
+ copy-pastes as gibberish). In these cases it recommends
+ ``--force-ocr`` to make the text searchable.
+ - PDFs containing vector objects are now rendered at more
+ appropriate resolution for OCR.
+ - We now exit with an error for PDFs that contain Adobe LiveCycle
+ Designer's dynamic XFA forms. Currently the open source community
+ does not have tools to work with these files.
+ - OCRmyPDF now warns when a PDF that contains Adobe AcroForms, since
+ such files probably do not need OCR. It can work with these files.
- - OCRmyPDF can now detect when a PDF contains text that cannot be mapped to Unicode (meaning it is readable to human eyes but copy-pastes as gibberish). In these cases it recommends ``--force-ocr`` to make the text searchable.
+- Added three new **experimental** features to improve OCR quality in
+ certain conditions. The name, syntax and behavior of these arguments
+ is subject to change. They may also be incompatible with some other
+ features.
- - PDFs containing vector objects are now rendered at more appropriate resolution for OCR.
+ - ``--remove-vectors`` which strips out vector graphics. This can
+ improve OCR quality since OCR will not search artwork for readable
+ text; however, it currently removes "text as curves" as well.
+ - ``--mask-barcodes`` to detect and suppress barcodes in files. We
+ have observed that barcodes can interfere with OCR because they
+ are "text-like" but not actually textual.
+ - ``--threshold`` which uses a more sophisticated thresholding
+ algorithm than is currently in use in Tesseract OCR. This works
+ around a `known issue in Tesseract
+ 4.0 `__
+ with dark text on bright backgrounds.
- - We now exit with an error for PDFs that contain Adobe LiveCycle Designer's dynamic XFA forms. Currently the open source community does not have tools to work with these files.
-
- - OCRmyPDF now warns when a PDF that contains Adobe AcroForms, since such files probably do not need OCR. It can work with these files.
-
-- Added three new **experimental** features to improve OCR quality in certain conditions. The name, syntax and behavior of these arguments is subject to change. They may also be incompatible with some other features.
-
- - ``--remove-vectors`` which strips out vector graphics. This can improve OCR quality since OCR will not search artwork for readable text; however, it currently removes "text as curves" as well.
-
- - ``--mask-barcodes`` to detect and suppress barcodes in files. We have observed that barcodes can interfere with OCR because they are "text-like" but not actually textual.
-
- - ``--threshold`` which uses a more sophisticated thresholding algorithm than is currently in use in Tesseract OCR. This works around a `known issue in Tesseract 4.0 `_ with dark text on bright backgrounds.
-
-- Fixed an issue where an error message was not reported when the installed Ghostscript was very old.
-
-- The PDF optimizer now saves files with object streams enabled when the optimization level is ``--optimize 1`` or higher (the default). This makes files a little bit smaller, but requires PDF 1.5. PDF 1.5 was first released in 2003 and is broadly supported by PDF viewers, but some rudimentary PDF parsers such as PyPDF2 do not understand object streams. You can use the command line tool ``qpdf --object-streams=disable`` or `pikepdf `_ library to remove them.
-
-- New dependency: pdfminer.six 20181108. Note this is a fork of the Python 2-only pdfminer.
-
-- Deprecation notice: At the end of 2018, we will be ending support for Python 3.5 and Tesseract 3.x. OCRmyPDF v7 will continue to work with older versions.
+- Fixed an issue where an error message was not reported when the
+ installed Ghostscript was very old.
+- The PDF optimizer now saves files with object streams enabled when
+ the optimization level is ``--optimize 1`` or higher (the default).
+ This makes files a little bit smaller, but requires PDF 1.5. PDF 1.5
+ was first released in 2003 and is broadly supported by PDF viewers,
+ but some rudimentary PDF parsers such as PyPDF2 do not understand
+ object streams. You can use the command line tool
+ ``qpdf --object-streams=disable`` or
+ `pikepdf `__ library to remove
+ them.
+- New dependency: pdfminer.six 20181108. Note this is a fork of the
+ Python 2-only pdfminer.
+- Deprecation notice: At the end of 2018, we will be ending support for
+ Python 3.5 and Tesseract 3.x. OCRmyPDF v7 will continue to work with
+ older versions.
v7.2.1
-------
-
-- Fix compatibility with an API change in pikepdf 0.3.5.
-
-- A kludge to support Leptonica versions older than 1.72 in the test suite was dropped. Older versions of Leptonica are likely still compatible. The only impact is that a portion of the test suite will be skipped.
+======
+- Fix compatibility with an API change in pikepdf 0.3.5.
+- A kludge to support Leptonica versions older than 1.72 in the test
+ suite was dropped. Older versions of Leptonica are likely still
+ compatible. The only impact is that a portion of the test suite will
+ be skipped.
v7.2.0
-------
+======
**Lossy JBIG2 behavior change**
-A user reported that ocrmypdf was in fact using JBIG2 in **lossy** compression mode. This was not the intended behavior. Users should `review the technical concerns with JBIG2 in lossy mode `_ and decide if this is a concern for their use case.
+A user reported that ocrmypdf was in fact using JBIG2 in **lossy**
+compression mode. This was not the intended behavior. Users should
+`review the technical concerns with JBIG2 in lossy
+mode `__
+and decide if this is a concern for their use case.
-JBIG2 lossy mode does achieve higher compression ratios than any other monochrome compression technology; for large text documents the savings are considerable. JBIG2 lossless still gives great compression ratios and is a major improvement over the older CCITT G4 standard.
+JBIG2 lossy mode does achieve higher compression ratios than any other
+monochrome compression technology; for large text documents the savings
+are considerable. JBIG2 lossless still gives great compression ratios
+and is a major improvement over the older CCITT G4 standard.
-Only users who have reviewed the concerns with JBIG2 in lossy mode should opt-in. As such, lossy mode JBIG2 is only turned on when the new argument ``--jbig2-lossy`` is issued. This is independent of the setting for ``--optimize``.
+Only users who have reviewed the concerns with JBIG2 in lossy mode
+should opt-in. As such, lossy mode JBIG2 is only turned on when the new
+argument ``--jbig2-lossy`` is issued. This is independent of the setting
+for ``--optimize``.
Users who did not install an optional JBIG2 encoder are unaffected.
@@ -209,930 +1019,1238 @@ Users who did not install an optional JBIG2 encoder are unaffected.
**Other issues**
-- When the image optimizer quantizes an image to 1 bit per pixel, it will now attempt to further optimize that image as CCITT or JBIG2, instead of keeping it in the "flate" encoding which is not efficient for 1 bpp images. (`#297 `_)
-
-- Images in PDFs that are used as soft masks (i.e. transparency masks or alpha channels) are now excluded from optimization.
-
-- Fixed handling of Tesseract 4.0-rc1 which now accepts invalid Tesseract configuration files, which broke the test suite.
+- When the image optimizer quantizes an image to 1 bit per pixel, it
+ will now attempt to further optimize that image as CCITT or JBIG2,
+ instead of keeping it in the "flate" encoding which is not efficient
+ for 1 bpp images.
+ (`#297 `__)
+- Images in PDFs that are used as soft masks (i.e. transparency masks
+ or alpha channels) are now excluded from optimization.
+- Fixed handling of Tesseract 4.0-rc1 which now accepts invalid
+ Tesseract configuration files, which broke the test suite.
v7.1.0
-------
+======
-- Improve the performance of initial text extraction, which is done to determine if a file contains existing text of some kind or not. On large files, this initial processing is now about 20x times faster. (`#299 `_)
-
-- pikepdf 0.3.3 is now required.
-
-- Fixed issue `#231 `_, a problem with JPEG2000 images where image metadata was only available inside the JPEG2000 file.
-
-- Fixed some additional Ghostscript 9.25 compatibility issues.
-
-- Improved handling of KeyboardInterrupt error messages. (`#301 `_)
-
-- README.md is now served in GitHub markdown instead of reStructuredText.
+- Improve the performance of initial text extraction, which is done to
+ determine if a file contains existing text of some kind or not. On
+ large files, this initial processing is now about 20x times faster.
+ (`#299 `__)
+- pikepdf 0.3.3 is now required.
+- Fixed issue
+ `#231 `__, a
+ problem with JPEG2000 images where image metadata was only available
+ inside the JPEG2000 file.
+- Fixed some additional Ghostscript 9.25 compatibility issues.
+- Improved handling of KeyboardInterrupt error messages.
+ (`#301 `__)
+- README.md is now served in GitHub markdown instead of
+ reStructuredText.
v7.0.6
-------
-
-- Blacklist Ghostscript 9.24, now that 9.25 is available and fixes many regressions in 9.24.
+======
+- Blacklist Ghostscript 9.24, now that 9.25 is available and fixes many
+ regressions in 9.24.
v7.0.5
-------
+======
-- Improve capability with Ghostscript 9.24, and enable the JPEG passthrough feature when this version in installed.
-
-- Ghostscript 9.24 lost the ability to set PDF title, author, subject and keyword metadata to Unicode strings. OCRmyPDF will set ASCII strings and warn when Unicode is suppressed. Other software may be used to update metadata. This is a short term work around.
-
-- PDFs generated by Kodak Capture Desktop, or generally PDFs that contain indirect references to null objects in their table of contents, would have an invalid table of contents after processing by OCRmyPDF that might interfere with other viewers. This has been fixed.
-
-- Detect PDFs generated by Adobe LiveCycle, which can only be displayed in Adobe Acrobat and Reader currently. When these are encountered, exit with an error instead of performing OCR on the "Please wait" error message page.
+- Improve capability with Ghostscript 9.24, and enable the JPEG
+ passthrough feature when this version in installed.
+- Ghostscript 9.24 lost the ability to set PDF title, author, subject
+ and keyword metadata to Unicode strings. OCRmyPDF will set ASCII
+ strings and warn when Unicode is suppressed. Other software may be
+ used to update metadata. This is a short term work around.
+- PDFs generated by Kodak Capture Desktop, or generally PDFs that
+ contain indirect references to null objects in their table of
+ contents, would have an invalid table of contents after processing by
+ OCRmyPDF that might interfere with other viewers. This has been
+ fixed.
+- Detect PDFs generated by Adobe LiveCycle, which can only be displayed
+ in Adobe Acrobat and Reader currently. When these are encountered,
+ exit with an error instead of performing OCR on the "Please wait"
+ error message page.
v7.0.4
-------
+======
-- Fix exception thrown when trying to optimize a certain type of PNG embedded in a PDF with the ``-O2``
-
-- Update to pikepdf 0.3.2, to gain support for optimizing some additional image types that were previously excluded from optimization (CMYK and grayscale). Fixes `#285 `_.
+- Fix exception thrown when trying to optimize a certain type of PNG
+ embedded in a PDF with the ``-O2``
+- Update to pikepdf 0.3.2, to gain support for optimizing some
+ additional image types that were previously excluded from
+ optimization (CMYK and grayscale). Fixes
+ `#285 `__.
v7.0.3
-------
+======
-- Fix issue `#284 `_, an error when parsing inline images that have are also image masks, by upgrading pikepdf to 0.3.1
+- Fix issue
+ `#284 `__, an error
+ when parsing inline images that have are also image masks, by
+ upgrading pikepdf to 0.3.1
v7.0.2
-------
+======
-- Fix a regression with ``--rotate-pages`` on pages that already had rotations applied. (`#279 `_)
-
-- Improve quality of page rotation in some cases by rasterizing a higher quality preview image. (`#281 `_)
+- Fix a regression with ``--rotate-pages`` on pages that already had
+ rotations applied.
+ (`#279 `__)
+- Improve quality of page rotation in some cases by rasterizing a
+ higher quality preview image.
+ (`#281 `__)
v7.0.1
-------
+======
-- Fix compatibility with img2pdf >= 0.3.0 by rejecting input images that have an alpha channel
-
-- Add forward compatibility for pikepdf 0.3.0 (unrelated to img2pdf)
-
-- Various documentation updates for v7.0.0 changes
+- Fix compatibility with img2pdf >= 0.3.0 by rejecting input images
+ that have an alpha channel
+- Add forward compatibility for pikepdf 0.3.0 (unrelated to img2pdf)
+- Various documentation updates for v7.0.0 changes
v7.0.0
-------
+======
-- The core algorithm for combining OCR layers with existing PDF pages has been rewritten and improved considerably. PDFs are no longer split into single page PDFs for processing; instead, images are rendered and the OCR results are grafted onto the input PDF. The new algorithm uses less temporary disk space and is much more performant especially for large files.
+- The core algorithm for combining OCR layers with existing PDF pages
+ has been rewritten and improved considerably. PDFs are no longer
+ split into single page PDFs for processing; instead, images are
+ rendered and the OCR results are grafted onto the input PDF. The new
+ algorithm uses less temporary disk space and is much more performant
+ especially for large files.
+- New dependency: `pikepdf `__.
+ pikepdf is a powerful new Python PDF library driving the latest
+ OCRmyPDF features, built on the QPDF C++ library (libqpdf).
+- New feature: PDF optimization with ``-O`` or ``--optimize``. After
+ OCR, OCRmyPDF will perform image optimizations relevant to OCR PDFs.
-- New dependency: `pikepdf `_. pikepdf is a powerful new Python PDF library driving the latest OCRmyPDF features, built on the QPDF C++ library (libqpdf).
+ - If a JBIG2 encoder is available, then monochrome images will be
+ converted, with the potential for huge savings on large black and
+ white images, since JBIG2 is far more efficient than any other
+ monochrome (bi-level) compression. (All known US patents related
+ to JBIG2 have probably expired, but it remains the responsibility
+ of the user to supply a JBIG2 encoder such as
+ `jbig2enc `__. OCRmyPDF does not
+ implement JBIG2 encoding.)
+ - If ``pngquant`` is installed, OCRmyPDF will optionally use it to
+ perform lossy quantization and compression of PNG images.
+ - The quality of JPEGs can also be lowered, on the assumption that a
+ lower quality image may be suitable for storage after OCR.
+ - This image optimization component will eventually be offered as an
+ independent command line utility.
+ - Optimization ranges from ``-O0`` through ``-O3``, where ``0``
+ disables optimization and ``3`` implements all options. ``1``, the
+ default, performs only safe and lossless optimizations. (This is
+ similar to GCC's optimization parameter.) The exact type of
+ optimizations performed will vary over time.
-- New feature: PDF optimization with ``-O`` or ``--optimize``. After OCR, OCRmyPDF will perform image optimizations relevant to OCR PDFs.
+- Small amounts of text in the margins of a page, such as watermarks,
+ page numbers, or digital stamps, will no longer prevent the rest of a
+ page from being OCRed when ``--skip-text`` is issued. This behavior
+ is based on a heuristic.
+- Removed features
- + If a JBIG2 encoder is available, then monochrome images will be converted, with the potential for huge savings on large black and white images, since JBIG2 is far more efficient than any other monochrome (bi-level) compression. (All known US patents related to JBIG2 have probably expired, but it remains the responsibility of the user to supply a JBIG2 encoder such as `jbig2enc `_. OCRmyPDF does not implement JBIG2 encoding.)
+ - The deprecated ``--pdf-renderer tesseract`` PDF renderer was
+ removed.
+ - ``-g``, the option to generate debug text pages, was removed
+ because it was a maintenance burden and only worked in isolated
+ cases. HOCR pages can still be previewed by running the
+ hocrtransform.py with appropriate settings.
- + If ``pngquant`` is installed, OCRmyPDF will optionally use it to perform lossy quantization and compression of PNG images.
+- Removed dependencies
- + The quality of JPEGs can also be lowered, on the assumption that a lower quality image may be suitable for storage after OCR.
+ - ``PyPDF2``
+ - ``defusedxml``
+ - ``PyMuPDF``
- + This image optimization component will eventually be offered as an independent command line utility.
+- The ``sandwich`` PDF renderer can be used with all supported versions
+ of Tesseract, including that those prior to v3.05 which don't support
+ ``-c textonly``. (Tesseract v4.0.0 is recommended and more
+ efficient.)
+- ``--pdf-renderer auto`` option and the diagnostics used to select a
+ PDF renderer now work better with old versions, but may make
+ different decisions than past versions.
+- If everything succeeds but PDF/A conversion fails, a distinct return
+ code is now returned (``ExitCode.pdfa_conversion_failed (10)``) where
+ this situation previously returned
+ ``ExitCode.invalid_output_pdf (4)``. The latter is now returned only
+ if there is some indication that the output file is invalid.
+- Notes for downstream packagers
- + Optimization ranges from ``-O0`` through ``-O3``, where ``0`` disables optimization and ``3`` implements all options. ``1``, the default, performs only safe and lossless optimizations. (This is similar to GCC's optimization parameter.) The exact type of optimizations performed will vary over time.
-
-- Small amounts of text in the margins of a page, such as watermarks, page numbers, or digital stamps, will no longer prevent the rest of a page from being OCRed when ``--skip-text`` is issued. This behavior is based on a heuristic.
-
-- Removed features
-
- + The deprecated ``--pdf-renderer tesseract`` PDF renderer was removed.
-
- + ``-g``, the option to generate debug text pages, was removed because it was a maintenance burden and only worked in isolated cases. HOCR pages can still be previewed by running the hocrtransform.py with appropriate settings.
-
-- Removed dependencies
-
- + ``PyPDF2``
-
- + ``defusedxml``
-
- + ``PyMuPDF``
-
-- The ``sandwich`` PDF renderer can be used with all supported versions of Tesseract, including that those prior to v3.05 which don't support ``-c textonly``. (Tesseract v4.0.0 is recommended and more efficient.)
-
-- ``--pdf-renderer auto`` option and the diagnostics used to select a PDF renderer now work better with old versions, but may make different decisions than past versions.
-
-- If everything succeeds but PDF/A conversion fails, a distinct return code is now returned (``ExitCode.pdfa_conversion_failed (10)``) where this situation previously returned ``ExitCode.invalid_output_pdf (4)``. The latter is now returned only if there is some indication that the output file is invalid.
-
-- Notes for downstream packagers
-
- + There is also a new dependency on ``python-xmp-toolkit`` which in turn depends on ``libexempi3``.
-
- + It may be necessary to separately ``pip install pycparser`` to avoid `another Python 3.7 issue `_.
+ - There is also a new dependency on ``python-xmp-toolkit`` which in
+ turn depends on ``libexempi3``.
+ - It may be necessary to separately ``pip install pycparser`` to
+ avoid `another Python 3.7
+ issue `__.
v6.2.5
-------
+======
-- Disable a failing test due to Tesseract 4.0rc1 behavior change. Previously, Tesseract would exit with an error message if its configuration was invalid, and OCRmyPDF would intercept this message. Now Tesseract issues a warning, which OCRmyPDF v6.2.5 may relay or ignore. (In v7.x, OCRmyPDF will respond to the warning.)
-
-- This release branch no longer supports using the optional PyMuPDF installation, since it was removed in v7.x.
-
-- This release branch no longer supports macOS. macOS users should upgrade to v7.x.
+- Disable a failing test due to Tesseract 4.0rc1 behavior change.
+ Previously, Tesseract would exit with an error message if its
+ configuration was invalid, and OCRmyPDF would intercept this message.
+ Now Tesseract issues a warning, which OCRmyPDF v6.2.5 may relay or
+ ignore. (In v7.x, OCRmyPDF will respond to the warning.)
+- This release branch no longer supports using the optional PyMuPDF
+ installation, since it was removed in v7.x.
+- This release branch no longer supports macOS. macOS users should
+ upgrade to v7.x.
v6.2.4
-------
+======
-- Backport Ghostscript 9.25 compatibility fixes, which removes support for setting Unicode metadata
-- Backport blacklisting Ghostscript 9.24
-- Older versions of Ghostscript are still supported
+- Backport Ghostscript 9.25 compatibility fixes, which removes support
+ for setting Unicode metadata
+- Backport blacklisting Ghostscript 9.24
+- Older versions of Ghostscript are still supported
v6.2.3
-------
+======
-- Fix compatibility with img2pdf >= 0.3.0 by rejecting input images that have an alpha channel
-- This version will be included in Ubuntu 18.10
+- Fix compatibility with img2pdf >= 0.3.0 by rejecting input images
+ that have an alpha channel
+- This version will be included in Ubuntu 18.10
v6.2.2
-------
+======
-- Backport compatibility fixes for Python 3.7 and ruffus 2.7.0 from v7.0.0
-- Backport fix to ignore masks when deciding what colors are on a page
-- Backport some minor improvements from v7.0.0: better argument validation and warnings about the Tesseract 4.0.0 ``--user-words`` regression
+- Backport compatibility fixes for Python 3.7 and ruffus 2.7.0 from
+ v7.0.0
+- Backport fix to ignore masks when deciding what colors are on a page
+- Backport some minor improvements from v7.0.0: better argument
+ validation and warnings about the Tesseract 4.0.0 ``--user-words``
+ regression
v6.2.1
-------
+======
-- Fix recent versions of Tesseract (after 4.0.0-beta1) not being detected as supporting the ``sandwich`` renderer (`#271 `_).
+- Fix recent versions of Tesseract (after 4.0.0-beta1) not being
+ detected as supporting the ``sandwich`` renderer
+ (`#271 `__).
v6.2.0
-------
-
-- **Docker**: The Docker image ``ocrmypdf-tess4`` has been removed. The main Docker images, ``ocrmypdf`` and ``ocrmypdf-polyglot`` now use Ubuntu 18.04 as a base image, and as such Tesseract 4.0.0-beta1 is now the Tesseract version they use. There is no Docker image based on Tesseract 3.05 anymore.
-
-- Creation of PDF/A-3 is now supported. However, there is no ability to attach files to PDF/A-3.
-
-- Lists more reasons why the file size might grow.
-
-- Fix issue `#262 `_, ``--remove-background`` error on PDFs contained colormapped (paletted) images.
-
-- Fix another XMP metadata validation issue, in cases where the input file's creation date has no timezone and the creation date is not overridden.
+======
+- **Docker**: The Docker image ``ocrmypdf-tess4`` has been removed. The
+ main Docker images, ``ocrmypdf`` and ``ocrmypdf-polyglot`` now use
+ Ubuntu 18.04 as a base image, and as such Tesseract 4.0.0-beta1 is
+ now the Tesseract version they use. There is no Docker image based on
+ Tesseract 3.05 anymore.
+- Creation of PDF/A-3 is now supported. However, there is no ability to
+ attach files to PDF/A-3.
+- Lists more reasons why the file size might grow.
+- Fix issue
+ `#262 `__,
+ ``--remove-background`` error on PDFs contained colormapped
+ (paletted) images.
+- Fix another XMP metadata validation issue, in cases where the input
+ file's creation date has no timezone and the creation date is not
+ overridden.
v6.1.5
-------
-
-- Fix issue `#253 `_, a possible division by zero when using the ``hocr`` renderer.
-
-- Fix incorrectly formatted ```` field inside XMP metadata for PDF/As. veraPDF flags this as a PDF/A validation failure. The error is caused the timezone and final digit of the seconds of modified time to be omitted, so at worst the modification time stamp is rounded to the nearest 10 seconds.
+======
+- Fix issue
+ `#253 `__, a
+ possible division by zero when using the ``hocr`` renderer.
+- Fix incorrectly formatted ```` field inside XMP
+ metadata for PDF/As. veraPDF flags this as a PDF/A validation
+ failure. The error is caused the timezone and final digit of the
+ seconds of modified time to be omitted, so at worst the modification
+ time stamp is rounded to the nearest 10 seconds.
v6.1.4
-------
+======
-- Fix issue `#248 `_ ``--clean`` argument may remove OCR from left column of text on certain documents. We now set ``--layout none`` to suppress this.
-
-- The test cache was updated to reflect the change above.
-
-- Change test suite to accommodate Ghostscript 9.23's new ability to insert JPEGs into PDFs without transcoding.
-
-- XMP metadata in PDFs is now examined using ``defusedxml`` for safety.
-
-- If an external process exits with a signal when asked to report its version, we now print the system error message instead of suppressing it. This occurred when the required executable was found but was missing a shared library.
-
-- qpdf 7.0.0 or newer is now required as the test suite can no longer pass without it.
+- Fix issue `#248 `__
+ ``--clean`` argument may remove OCR from left column of text on
+ certain documents. We now set ``--layout none`` to suppress this.
+- The test cache was updated to reflect the change above.
+- Change test suite to accommodate Ghostscript 9.23's new ability to
+ insert JPEGs into PDFs without transcoding.
+- XMP metadata in PDFs is now examined using ``defusedxml`` for safety.
+- If an external process exits with a signal when asked to report its
+ version, we now print the system error message instead of suppressing
+ it. This occurred when the required executable was found but was
+ missing a shared library.
+- qpdf 7.0.0 or newer is now required as the test suite can no longer
+ pass without it.
Notes
-~~~~~
-
-- An apparent `regression in Ghostscript 9.23 `_ will cause some ocrmypdf output files to become invalid in rare cases; the workaround for the moment is to set ``--force-ocr``.
+-----
+- An apparent `regression in Ghostscript
+ 9.23 `__ will
+ cause some ocrmypdf output files to become invalid in rare cases; the
+ workaround for the moment is to set ``--force-ocr``.
v6.1.3
-------
-
-- Fix issue `#247 `_, ``/CreationDate`` metadata not copied from input to output.
-
-- A warning is now issued when Python 3.5 is used on files with a large page count, as this case is known to regress to single core performance. The cause of this problem is unknown.
+======
+- Fix issue
+ `#247 `__,
+ ``/CreationDate`` metadata not copied from input to output.
+- A warning is now issued when Python 3.5 is used on files with a large
+ page count, as this case is known to regress to single core
+ performance. The cause of this problem is unknown.
v6.1.2
-------
-
-- Upgrade to PyMuPDF v1.12.5 which includes a more complete fix to `#239 `_.
-
-- Add ``defusedxml`` dependency.
+======
+- Upgrade to PyMuPDF v1.12.5 which includes a more complete fix to
+ `#239 `__.
+- Add ``defusedxml`` dependency.
v6.1.1
-------
-
-- Fix text being reported as found on all pages if PyMuPDF is not installed.
+======
+- Fix text being reported as found on all pages if PyMuPDF is not
+ installed.
v6.1.0
-------
-
-- PyMuPDF is now an optional but recommended dependency, to alleviate installation difficulties on platforms that have less access to PyMuPDF than the author anticipated. (For version 6.x only) install OCRmyPDF with ``pip install ocrmypdf[fitz]`` to use it to its full potential.
-
-- Fix ``FileExistsError`` that could occur if OCR timed out while it was generating the output file. (`#218 `_)
-
-- Fix table of contents/bookmarks all being redirected to page 1 when generating a PDF/A (with PyMuPDF). (Without PyMuPDF the table of contents is removed in PDF/A mode.)
-
-- Fix "RuntimeError: invalid key in dict" when table of contents/bookmarks titles contained the character ``)``. (`#239 `_)
-
-- Added a new argument ``--skip-repair`` to skip the initial PDF repair step if the PDF is already well-formed (because another program repaired it).
+======
+- PyMuPDF is now an optional but recommended dependency, to alleviate
+ installation difficulties on platforms that have less access to
+ PyMuPDF than the author anticipated. (For version 6.x only) install
+ OCRmyPDF with ``pip install ocrmypdf[fitz]`` to use it to its full
+ potential.
+- Fix ``FileExistsError`` that could occur if OCR timed out while it
+ was generating the output file.
+ (`#218 `__)
+- Fix table of contents/bookmarks all being redirected to page 1 when
+ generating a PDF/A (with PyMuPDF). (Without PyMuPDF the table of
+ contents is removed in PDF/A mode.)
+- Fix "RuntimeError: invalid key in dict" when table of
+ contents/bookmarks titles contained the character ``)``.
+ (`#239 `__)
+- Added a new argument ``--skip-repair`` to skip the initial PDF repair
+ step if the PDF is already well-formed (because another program
+ repaired it).
v6.0.0
-------
+======
-- The software license has been changed to GPLv3. Test resource files and some individual sources may have other licenses.
+- The software license has been changed to GPLv3 [it has since changed again].
+ Test resource files and some individual sources may have other licenses.
+- OCRmyPDF now depends on
+ `PyMuPDF `__.
+ Including PyMuPDF is the primary reason for the change to GPLv3.
+- Other backward incompatible changes
-- OCRmyPDF now depends on `PyMuPDF `_. Including PyMuPDF is the primary reason for the change to GPLv3.
-
-- Other backward incompatible changes
-
- + The ``OCRMYPDF_TESSERACT``, ``OCRMYPDF_QPDF``, ``OCRMYPDF_GS`` and ``OCRMYPDF_UNPAPER`` environment variables are no longer used. Change ``PATH`` if you need to override the external programs OCRmyPDF uses.
-
- + The ``ocrmypdf`` package has been moved to ``src/ocrmypdf`` to avoid issues with accidental import.
-
- + The function ``ocrmypdf.exec.get_program`` was removed.
-
- + The deprecated module ``ocrmypdf.pageinfo`` was removed.
-
- + The ``--pdf-renderer tess4`` alias for ``sandwich`` was removed.
-
-- Fixed an issue where OCRmyPDF failed to detect existing text on pages, depending on how the text and fonts were encoded within the PDF. (`#233 `_, `#232 `_)
-
-- Fixed an issue that caused dramatic inflation of file sizes when ``--skip-text --output-type pdf`` was used. OCRmyPDF now removes duplicate resources such as fonts, images and other objects that it generates. (`#237 `_)
-
-- Improved performance of the initial page splitting step. Originally this step was not believed to be expensive and ran in a process. Large file testing revealed it to be a bottleneck, so it is now parallelized. On a 700 page file with quad core machine, this change saves about 2 minutes. (`#234 `_)
-
-- The test suite now includes a cache that can be used to speed up test runs across platforms. This also does not require computing checksums, so it's faster. (`#217 `_)
+ - The ``OCRMYPDF_TESSERACT``, ``OCRMYPDF_QPDF``, ``OCRMYPDF_GS`` and
+ ``OCRMYPDF_UNPAPER`` environment variables are no longer used.
+ Change ``PATH`` if you need to override the external programs
+ OCRmyPDF uses.
+ - The ``ocrmypdf`` package has been moved to ``src/ocrmypdf`` to
+ avoid issues with accidental import.
+ - The function ``ocrmypdf.exec.get_program`` was removed.
+ - The deprecated module ``ocrmypdf.pageinfo`` was removed.
+ - The ``--pdf-renderer tess4`` alias for ``sandwich`` was removed.
+- Fixed an issue where OCRmyPDF failed to detect existing text on
+ pages, depending on how the text and fonts were encoded within the
+ PDF. (`#233 `__,
+ `#232 `__)
+- Fixed an issue that caused dramatic inflation of file sizes when
+ ``--skip-text --output-type pdf`` was used. OCRmyPDF now removes
+ duplicate resources such as fonts, images and other objects that it
+ generates.
+ (`#237 `__)
+- Improved performance of the initial page splitting step. Originally
+ this step was not believed to be expensive and ran in a process.
+ Large file testing revealed it to be a bottleneck, so it is now
+ parallelized. On a 700 page file with quad core machine, this change
+ saves about 2 minutes.
+ (`#234 `__)
+- The test suite now includes a cache that can be used to speed up test
+ runs across platforms. This also does not require computing
+ checksums, so it's faster.
+ (`#217 `__)
v5.7.0
-------
+======
-- Fixed an issue that caused poor CPU utilization on machines with more than 4 cores when running Tesseract 4. (Related to issue `#217 `_.)
+- Fixed an issue that caused poor CPU utilization on machines with more
+ than 4 cores when running Tesseract 4. (Related to issue
+ `#217 `__.)
+- The 'hocr' renderer has been improved. The 'sandwich' and 'tesseract'
+ renderers are still better for most use cases, but 'hocr' may be
+ useful for people who work with the PDF.js renderer in English/ASCII
+ languages.
+ (`#225 `__)
-- The 'hocr' renderer has been improved. The 'sandwich' and 'tesseract' renderers are still better for most use cases, but 'hocr' may be useful for people who work with the PDF.js renderer in English/ASCII languages. (`#225 `_)
-
- + It now formats text in a matter that is easier for certain PDF viewers to select and extract copy and paste text. This should help macOS Preview and PDF.js in particular.
- + The appearance of selected text and behavior of selecting text is improved.
- + The PDF content stream now uses relative moves, making it more compact and easier for viewers to determine when two words on the same line.
- + It can now deal with text on a skewed baseline.
- + Thanks to @cforcey for the pull request, @jbreiden for many helpful suggestions, @ctbarbour for another round of improvements, and @acaloiaro for an independent review.
+ - It now formats text in a matter that is easier for certain PDF
+ viewers to select and extract copy and paste text. This should
+ help macOS Preview and PDF.js in particular.
+ - The appearance of selected text and behavior of selecting text is
+ improved.
+ - The PDF content stream now uses relative moves, making it more
+ compact and easier for viewers to determine when two words on the
+ same line.
+ - It can now deal with text on a skewed baseline.
+ - Thanks to @cforcey for the pull request, @jbreiden for many
+ helpful suggestions, @ctbarbour for another round of improvements,
+ and @acaloiaro for an independent review.
v5.6.3
-------
-
-- Suppress two debug messages that were too verbose
+======
+- Suppress two debug messages that were too verbose
v5.6.2
-------
-
-- Development branch accidentally tagged as release. Do not use.
+======
+- Development branch accidentally tagged as release. Do not use.
v5.6.1
-------
-
-- Fix issue `#219 `_: change how the final output file is created to avoid triggering permission errors when the output is a special file such as ``/dev/null``
-- Fix test suite failures due to a qpdf 8.0.0 regression and Python 3.5's handling of symlink
-- The "encrypted PDF" error message was different depending on the type of PDF encryption. Now a single clear message appears for all types of PDF encryption.
-- ocrmypdf is now in Homebrew. Homebrew users are advised to the version of ocrmypdf in the official homebrew-core formulas rather than the private tap.
-- Some linting
+======
+- Fix issue
+ `#219 `__: change
+ how the final output file is created to avoid triggering permission
+ errors when the output is a special file such as ``/dev/null``
+- Fix test suite failures due to a qpdf 8.0.0 regression and Python
+ 3.5's handling of symlink
+- The "encrypted PDF" error message was different depending on the type
+ of PDF encryption. Now a single clear message appears for all types
+ of PDF encryption.
+- ocrmypdf is now in Homebrew. Homebrew users are advised to the
+ version of ocrmypdf in the official homebrew-core formulas rather
+ than the private tap.
+- Some linting
v5.6.0
-------
-
-- Fix issue `#216 `_: preserve "text as curves" PDFs without rasterizing file
-- Related to the above, messages about rasterizing are more consistent
-- For consistency versions minor releases will now get the trailing .0 they always should have had.
+======
+- Fix issue
+ `#216 `__: preserve
+ "text as curves" PDFs without rasterizing file
+- Related to the above, messages about rasterizing are more consistent
+- For consistency versions minor releases will now get the trailing .0
+ they always should have had.
v5.5
-----
-
-- Add new argument ``--max-image-mpixels``. Pillow 5.0 now raises an exception when images may be decompression bombs. This argument can be used to override the limit Pillow sets.
-- Fix output page cropped when using the sandwich renderer and OCR is skipped on a rotated and image-processed page
-- A warning is now issued when old versions of Ghostscript are used in cases known to cause issues with non-Latin characters
-- Fix a few parameter validation checks for ``-output-type pdfa-1`` and ``pdfa-2``
+====
+- Add new argument ``--max-image-mpixels``. Pillow 5.0 now raises an
+ exception when images may be decompression bombs. This argument can
+ be used to override the limit Pillow sets.
+- Fix output page cropped when using the sandwich renderer and OCR is
+ skipped on a rotated and image-processed page
+- A warning is now issued when old versions of Ghostscript are used in
+ cases known to cause issues with non-Latin characters
+- Fix a few parameter validation checks for ``-output-type pdfa-1`` and
+ ``pdfa-2``
v5.4.4
-------
-
-- Fix issue `#181 `_: fix final merge failure for PDFs with more pages than the system file handle limit (``ulimit -n``)
-- Fix issue `#200 `_: an uncommon syntax for formatting decimal numbers in a PDF would cause qpdf to issue a warning, which ocrmypdf treated as an error. Now this the warning is relayed.
-- Fix an issue where intermediate PDFs would be created at version 1.3 instead of the version of the original file. It's possible but unlikely this had side effects.
-- A warning is now issued when older versions of qpdf are used since issues like `#200 `_ cause qpdf to infinite-loop
-- Address issue `#140 `_: if Tesseract outputs invalid UTF-8, escape it and print its message instead of aborting with a Unicode error
-- Adding previously unlisted setup requirement, pytest-runner
-- Update documentation: fix an error in the example script for Synology with Docker images, improved security guidance, advised ``pip install --user``
+======
+- Fix issue
+ `#181 `__: fix
+ final merge failure for PDFs with more pages than the system file
+ handle limit (``ulimit -n``)
+- Fix issue
+ `#200 `__: an
+ uncommon syntax for formatting decimal numbers in a PDF would cause
+ qpdf to issue a warning, which ocrmypdf treated as an error. Now this
+ the warning is relayed.
+- Fix an issue where intermediate PDFs would be created at version 1.3
+ instead of the version of the original file. It's possible but
+ unlikely this had side effects.
+- A warning is now issued when older versions of qpdf are used since
+ issues like
+ `#200 `__ cause
+ qpdf to infinite-loop
+- Address issue
+ `#140 `__: if
+ Tesseract outputs invalid UTF-8, escape it and print its message
+ instead of aborting with a Unicode error
+- Adding previously unlisted setup requirement, pytest-runner
+- Update documentation: fix an error in the example script for Synology
+ with Docker images, improved security guidance, advised
+ ``pip install --user``
v5.4.3
-------
-
-- If a subprocess fails to report its version when queried, exit cleanly with an error instead of throwing an exception
-- Added test to confirm that the system locale is Unicode-aware and fail early if it's not
-- Clarified some copyright information
-- Updated pinned requirements.txt so the homebrew formula captures more recent versions
+======
+- If a subprocess fails to report its version when queried, exit
+ cleanly with an error instead of throwing an exception
+- Added test to confirm that the system locale is Unicode-aware and
+ fail early if it's not
+- Clarified some copyright information
+- Updated pinned requirements.txt so the homebrew formula captures more
+ recent versions
v5.4.2
-------
-
-- Fixed a regression from v5.4.1 that caused sidecar files to be created as empty files
+======
+- Fixed a regression from v5.4.1 that caused sidecar files to be
+ created as empty files
v5.4.1
-------
-
-- Add workaround for Tesseract v4.00alpha crash when trying to obtain orientation and the latest language packs are installed
+======
+- Add workaround for Tesseract v4.00alpha crash when trying to obtain
+ orientation and the latest language packs are installed
v5.4
-----
-
-- Change wording of a deprecation warning to improve clarity
-- Added option to generate PDF/A-1b output if desired (``--output-type pdfa-1``); default remains PDF/A-2b generation
-- Update documentation
+====
+- Change wording of a deprecation warning to improve clarity
+- Added option to generate PDF/A-1b output if desired
+ (``--output-type pdfa-1``); default remains PDF/A-2b generation
+- Update documentation
v5.3.3
-------
-
-- 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
+======
+- 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
v5.3.2
-------
-
-- Fixed a broken test case related to language packs
+======
+- Fixed a broken test case related to language packs
v5.3.1
-------
-
-- Fixed wrong return code given for missing Tesseract language packs
-- Fixed "brew audit" crashing on Travis when trying to auto-brew
+======
+- Fixed wrong return code given for missing Tesseract language packs
+- Fixed "brew audit" crashing on Travis when trying to auto-brew
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
+====
+- 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
-----
-
-- When using Tesseract 3.05.01 or newer, OCRmyPDF will select the "sandwich" PDF renderer by default, unless another PDF renderer is specified with the ``--pdf-renderer`` argument. The previous behavior was to select ``--pdf-renderer=hocr``.
-- The "tesseract" PDF renderer is now deprecated, since it can cause problems with Ghostscript on Tesseract 3.05.00
-- The "tess4" PDF renderer has been renamed to "sandwich". "tess4" is now a deprecated alias for "sandwich".
+====
+- When using Tesseract 3.05.01 or newer, OCRmyPDF will select the
+ "sandwich" PDF renderer by default, unless another PDF renderer is
+ specified with the ``--pdf-renderer`` argument. The previous behavior
+ was to select ``--pdf-renderer=hocr``.
+- The "tesseract" PDF renderer is now deprecated, since it can cause
+ problems with Ghostscript on Tesseract 3.05.00
+- The "tess4" PDF renderer has been renamed to "sandwich". "tess4" is
+ now a deprecated alias for "sandwich".
v5.1
-----
-
-- Files with pages larger than 200" (5080 mm) in either dimension are now supported with ``--output-type=pdf`` with the page size preserved (in the PDF specification this feature is called UserUnit scaling). Due to Ghostscript limitations this is not available in conjunction with PDF/A output.
+====
+- Files with pages larger than 200" (5080 mm) in either dimension are
+ now supported with ``--output-type=pdf`` with the page size preserved
+ (in the PDF specification this feature is called UserUnit scaling).
+ Due to Ghostscript limitations this is not available in conjunction
+ with PDF/A output.
v5.0.1
-------
+======
-- Fixed issue `#169 `_, exception due to failure to create sidecar text files on some versions of Tesseract 3.04, including the jbarlow83/ocrmypdf Docker image
+- Fixed issue
+ `#169 `__,
+ exception due to failure to create sidecar text files on some
+ versions of Tesseract 3.04, including the jbarlow83/ocrmypdf Docker
+ image
v5.0
-----
+====
-- Backward incompatible changes
+- 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 `_.
-- Fixed issue `#143 `_, added ``--quiet`` to suppress "INFO" messages
-- Fixed issue `#164 `_, a typo
-- Removed the command line parameters ``-n`` and ``--just-print`` since they have not worked for some time (reported as Ubuntu bug `#1687308 `_)
+- 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 `__.
+
+- Fixed issue
+ `#143 `__, added
+ ``--quiet`` to suppress "INFO" messages
+
+- Fixed issue
+ `#164 `__, a typo
+
+- Removed the command line parameters ``-n`` and ``--just-print`` since
+ they have not worked for some time (reported as Ubuntu bug
+ `#1687308 `__)
v4.5.6
-------
+======
-- Fixed issue `#156 `_, 'NoneType' object has no attribute 'getObject' on pages with no optional /Contents record. This should resolve all issues related to pages with no /Contents record.
-- Fixed issue `#158 `_, ocrmypdf now stops and terminates if Ghostscript fails on an intermediate step, as it is not possible to proceed.
-- Fixed issue `#160 `_, exception thrown on certain invalid arguments instead of error message
+- Fixed issue
+ `#156 `__,
+ 'NoneType' object has no attribute 'getObject' on pages with no
+ optional /Contents record. This should resolve all issues related to
+ pages with no /Contents record.
+- Fixed issue
+ `#158 `__, ocrmypdf
+ now stops and terminates if Ghostscript fails on an intermediate
+ step, as it is not possible to proceed.
+- Fixed issue
+ `#160 `__,
+ exception thrown on certain invalid arguments instead of error
+ message
v4.5.5
-------
+======
-- Automated update of macOS homebrew tap
-- Fixed issue `#154 `_, KeyError '/Contents' when searching for text on blank pages that have no /Contents record. Note: incomplete fix for this issue.
+- Automated update of macOS homebrew tap
+- Fixed issue
+ `#154 `__, KeyError
+ '/Contents' when searching for text on blank pages that have no
+ /Contents record. Note: incomplete fix for this issue.
v4.5.4
-------
+======
-- Fix ``--skip-big`` raising an exception if a page contains no images (`#152 `_) (thanks to @TomRaz)
-- Fix an issue where pages with no images might trigger "cannot write mode P as JPEG" (`#151 `_)
+- Fix ``--skip-big`` raising an exception if a page contains no images
+ (`#152 `__) (thanks
+ to @TomRaz)
+- Fix an issue where pages with no images might trigger "cannot write
+ mode P as JPEG"
+ (`#151 `__)
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
-----
+====
-- 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
+- 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