forked from josch/img2pdf
try to use json output instead of identify -verbose
This commit is contained in:
parent
fbb51d9083
commit
c506cf0b8d
1 changed files with 18 additions and 22 deletions
|
@ -17,6 +17,7 @@ from PIL import Image
|
||||||
import decimal
|
import decimal
|
||||||
from packaging.version import parse as parse_version
|
from packaging.version import parse as parse_version
|
||||||
import warnings
|
import warnings
|
||||||
|
import json
|
||||||
|
|
||||||
HAVE_MUTOOL = True
|
HAVE_MUTOOL = True
|
||||||
try:
|
try:
|
||||||
|
@ -2360,28 +2361,23 @@ def tiff_ccitt_nometa2_img(tmp_path_factory, tmp_gray1_png):
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
["tiffset", "-u", "278", str(in_img)]
|
["tiffset", "-u", "278", str(in_img)]
|
||||||
) # remove RowsPerStrip (278)
|
) # remove RowsPerStrip (278)
|
||||||
identify = subprocess.check_output(["identify", "-verbose", str(in_img)])
|
identify = json.loads(subprocess.check_output(["convert", str(in_img), "json:"]))
|
||||||
expected = [
|
assert len(identify) == 1
|
||||||
r"^ Format: TIFF \(Tagged Image File Format\)$",
|
assert "image" in identify[0]
|
||||||
r"^ Mime type: image/tiff$",
|
assert identify[0]["image"]["format"] == "TIFF"
|
||||||
r"^ Geometry: 60x60\+0\+0$",
|
assert identify[0]["image"]["formatDescription"] == "Tagged Image File Format"
|
||||||
r"^ Colorspace: Gray$",
|
assert identify[0]["image"]["mimeType"] == "image/tiff"
|
||||||
r"^ Type: Bilevel$",
|
assert identify[0]["image"]["geometry"] == {'width': 60, 'height': 60, 'x': 0, 'y': 0}
|
||||||
r"^ Endiann?ess: LSB$",
|
assert identify[0]["image"]["units"] == "PixelsPerInch"
|
||||||
r"^ Depth: 1-bit$",
|
assert identify[0]["image"]["type"] == "Bilevel"
|
||||||
r"^ Page geometry: 60x60\+0\+0$",
|
assert identify[0]["image"]["endianess"] == "Undefined" # FIXME: should be LSB
|
||||||
r"^ Compression: Group4$",
|
assert identify[0]["image"]["colorspace"] == "Gray"
|
||||||
r"^ tiff:alpha: unspecified$",
|
assert identify[0]["image"]["depth"] == 1
|
||||||
r"^ tiff:endian: lsb$",
|
assert identify[0]["image"]["compression"] == "Group4"
|
||||||
r"^ tiff:photometric: min-is-white$",
|
assert identify[0]["image"]["properties"]["tiff:alpha"] == "unspecified"
|
||||||
]
|
assert identify[0]["image"]["properties"]["tiff:endian"] == "lsb"
|
||||||
for e in expected:
|
assert identify[0]["image"]["properties"]["tiff:photometric"] == "min-is-white"
|
||||||
assert re.search(e, identify.decode("utf8"), re.MULTILINE), identify.decode(
|
assert "tiff:rows-per-strip" not in identify[0]["image"]["properties"]
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
unexpected = [" tiff:rows-per-strip: "]
|
|
||||||
for e in unexpected:
|
|
||||||
assert e not in identify.decode("utf8")
|
|
||||||
tiffinfo = subprocess.check_output(["tiffinfo", str(in_img)])
|
tiffinfo = subprocess.check_output(["tiffinfo", str(in_img)])
|
||||||
expected = [
|
expected = [
|
||||||
r"^ Image Width: 60 Image Length: 60",
|
r"^ Image Width: 60 Image Length: 60",
|
||||||
|
|
Loading…
Reference in a new issue