forked from josch/img2pdf
Compare commits
2 commits
56c7c3988d
...
d60b5109e0
Author | SHA1 | Date | |
---|---|---|---|
d60b5109e0 | |||
152f6fb629 |
3 changed files with 23 additions and 13 deletions
|
@ -13,7 +13,6 @@ matrix:
|
||||||
- netpbm
|
- netpbm
|
||||||
- ghostscript
|
- ghostscript
|
||||||
- mupdf-tools
|
- mupdf-tools
|
||||||
- icc-profiles-free
|
|
||||||
- name: "python 3.9 Windows"
|
- name: "python 3.9 Windows"
|
||||||
os: windows
|
os: windows
|
||||||
language: shell # 'language: python' is an error on Travis CI 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)
|
[![Travis Status](https://travis-ci.com/josch/img2pdf.svg?branchinn)](https://travis-ci.com/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)
|
[![Appveyor Status](https://ci.appveyor.com/api/projects/status/2kws3wkqvi526llj/branch/main?svg=true)](https://ci.appveyor.com/project/josch/img2pdf/branch/main)
|
||||||
|
|
||||||
img2pdf
|
img2pdf
|
||||||
=======
|
=======
|
||||||
|
|
|
@ -20,6 +20,21 @@ import warnings
|
||||||
import json
|
import json
|
||||||
import pathlib
|
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
|
HAVE_MUTOOL = True
|
||||||
try:
|
try:
|
||||||
ver = subprocess.check_output(["mutool", "-v"], stderr=subprocess.STDOUT)
|
ver = subprocess.check_output(["mutool", "-v"], stderr=subprocess.STDOUT)
|
||||||
|
@ -304,11 +319,9 @@ def compare(im1, im2, exact, icc, cmyk):
|
||||||
else:
|
else:
|
||||||
iccargs = []
|
iccargs = []
|
||||||
if icc:
|
if icc:
|
||||||
profile = "/usr/share/color/icc/sRGB.icc"
|
if ICC_PROFILE is None:
|
||||||
if not os.path.isfile(profile):
|
pytest.skip("Could not locate an ICC profile")
|
||||||
warnings.warn(profile + " not present, skipping checks...")
|
iccargs = ["-profile", ICC_PROFILE]
|
||||||
return
|
|
||||||
iccargs = ["-profile", profile]
|
|
||||||
psnr = subprocess.run(
|
psnr = subprocess.run(
|
||||||
["compare"]
|
["compare"]
|
||||||
+ iccargs
|
+ iccargs
|
||||||
|
@ -421,10 +434,8 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if icc:
|
if icc:
|
||||||
profile = "/usr/share/color/icc/ghostscript/srgb.icc"
|
if ICC_PROFILE is None:
|
||||||
if not os.path.isfile(profile):
|
pytest.skip("Could not locate an ICC profile")
|
||||||
warnings.warn(profile + " not present, skipping checks...")
|
|
||||||
return
|
|
||||||
psnr = subprocess.run(
|
psnr = subprocess.run(
|
||||||
[
|
[
|
||||||
"compare",
|
"compare",
|
||||||
|
@ -432,7 +443,7 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
|
||||||
"PSNR",
|
"PSNR",
|
||||||
"(",
|
"(",
|
||||||
"-profile",
|
"-profile",
|
||||||
profile,
|
ICC_PROFILE,
|
||||||
"-depth",
|
"-depth",
|
||||||
"8",
|
"8",
|
||||||
str(img),
|
str(img),
|
||||||
|
|
Loading…
Reference in a new issue