at 24.05-pre 1.7 kB view raw
1{ lib, buildPythonPackage, fetchFromGitHub, numpy, scipy, pillow, fetchpatch }: 2 3buildPythonPackage rec { 4 pname = "pyssim"; 5 version = "0.6"; 6 7 propagatedBuildInputs = [ numpy scipy pillow ]; 8 9 # PyPI tarball doesn't contain test images so let's use GitHub 10 src = fetchFromGitHub { 11 owner = "jterrace"; 12 repo = pname; 13 rev = "v${version}"; 14 sha256 = "sha256-VvxQTvDTDms6Ccyclbf9P0HEQksl5atPPzHuH8yXTmc="; 15 }; 16 17 patches = [ 18 # "Replace Image.ANTIALIAS with Image.LANCZOS" 19 # Image.ANTIALIAS has been removed in Pillow 10.0.0, 20 # the version currently in nixpkgs, 21 # and Image.LANCZOS is a drop-in since Pillow 2.7.0. 22 # https://github.com/jterrace/pyssim/pull/45 23 (fetchpatch { 24 url = "https://github.com/jterrace/pyssim/commit/db4296c12ca9c027eb9cd61b52195a78dfcc6711.patch"; 25 hash = "sha256-wNp47EFtjXv6jIFX25IErXg83ksmGRNFKNeMFS+tP6s="; 26 }) 27 ]; 28 29 # Tests are copied from .travis.yml 30 checkPhase = '' 31 $out/bin/pyssim test-images/test1-1.png test-images/test1-1.png | grep 1 32 $out/bin/pyssim test-images/test1-1.png test-images/test1-2.png | grep 0.998 33 $out/bin/pyssim test-images/test1-1.png "test-images/*" | grep -E " 1| 0.998| 0.672| 0.648" | wc -l | grep 4 34 $out/bin/pyssim --cw --width 128 --height 128 test-images/test1-1.png test-images/test1-1.png | grep 1 35 $out/bin/pyssim --cw --width 128 --height 128 test-images/test3-orig.jpg test-images/test3-rot.jpg | grep 0.938 36 ''; 37 38 meta = with lib; { 39 description = "Module for computing Structured Similarity Image Metric (SSIM) in Python"; 40 homepage = "https://github.com/jterrace/pyssim"; 41 license = licenses.mit; 42 maintainers = with maintainers; [ jluttine ]; 43 }; 44}