Skip to content

Commit

Permalink
Add heif/heic input image support
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarlow83 committed Apr 7, 2024
1 parent 065bddb commit d6342cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
11 changes: 10 additions & 1 deletion docs/maintainers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ installation documentation.

If you maintain a Linux distribution that supports 32-bit x86 or ARM, OCRmyPDF
should continue to work as long as all of its dependencies continue to be
available in 32-bit form. Please note we do not test on 32-bit platforms.
available in 32-bit form. Please note we do not test on 32-bit platforms.

HEIF/HEIC
---------

OCRmyPDF defaults to installing the pi-heif PyPI package, which supports converting
HEIF (High Efficiency Image File Format) images to PDF from the command line.
If your distribution does not have this library available, you can exclude it and
OCRmyPDF will gracefully degrade automatically, losing only support for this
feature.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ readme = "README.md"
license = { text = "MPL-2.0" }
requires-python = ">=3.10"
dependencies = [
"Pillow>=10.0.1",
"deprecation>=2.1.0",
"img2pdf>=0.5",
"packaging>=20",
"pdfminer.six>=20220319",
"pi-heif", # Heif image format - maintainers: if this is removed, it will NOT break
"pikepdf>=8.10.1",
"Pillow>=10.0.1",
"pluggy>=1",
"rich>=13",
]
Expand Down
11 changes: 11 additions & 0 deletions src/ocrmypdf/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,23 @@
from ocrmypdf.pdfinfo import Colorspace, Encoding, PageInfo, PdfInfo
from ocrmypdf.pluginspec import OrientationConfidence

try:
from pi_heif import register_heif_opener
except ImportError:

def register_heif_opener():
pass


T = TypeVar("T")
log = logging.getLogger(__name__)

VECTOR_PAGE_DPI = 400


register_heif_opener()


def triage_image_file(input_file: Path, output_file: Path, options) -> None:
"""Triage the input image file.
Expand Down

0 comments on commit d6342cb

Please sign in to comment.