You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
8.1 KiB
239 lines
8.1 KiB
<!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"> |
|
|
|
RGBA |
|
<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> |
|
<div class="progress last"> |
|
<div id="alpha" class="bar" style="width: 0%;"></div> |
|
</div> |
|
Black & white |
|
<div class="progress"> |
|
<div id="black" class="bar" style="width: 0%;"></div> |
|
</div> |
|
<div class="progress last"> |
|
<div id="white" 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" id="raw">Ignore nothing</button> |
|
<button class="btn active" id="less">Ignore less</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="original-size">Use original size</button> |
|
<button class="btn" id="same-size">Scale to same size</button> |
|
</div> |
|
|
|
<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 class="btn-group buttons" style="display:none"> |
|
<div class="row"> |
|
<div class="span1"> |
|
<label>Left</label> |
|
<input type="number" class="input-mini" id="x1" value="100" /> |
|
</div> |
|
<div class="span1"> |
|
<label>Top</label> |
|
<input type="number" class="input-mini" id="y1" value="100" /> |
|
</div> |
|
<div class="span1"> |
|
<label>Right</label> |
|
<input type="number" class="input-mini" id="x2" value="400" /> |
|
</div> |
|
<div class="span1"> |
|
<label>Bottom</label> |
|
<input type="number" class="input-mini" id="y2" value="300" /> |
|
</div> |
|
<div class="span2"> |
|
<label> </label> |
|
<button class="btn" id="boundingBox">Set bounding box</button> |
|
</div> |
|
</div> |
|
</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: 100, |
|
green: 100, |
|
blue: 100, |
|
brightness: 100, |
|
alpha: 100, |
|
white: 100, |
|
black: 100 |
|
} |
|
*/ |
|
});</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>
|
|
|