13
13
?>
14
14
--FILE--
15
15
<?php
16
- $ cwd = __DIR__ ;
17
- $ infile = $ cwd . '/girl.avif ' ;
18
- $ outfile = $ cwd . '/test.avif ' ;
16
+
17
+ require_once __DIR__ . '/similarity.inc ' ;
18
+
19
+ $ infile = __DIR__ . '/girl.avif ' ;
20
+ $ outfile = __DIR__ . '/test.avif ' ;
19
21
20
22
echo 'Decoding AVIF image: ' ;
21
23
$ img = imagecreatefromavif ($ infile );
39
41
echo 'Encoding AVIF with illegal speed: ' ;
40
42
echo_status (imageavif ($ img , $ outfile , 70 , 1234 ));
41
43
44
+ echo 'Encoding AVIF losslessly... ' ;
45
+ echo_status (imageavif ($ img , $ outfile , 100 , 0 ));
46
+
47
+ echo "Decoding the AVIF we just wrote... \n" ;
48
+ $ img_from_avif = imagecreatefromavif ($ outfile );
49
+
50
+ // Note we could also forgive a certain number of pixel differences.
51
+ // With the current test image, we just didn't need to.
52
+ echo 'How many pixels are different in the two images? ' ;
53
+ print_r (calc_image_dissimilarity ($ img , $ img_from_avif ));
54
+
42
55
unlink ($ outfile );
43
56
57
+
44
58
function echo_status ($ success ) {
45
59
echo $ success ? "ok \n" : "failed \n" ;
46
60
}
@@ -53,3 +67,6 @@ Encoding AVIF at quality 70 with speed 5: ok
53
67
Encoding AVIF with default quality: ok
54
68
Encoding AVIF with illegal quality: ok
55
69
Encoding AVIF with illegal speed: ok
70
+ Encoding AVIF losslessly... ok
71
+ Decoding the AVIF we just wrote...
72
+ How many pixels are different in the two images? 0
0 commit comments