forked from rsmbl/Resemble.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
197 lines (185 loc) · 6.57 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Resemble.js : Image analysis</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="libs/twitter-bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="demoassets/resemble.css?v1">
</head>
<body>
<div class="container">
<header>
<div class="page-header">
<h1>Resemble.js : Image analysis and comparison</h1>
</div>
</header>
<section role="main">
<div class="row">
<div class="span12">
<div class="hero-unit">
<div class="row">
<div class="span6">
<p>
<div id="drop-zone" class="drop-zone">
Drop image here.
</div>
</p>
</div>
<div class="span4">
<h2>What is this?</h2>
<p>
Resemble.js analyses and compares images with HTML5 canvas and JavaScript.
</p>
<p>
<strong>Try it for yourself.</strong>
</p>
<div id="image-data" style="display:none">
RGB
<div class="progress progress-danger">
<div id="red" class="bar" style="width: 0%;"></div>
</div>
<div class="progress progress-success">
<div id="green" class="bar" style="width: 0%;"></div>
</div>
<div class="progress">
<div id="blue" class="bar" style="width: 0%;"></div>
</div>
Brightness
<div class="progress progress-warning">
<div id="brightness" class="bar" style="width: 0%;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<div class="row">
<div class="span6">
<div id="dropzone1" class="small-drop-zone">
Drop first image
</div>
<div id="dropzone2" class="small-drop-zone">
Drop second image
</div>
</div>
<div class="span6">
<h2>Compare two images?</h2>
<p>
Drop two images on the boxes to the left. The box below will show a generated 'diff' image, pink areas show mismatch. This example best works with two very similar but slightly different images. Try for yourself!
</p>
<p>
Don't have any images to compare? <button class="btn" id="example-images">Use example images</button>
</p>
<div id="image-diff" class="small-drop-zone">
Diff will appear here.
</div>
<br/>
<div class="btn-group buttons" style="display:none">
<button class="btn active" id="raw">Ignore nothing</button>
<button class="btn" id="colors">Ignore colors</button>
<button class="btn" id="antialising">Ignore antialiasing</button>
</div>
<br/>
<br/>
<div class="btn-group buttons" style="display:none">
<button class="btn active" id="pink">Pink</button>
<button class="btn" id="yellow">Yellow</button>
</div>
<br/>
<br/>
<div class="btn-group buttons" style="display:none">
<button class="btn active" id="flat">Flat</button>
<button class="btn" id="movement">Movement</button>
<button class="btn" id="flatDifferenceIntensity">Flat with diff intensity</button>
<button class="btn" id="movementDifferenceIntensity">Movement with diff intensity</button>
</div>
<br/>
<br/>
<div class="btn-group buttons" style="display:none">
<button class="btn active" id="opaque">Opaque</button>
<button class="btn" id="transparent">Transparent</button>
</div>
<br/>
<br/>
<div id="diff-results" style="display:none;">
<p>
<strong>The second image is <span id="mismatch"></span>% different compared to the first.
<span id="differentdimensions" style="display:none;">And they have different dimensions.</span></strong>
</p>
<p>
Use the buttons above to change the comparison algorithm. Perhaps you don't care about color? Annoying antialiasing causing too much noise? Resemble.js offers multiple comparison options.
</p>
</div>
<p id="thesame" style="display:none;">
<strong>These images are the same!</strong>
</p>
</div>
</div>
</div>
</div>
<br/><br/>
<div class="row">
<div class="span6">
<h2>Why?</h2>
<p>
Resemble.js can be used for any image analysis and comparison requirement you might have in the browser. However, it has been designed and built for use by the PhantomJS powered visual regression library <a href="https://github.com/Huddle/PhantomCSS" target="_blank">PhantomCSS</a>. PhantomCSS needs to be able to ignore antialiasing as this would cause differences between screenshots derived from different machines.
</p>
<p>
Resemble.js uses the <a href="http://www.w3.org/TR/file-upload/" target="_blank">HTML5 File API</a> to parse image data, and canvas for rendering image diffs.
</p>
<p>
<br/>
<a class="btn btn-large btn-primary" href="https://github.com/Huddle/Resemble.js"><strong>View project on GitHub</strong></a>
</p>
</div>
<div class="span6">
<h2>How can I use it?</h2>
<p>Retrieve basic analysis on image.</p>
<pre>
var api = resemble(fileData).onComplete(function(data){
return data;
/*
{
red: 255,
green: 255,
blue: 255,
brightness: 255
}
*/
});</pre>
<p>Use resemble to compare two images.</p>
<pre>
resemble(file).compareTo(file2).onComplete(function(){
return data;
/*
{
misMatchPercentage : 100, // %
isSameDimensions: true, // or false
getImageDataUrl: function(){}
}
*/
});</pre>
<p>Take a look at the <a href="demoassets/main.js" target="_blank">JavaScript for this demo page</a> from a better example</p>
</div>
</div>
</section>
<footer class="footer">
<p>
Created by <a href="https://github.com/jamescryer" target="_blank">James Cryer</a> and the Huddle development team.
</p>
<p>
The image used in the comparison example was created by <a href="https://twitter.com/Shadowise" target="_blank">Daniel Rajendran</a>
</p>
</footer>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="resemble.js"></script>
<script src="demoassets/main.js"></script>
</body>
</html>