Make tests work with ImageMagick 6 and 7, fixes #111 #117
3 changed files with 23 additions and 50 deletions
|
@ -13,7 +13,6 @@ matrix:
|
|||
- netpbm
|
||||
- ghostscript
|
||||
- mupdf-tools
|
||||
- icc-profiles-free
|
||||
- name: "python 3.9 Windows"
|
||||
os: windows
|
||||
language: shell # 'language: python' is an error on Travis CI Windows
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[![Travis Status](https://travis-ci.org/josch/img2pdf.svg?branch=master)](https://travis-ci.org/josch/img2pdf)
|
||||
[![Appveyor Status](https://ci.appveyor.com/api/projects/status/2kws3wkqvi526llj/branch/master?svg=true)](https://ci.appveyor.com/project/josch/img2pdf/branch/master)
|
||||
[![Travis Status](https://travis-ci.com/josch/img2pdf.svg?branch=main)](https://app.travis-ci.com/josch/img2pdf)
|
||||
[![Appveyor Status](https://ci.appveyor.com/api/projects/status/2kws3wkqvi526llj/branch/main?svg=true)](https://ci.appveyor.com/project/josch/img2pdf/branch/main)
|
||||
|
||||
img2pdf
|
||||
=======
|
||||
|
|
|
@ -20,6 +20,21 @@ import warnings
|
|||
import json
|
||||
import pathlib
|
||||
|
||||
ICC_PROFILE = None
|
||||
ICC_PROFILE_PATHS = (
|
||||
# Debian
|
||||
"/usr/share/color/icc/ghostscript/srgb.icc",
|
||||
# Fedora
|
||||
"/usr/share/ghostscript/iccprofiles/srgb.icc",
|
||||
# Archlinux and Gentoo
|
||||
"/usr/share/ghostscript/*/iccprofiles/srgb.icc",
|
||||
)
|
||||
for glob in ICC_PROFILE_PATHS:
|
||||
for path in pathlib.Path("/").glob(glob.lstrip("/")):
|
||||
if path.is_file():
|
||||
ICC_PROFILE = path
|
||||
break
|
||||
|
||||
HAVE_MUTOOL = True
|
||||
try:
|
||||
ver = subprocess.check_output(["mutool", "-v"], stderr=subprocess.STDOUT)
|
||||
|
@ -304,11 +319,9 @@ def compare(im1, im2, exact, icc, cmyk):
|
|||
else:
|
||||
iccargs = []
|
||||
if icc:
|
||||
profile = "/usr/share/color/icc/sRGB.icc"
|
||||
if not os.path.isfile(profile):
|
||||
warnings.warn(profile + " not present, skipping checks...")
|
||||
return
|
||||
iccargs = ["-profile", profile]
|
||||
if ICC_PROFILE is None:
|
||||
pytest.skip("Could not locate an ICC profile")
|
||||
iccargs = ["-profile", ICC_PROFILE]
|
||||
psnr = subprocess.run(
|
||||
["compare"]
|
||||
+ iccargs
|
||||
|
@ -421,10 +434,8 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
|
|||
)
|
||||
else:
|
||||
if icc:
|
||||
profile = "/usr/share/color/icc/ghostscript/srgb.icc"
|
||||
if not os.path.isfile(profile):
|
||||
warnings.warn(profile + " not present, skipping checks...")
|
||||
return
|
||||
if ICC_PROFILE is None:
|
||||
pytest.skip("Could not locate an ICC profile")
|
||||
psnr = subprocess.run(
|
||||
[
|
||||
"compare",
|
||||
|
@ -432,7 +443,7 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
|
|||
"PSNR",
|
||||
"(",
|
||||
"-profile",
|
||||
profile,
|
||||
ICC_PROFILE,
|
||||
"-depth",
|
||||
"8",
|
||||
str(img),
|
||||
|
@ -1154,7 +1165,6 @@ def png_rgb8_img(tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -1204,7 +1214,6 @@ def png_rgb16_img(tmp_normal16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig")
|
||||
== "16"
|
||||
|
@ -1258,7 +1267,6 @@ def png_rgba8_img(tmp_path_factory, tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -1309,7 +1317,6 @@ def png_rgba16_img(tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig")
|
||||
== "16"
|
||||
|
@ -1376,7 +1383,6 @@ def png_gray8a_img(tmp_path_factory, tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -1439,7 +1445,6 @@ def png_gray16a_img(tmp_path_factory, tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig")
|
||||
== "16"
|
||||
|
@ -1494,7 +1499,6 @@ def png_interlaced_img(tmp_path_factory, tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -1546,7 +1550,6 @@ def png_gray1_img(tmp_path_factory, tmp_gray1_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "1"
|
||||
), str(identify)
|
||||
|
@ -1597,7 +1600,6 @@ def png_gray2_img(tmp_path_factory, tmp_gray2_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "2"
|
||||
), str(identify)
|
||||
|
@ -1648,7 +1650,6 @@ def png_gray4_img(tmp_path_factory, tmp_gray4_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "4"
|
||||
), str(identify)
|
||||
|
@ -1699,7 +1700,6 @@ def png_gray8_img(tmp_path_factory, tmp_gray8_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -1750,7 +1750,6 @@ def png_gray16_img(tmp_path_factory, tmp_gray16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig")
|
||||
== "16"
|
||||
|
@ -1802,7 +1801,6 @@ def png_palette1_img(tmp_path_factory, tmp_palette1_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "1"
|
||||
), str(identify)
|
||||
|
@ -1853,7 +1851,6 @@ def png_palette2_img(tmp_path_factory, tmp_palette2_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "2"
|
||||
), str(identify)
|
||||
|
@ -1904,7 +1901,6 @@ def png_palette4_img(tmp_path_factory, tmp_palette4_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "4"
|
||||
), str(identify)
|
||||
|
@ -1955,7 +1951,6 @@ def png_palette8_img(tmp_path_factory, tmp_palette8_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
@ -2265,7 +2260,6 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("quantum:format")
|
||||
== "floating-point"
|
||||
|
@ -2318,7 +2312,6 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2376,7 +2369,6 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2424,7 +2416,6 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2477,7 +2468,6 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2530,7 +2520,6 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2579,7 +2568,6 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2628,7 +2616,6 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
|
||||
), str(identify)
|
||||
|
@ -2677,7 +2664,6 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
|
||||
), str(identify)
|
||||
|
@ -2724,7 +2710,6 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2772,7 +2757,6 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2820,7 +2804,6 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2868,7 +2851,6 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2916,7 +2898,6 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -2968,7 +2949,6 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3009,7 +2989,6 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3059,7 +3038,6 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3108,7 +3086,6 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3157,7 +3134,6 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3205,7 +3181,6 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
|
||||
), str(identify)
|
||||
|
@ -3735,7 +3710,6 @@ def png_icc_img(tmp_icc_png):
|
|||
"x": 0,
|
||||
"y": 0,
|
||||
}, str(identify)
|
||||
assert identify[0]["image"].get("compression") == "Zip", str(identify)
|
||||
assert (
|
||||
identify[0]["image"].get("properties", {}).get("png:IHDR.bit-depth-orig") == "8"
|
||||
), str(identify)
|
||||
|
|
Loading…
Reference in a new issue