Skip to content

Commit

Permalink
Windows specific prefix check (magick)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexm96 committed Apr 25, 2024
1 parent 925953f commit 8bbc536
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/invoice2data/input/tesseract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

import platform
import shutil
import tempfile
import mimetypes
Expand Down Expand Up @@ -32,17 +32,21 @@ def to_text(path: str, area_details: dict = None):
"""

# Check for dependencies. Needs Tesseract and Imagemagick installed.
current_platform = platform.platform()
if current_platform.startswith("win32"):
convert_command_prefix = "magick"
else:
convert_command_prefix = "convert"
if not shutil.which("tesseract"):
raise EnvironmentError("tesseract not installed.")
if not shutil.which("convert"):
if not shutil.which(convert_command_prefix):
raise EnvironmentError("imagemagick not installed.")

language = get_languages()
logger.debug("tesseract language arg is, %s", language)
timeout = 180

# convert the (multi-page) pdf file to a 300dpi png
convert = [
convert = [convert_command_prefix] + [
"convert",
"-units",
"PixelsPerInch",
Expand Down

0 comments on commit 8bbc536

Please sign in to comment.