Don't try to run jbig2 when not available

This commit is contained in:
James R. Barlow
2018-05-11 12:42:00 -07:00
parent 3254315127
commit d9bbb80a6b
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -133,7 +133,7 @@ def extract_image(*, doc, pike, root, log, image, xref, jbig2s,
return False
filtdp = filtdps[0]
if bpc == 1 and filtdp[0] != '/JBIG2Decode':
if bpc == 1 and filtdp[0] != '/JBIG2Decode' and jbig2enc.available():
if filtdp[0] == '/CCITTFaxDecode':
data = image.read_raw_bytes()
try:
+10 -1
View File
@@ -22,7 +22,7 @@ import os
import shutil
from . import get_version
from ..exceptions import ExitCode
from ..exceptions import ExitCode, MissingDependencyError
@lru_cache(maxsize=1)
@@ -30,6 +30,15 @@ def version():
return get_version('jbig2enc', regex=r'jbig2enc (\d+(\.\d+)*).*')
@lru_cache(maxsize=1)
def available():
try:
version()
except MissingDependencyError:
return False
return True
def convert_group(*, cwd, infiles, out_prefix):
args = [
'jbig2',