1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 numpy,
6 scipy,
7 pillow,
8 pywavelets,
9 setuptools,
10}:
11
12buildPythonPackage rec {
13 pname = "pyssim";
14 version = "0.7.1";
15 pyproject = true;
16
17 # PyPI tarball doesn't contain test images so let's use GitHub
18 src = fetchFromGitHub {
19 owner = "jterrace";
20 repo = "pyssim";
21 tag = "v${version}";
22 hash = "sha256-6393EATaXg12pYXPaHty+8LepUM6kgtZ0zSjZ1Izytg=";
23 };
24
25 build-system = [
26 setuptools
27 ];
28
29 dependencies = [
30 numpy
31 scipy
32 pillow
33 pywavelets
34 ];
35
36 # Tests are copied from .github/workflows/python-package.yml
37 checkPhase = ''
38 runHook preCheck
39 $out/bin/pyssim test-images/test1-1.png test-images/test1-1.png | grep 1
40 $out/bin/pyssim test-images/test1-1.png test-images/test1-2.png | grep 0.998
41 $out/bin/pyssim test-images/test1-1.png "test-images/*" | grep -E " 1| 0.998| 0.672| 0.648" | wc -l | grep 4
42 $out/bin/pyssim --cw --width 128 --height 128 test-images/test1-1.png test-images/test1-1.png | grep 1
43 $out/bin/pyssim --cw --width 128 --height 128 test-images/test3-orig.jpg test-images/test3-rot.jpg | grep 0.938
44 runHook postCheck
45 '';
46
47 meta = {
48 description = "Module for computing Structured Similarity Image Metric (SSIM) in Python";
49 mainProgram = "pyssim";
50 homepage = "https://github.com/jterrace/pyssim";
51 changelog = "https://github.com/jterrace/pyssim/blob/${src.tag}/CHANGES.md";
52 license = lib.licenses.mit;
53 maintainers = with lib.maintainers; [ jluttine ];
54 };
55}