1
0
Fork 0
forked from josch/img2pdf

src/img2pdf_test.py: replace jpg_img check by json output

This commit is contained in:
Johannes 'josch' Schauer 2020-08-05 08:11:39 +02:00
parent 67dca425d1
commit 7da0a00ef3
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -783,21 +783,33 @@ def tmp_palette8_png(tmp_path_factory, alpha):
def jpg_img(tmp_path_factory, tmp_normal_png): def jpg_img(tmp_path_factory, tmp_normal_png):
in_img = tmp_path_factory.mktemp("jpg") / "in.jpg" in_img = tmp_path_factory.mktemp("jpg") / "in.jpg"
subprocess.check_call(["convert", str(tmp_normal_png), str(in_img)]) subprocess.check_call(["convert", str(tmp_normal_png), str(in_img)])
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: JPEG \(Joint Photographic Experts Group JFIF format\)$", # somewhere between imagemagick 6.9.7.4 and 6.9.9.34, the json output was
r"^ Mime type: image/jpeg$", # put into an array, here we cater for the older version containing just
r"^ Geometry: 60x60\+0\+0$", # the bare dictionary
r"^ Colorspace: sRGB$", if "image" in identify:
r"^ Type: TrueColor$", identify = [identify]
r"^ Depth: 8-bit$", assert "image" in identify[0]
r"^ Page geometry: 60x60\+0\+0$", assert identify[0]["image"]["format"] == "JPEG"
r"^ Compression: JPEG$", assert (
] identify[0]["image"]["formatDescription"]
for e in expected: == "Joint Photographic Experts Group JFIF format"
assert re.search(e, identify.decode("utf8"), re.MULTILINE), identify.decode( )
"utf8" assert identify[0]["image"]["mimeType"] == "image/jpeg"
) assert identify[0]["image"]["geometry"] == {
"width": 60,
"height": 60,
"x": 0,
"y": 0,
}
assert identify[0]["image"]["units"] == "Undefined"
assert identify[0]["image"]["type"] == "TrueColor"
assert identify[0]["image"]["endianess"] == "Undefined"
assert identify[0]["image"]["colorspace"] == "sRGB"
assert identify[0]["image"]["depth"] == 8
assert identify[0]["image"]["compression"] == "JPEG"
assert identify[0]["image"]["properties"]["jpeg:colorspace"] == "2"
yield in_img yield in_img
in_img.unlink() in_img.unlink()