1{
2 image,
3 invisible-watermark,
4 opencv4,
5 python3,
6 runCommand,
7 stdenvNoCC,
8}:
9
10# This test checks if the python code shown in the README works correctly
11
12let
13 message = "fnörd1";
14 method = "dwtDct";
15
16 pythonWithPackages = python3.withPackages (
17 pp: with pp; [
18 invisible-watermark
19 opencv4
20 ]
21 );
22 pythonInterpreter = pythonWithPackages.interpreter;
23
24 encode = stdenvNoCC.mkDerivation {
25 name = "encode";
26 realBuilder = pythonInterpreter;
27 args = [ ./encode.py ];
28 inherit image message method;
29 };
30
31 decode = stdenvNoCC.mkDerivation {
32 name = "decode";
33 realBuilder = pythonInterpreter;
34 args = [ ./decode.py ];
35 inherit method;
36 image = "${encode}/test_wm.png";
37 num_bits = (builtins.stringLength message) * 8;
38 };
39in
40runCommand "invisible-watermark-test-python" { } ''
41 decoded_message="$(cat '${decode}')"
42 if [ '${message}' != "$decoded_message" ]; then
43 echo "invisible-watermark did not decode the watermark correctly."
44 echo "The original message was ${message} but the decoded message was $decoded_message."
45 exit 1
46 fi
47 touch "$out"
48''