2021-09-22 15:38:15 +00:00
|
|
|
diff --git a/src/ocrmypdf/_exec/ghostscript.py b/src/ocrmypdf/_exec/ghostscript.py
|
2024-01-13 08:15:51 +00:00
|
|
|
index 94eec244..4bb15db9 100644
|
2021-09-22 15:38:15 +00:00
|
|
|
--- a/src/ocrmypdf/_exec/ghostscript.py
|
|
|
|
+++ b/src/ocrmypdf/_exec/ghostscript.py
|
2024-01-13 08:15:51 +00:00
|
|
|
@@ -31,7 +31,7 @@ COLOR_CONVERSION_STRATEGIES = frozenset(
|
|
|
|
]
|
|
|
|
)
|
2023-10-09 19:29:22 +00:00
|
|
|
# Ghostscript executable - gswin32c is not supported
|
|
|
|
-GS = 'gswin64c' if os.name == 'nt' else 'gs'
|
2021-09-22 15:38:15 +00:00
|
|
|
+GS = '@gs@'
|
|
|
|
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2021-09-22 15:38:15 +00:00
|
|
|
diff --git a/src/ocrmypdf/_exec/jbig2enc.py b/src/ocrmypdf/_exec/jbig2enc.py
|
2024-01-02 11:29:13 +00:00
|
|
|
index 5a34a95a..5ee1b333 100644
|
2021-09-22 15:38:15 +00:00
|
|
|
--- a/src/ocrmypdf/_exec/jbig2enc.py
|
|
|
|
+++ b/src/ocrmypdf/_exec/jbig2enc.py
|
2023-10-09 19:29:22 +00:00
|
|
|
@@ -14,7 +14,7 @@ from ocrmypdf.subprocess import get_version, run
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
def version() -> Version:
|
|
|
|
- return Version(get_version('jbig2', regex=r'jbig2enc (\d+(\.\d+)*).*'))
|
|
|
|
+ return Version(get_version('@jbig2@', regex=r'jbig2enc (\d+(\.\d+)*).*'))
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def available():
|
2023-10-09 19:29:22 +00:00
|
|
|
@@ -27,7 +27,7 @@ def available():
|
2021-09-22 15:38:15 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
def convert_group(cwd, infiles, out_prefix, threshold):
|
2021-09-22 15:38:15 +00:00
|
|
|
args = [
|
|
|
|
- 'jbig2',
|
|
|
|
+ '@jbig2@',
|
|
|
|
'-b',
|
|
|
|
out_prefix,
|
2023-10-09 19:29:22 +00:00
|
|
|
'--symbol-mode', # symbol mode (lossy)
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -44,7 +44,7 @@ def convert_group(cwd, infiles, out_prefix, threshold):
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
def convert_single(cwd, infile, outfile, threshold):
|
2023-10-09 19:29:22 +00:00
|
|
|
- args = ['jbig2', '--pdf', '-t', str(threshold), infile]
|
|
|
|
+ args = ['@jbig2@', '--pdf', '-t', str(threshold), infile]
|
2021-09-22 15:38:15 +00:00
|
|
|
with open(outfile, 'wb') as fstdout:
|
|
|
|
proc = run(args, cwd=cwd, stdout=fstdout, stderr=PIPE)
|
|
|
|
proc.check_returncode()
|
|
|
|
diff --git a/src/ocrmypdf/_exec/pngquant.py b/src/ocrmypdf/_exec/pngquant.py
|
2024-01-02 11:29:13 +00:00
|
|
|
index 5b8600d0..fcad771b 100644
|
2021-09-22 15:38:15 +00:00
|
|
|
--- a/src/ocrmypdf/_exec/pngquant.py
|
|
|
|
+++ b/src/ocrmypdf/_exec/pngquant.py
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -15,7 +15,7 @@ from ocrmypdf.subprocess import get_version, run
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
def version() -> Version:
|
|
|
|
- return Version(get_version('pngquant', regex=r'(\d+(\.\d+)*).*'))
|
|
|
|
+ return Version(get_version('@pngquant@', regex=r'(\d+(\.\d+)*).*'))
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def available():
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -37,7 +37,7 @@ def quantize(input_file: Path, output_file: Path, quality_min: int, quality_max:
|
|
|
|
"""
|
|
|
|
with open(input_file, 'rb') as input_stream:
|
2021-09-22 15:38:15 +00:00
|
|
|
args = [
|
|
|
|
- 'pngquant',
|
|
|
|
+ '@pngquant@',
|
|
|
|
'--force',
|
|
|
|
'--skip-if-larger',
|
|
|
|
'--quality',
|
|
|
|
diff --git a/src/ocrmypdf/_exec/tesseract.py b/src/ocrmypdf/_exec/tesseract.py
|
2024-01-02 11:29:13 +00:00
|
|
|
index fab92bb1..78b634a7 100644
|
2021-09-22 15:38:15 +00:00
|
|
|
--- a/src/ocrmypdf/_exec/tesseract.py
|
|
|
|
+++ b/src/ocrmypdf/_exec/tesseract.py
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -95,7 +95,7 @@ class TesseractVersion(Version):
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
def version() -> Version:
|
|
|
|
- return TesseractVersion(get_version('tesseract', regex=r'tesseract\s(.+)'))
|
|
|
|
+ return TesseractVersion(get_version('@tesseract@', regex=r'tesseract\s(.+)'))
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
def has_thresholding() -> bool:
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -113,7 +113,7 @@ def get_languages() -> set[str]:
|
2021-09-22 15:38:15 +00:00
|
|
|
msg += output
|
|
|
|
return msg
|
|
|
|
|
|
|
|
- args_tess = ['tesseract', '--list-langs']
|
|
|
|
+ args_tess = ['@tesseract@', '--list-langs']
|
|
|
|
try:
|
|
|
|
proc = run(
|
|
|
|
args_tess,
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -135,7 +135,7 @@ def get_languages() -> set[str]:
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
def tess_base_args(langs: list[str], engine_mode: int | None) -> list[str]:
|
2021-09-22 15:38:15 +00:00
|
|
|
- args = ['tesseract']
|
|
|
|
+ args = ['@tesseract@']
|
|
|
|
if langs:
|
|
|
|
args.extend(['-l', '+'.join(langs)])
|
|
|
|
if engine_mode is not None:
|
|
|
|
diff --git a/src/ocrmypdf/_exec/unpaper.py b/src/ocrmypdf/_exec/unpaper.py
|
2024-01-02 11:29:13 +00:00
|
|
|
index 493d9b3a..578c2dda 100644
|
2021-09-22 15:38:15 +00:00
|
|
|
--- a/src/ocrmypdf/_exec/unpaper.py
|
|
|
|
+++ b/src/ocrmypdf/_exec/unpaper.py
|
2024-01-02 11:29:13 +00:00
|
|
|
@@ -70,7 +70,7 @@ class UnpaperImageTooLargeError(Exception):
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
def version() -> Version:
|
|
|
|
- return Version(get_version('unpaper'))
|
|
|
|
+ return Version(get_version('@unpaper@'))
|
2021-09-22 15:38:15 +00:00
|
|
|
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
@contextmanager
|
|
|
|
@@ -92,7 +92,7 @@ def _setup_unpaper_io(input_file: Path) -> Iterator[tuple[Path, Path, Path]]:
|
2022-06-26 10:26:21 +00:00
|
|
|
def run_unpaper(
|
2022-08-12 12:06:08 +00:00
|
|
|
input_file: Path, output_file: Path, *, dpi: DecFloat, mode_args: list[str]
|
2021-09-22 15:38:15 +00:00
|
|
|
) -> None:
|
|
|
|
- args_unpaper = ['unpaper', '-v', '--dpi', str(round(dpi, 6))] + mode_args
|
|
|
|
+ args_unpaper = ['@unpaper@', '-v', '--dpi', str(round(dpi, 6))] + mode_args
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
with _setup_unpaper_io(input_file) as (input_png, output_pnm, tmpdir):
|
2022-06-26 10:26:21 +00:00
|
|
|
# To prevent any shenanigans from accepting arbitrary parameters in
|