-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.php
55 lines (50 loc) · 1.73 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @author ThaoNv
* compareImages example
*/
include('compareImages.php');
/* Get hash string from image*/
$image1 = 'image1.jpg';
$compareMachine = new compareImages($image1);
$image1Hash = $compareMachine->getHasString();
echo "Image 1: <img src='$image1'/><br/>";
echo 'Image 1 Hash :'.$image1Hash.'<br/>';
/* Compare this image with an other image*/
$image2 = 'image2.jpg';
//$diff = $compareMachine->compareWith($image2); //easy
$image2Hash = $compareMachine->hasStringImage($image2);
$diff = $compareMachine->compareHash($image2Hash);
echo "Image 2: <img src='$image2'/><br/>";
echo 'Image 2 Hash :'.$image2Hash.'<br/>';
echo 'Different rates (image1 Vs image2): '.$diff;
if($diff>11){
echo ' => 2 different image';
}
else{
echo ' => duplicate image';
}
echo '<br/>-------------------------------------------------------------<br/>';
/* Get hash string from image*/
$image3 = 'image3.jpg';
$compareMachine = new compareImages($image3);
$image3Hash = $compareMachine->getHasString();
echo "Image 3: <img src='$image3'/><br/>";
echo 'Image 3 Hash :'.$image3Hash.'<br/>';
/* Compare this image with an other image*/
$image4 = 'image4.jpg';
$image4Hash = $compareMachine->hasStringImage($image4);
$diff = $compareMachine->compareHash($image4Hash);
echo "Image 4: <img src='$image4'/><br/>";
echo 'Image 4 Hash :'.$image4Hash.'<br/>';
echo 'Different rates (image3 Vs image4): '.$diff;
if($diff>11){
echo ' => 2 different image';
}
else{
echo ' => duplicate image';
}
echo '<br/>-------------------------------------------------------------<br/>';
echo 'Different rates (image3 Vs image3): '.$compareMachine->compareWith($image3).'<br/>';
echo 'Different rates (image3 Vs image1): '.$compareMachine->compareWith($image1).'<br/>';
?>