Can you confirm if the following (untested) diff fixes the problem?
diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py
index 31b4043..f11df03 100755
--- a/src/img2pdf_test.py
+++ b/src/img2pdf_test.py
@@ -113,6 +113,12 @@ except subprocess.CalledProcessError:
if not HAVE_JP2:
warnings.warn("imagemagick has no jpeg 2000 support, skipping certain checks...")
+# the result of compare -metric PSNR is either just a floating point value or a
+# floating point value following by the same value multiplied by 0.01,
+# surrounded in parenthesis since ImagemMagick 7.1.0-48:
+# https://github.com/ImageMagick/ImageMagick/commit/751829cd4c911d7a42953a47c1f73068d9e7da2f
+psnr_re = re.compile(rb"((?:inf|(?:0|[1-9][0-9]+)(?:.[0-9]+)?))(?: \([0-9.]+\))?")
+
###############################################################################
# HELPER FUNCTIONS #
###############################################################################
@@ -345,7 +351,10 @@ def compare(im1, im2, exact, icc, cmyk):
stderr=subprocess.PIPE,
).stderr
assert psnr != b"0"
- psnr = float(psnr.strip(b"0"))
+ assert psnr != b"0 (0)"
+ assert psnr_re.fullmatch(psnr) is not None, psnr
+ psnr = psnr_re.fullmatch(psnr).group(1)
+ psnr = float(psnr)
assert psnr != 0 # or otherwise we would use the exact variant
assert psnr > 50
@@ -501,7 +510,9 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
stderr=subprocess.PIPE,
).stderr
assert psnr != b"0"
- psnr = float(psnr.strip(b"0"))
+ assert psnr != b"0 (0)"
+ psnr = psnr_re.fullmatch(psnr).group(1)
+ psnr = float(psnr)
assert psnr != 0 # or otherwise we would use the exact variant
assert psnr > 50
(tmpdir / "images-000.png").unlink()
I suspect that this is the culprit:
https://github.com/ImageMagick/ImageMagick/commit/751829cd4c911d7a42953a47c1f73068d9e7da2f
Can you confirm if the following (untested) diff fixes the problem?
```patch
diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py
index 31b4043..f11df03 100755
--- a/src/img2pdf_test.py
+++ b/src/img2pdf_test.py
@@ -113,6 +113,12 @@ except subprocess.CalledProcessError:
if not HAVE_JP2:
warnings.warn("imagemagick has no jpeg 2000 support, skipping certain checks...")
+# the result of compare -metric PSNR is either just a floating point value or a
+# floating point value following by the same value multiplied by 0.01,
+# surrounded in parenthesis since ImagemMagick 7.1.0-48:
+# https://github.com/ImageMagick/ImageMagick/commit/751829cd4c911d7a42953a47c1f73068d9e7da2f
+psnr_re = re.compile(rb"((?:inf|(?:0|[1-9][0-9]+)(?:.[0-9]+)?))(?: \([0-9.]+\))?")
+
###############################################################################
# HELPER FUNCTIONS #
###############################################################################
@@ -345,7 +351,10 @@ def compare(im1, im2, exact, icc, cmyk):
stderr=subprocess.PIPE,
).stderr
assert psnr != b"0"
- psnr = float(psnr.strip(b"0"))
+ assert psnr != b"0 (0)"
+ assert psnr_re.fullmatch(psnr) is not None, psnr
+ psnr = psnr_re.fullmatch(psnr).group(1)
+ psnr = float(psnr)
assert psnr != 0 # or otherwise we would use the exact variant
assert psnr > 50
@@ -501,7 +510,9 @@ def compare_pdfimages_png(tmpdir, img, pdf, exact=True, icc=False):
stderr=subprocess.PIPE,
).stderr
assert psnr != b"0"
- psnr = float(psnr.strip(b"0"))
+ assert psnr != b"0 (0)"
+ psnr = psnr_re.fullmatch(psnr).group(1)
+ psnr = float(psnr)
assert psnr != 0 # or otherwise we would use the exact variant
assert psnr > 50
(tmpdir / "images-000.png").unlink()
```
Thanks a lot for reporting this issue and helping with fixing it!
In Debian we do not have enough person-power to maintain imagemagick these days so we lack severely behind.
Does NixOS package every new imagemagick version and run tests for all packages depending on it?
I would appreciate more bug reports of this sort in the future! :)
Thanks a lot for reporting this issue and helping with fixing it!
In Debian we do not have enough person-power to maintain imagemagick these days so we lack severely behind.
Does NixOS package every new imagemagick version and run tests for all packages depending on it?
I would appreciate more bug reports of this sort in the future! :)
Yes, NixOS unstable is a rolling distro and we are usually pretty quick to update everything. We also run python tests when available, because the ecosystem is somewhat fragile for distros where there can be only one version of a python package. We can't test every reverse dependency of imagemagick immediately, but we'll notice these kinds of breakages quickly through appliations like paperless-ngx.
Thanks for the quick turn-around, we'll happily report more issues when we come across them.
Yes, NixOS unstable is a rolling distro and we are usually pretty quick to update everything. We also run python tests when available, because the ecosystem is somewhat fragile for distros where there can be only one version of a python package. We can't test every reverse dependency of imagemagick immediately, but we'll notice these kinds of breakages quickly through appliations like paperless-ngx.
Thanks for the quick turn-around, we'll happily report more issues when we come across them.
We recently upgraded imagemagick in NixOS unstable from 7.1.0-47 to 7.1.0-48 and img2pdf 0.4.4 has multiple tests failing in the same way.
I suspect that this is the culprit:
751829cd4c
Can you confirm if the following (untested) diff fixes the problem?
With that patch applied we arrive here:
Oh wow, that imagemagick release is wild! I think that this commit might've fixed the in-exact cmyk issues:
c1ca247654
Can you try this new patch?
Different errors now:
Aha, of course! Here is another patch:
Yes, all good now! Thanks!
Thanks a lot for reporting this issue and helping with fixing it!
In Debian we do not have enough person-power to maintain imagemagick these days so we lack severely behind.
Does NixOS package every new imagemagick version and run tests for all packages depending on it?
I would appreciate more bug reports of this sort in the future! :)
Yes, NixOS unstable is a rolling distro and we are usually pretty quick to update everything. We also run python tests when available, because the ecosystem is somewhat fragile for distros where there can be only one version of a python package. We can't test every reverse dependency of imagemagick immediately, but we'll notice these kinds of breakages quickly through appliations like paperless-ngx.
Thanks for the quick turn-around, we'll happily report more issues when we come across them.