resemblejs
Advanced tools
Comparing version 2.2.1 to 2.2.2
{ | ||
"name": "resemblejs", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Image analysis and comparison with HTML5", | ||
@@ -5,0 +5,0 @@ "main": "resemble.js", |
Resemble.js | ||
========== | ||
Analyse and compare images with Javascript and HTML5. [Resemble.js Demo](http://huddle.github.com/Resemble.js/) | ||
Analyse and compare images with Javascript and HTML5. [More info & Resemble.js Demo](http://huddle.github.com/Resemble.js/). If you need NodeJS support, take a look at [node-resemble](https://github.com/ddo/node-resemble) | ||
@@ -74,3 +74,4 @@ ![Two image diff examples side-by-side, one pink, one yellow.](https://raw.github.com/Huddle/Resemble.js/master/demoassets/readmeimage.jpg "Visual image comparison") | ||
transparency: 0.3, | ||
largeImageThreshold: 1200 | ||
largeImageThreshold: 1200, | ||
useCrossOrigin: false | ||
}); | ||
@@ -84,4 +85,7 @@ // resembleControl.repaint(); | ||
`useCrossOrigin` is true by default, you might need to set it to false if you're using [Data URIs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs). | ||
-------------------------------------- | ||
Created by [James Cryer](http://github.com/jamescryer) and the Huddle development team. |
@@ -67,8 +67,5 @@ /* | ||
var errorPixelTransformer = errorPixelTransform.flat; | ||
var largeImageThreshold = 1200; | ||
var httpRegex = /^https?:\/\//; | ||
var useCrossOrigin = true; | ||
var document = typeof window != "undefined" ? window.document : {}; | ||
var documentDomainRegex = new RegExp('^https?://' + document.domain); | ||
@@ -104,8 +101,8 @@ var resemble = function( fileData ){ | ||
function loop(x, y, callback){ | ||
var i,j; | ||
function loop(w, h, callback){ | ||
var x,y; | ||
for (i=0;i<x;i++){ | ||
for (j=0;j<y;j++){ | ||
callback(i, j); | ||
for (x=0;x<w;x++){ | ||
for (y=0;y<h;y++){ | ||
callback(x, y); | ||
} | ||
@@ -123,2 +120,4 @@ } | ||
var brightnessTotal = 0; | ||
var whiteTotal = 0; | ||
var blackTotal = 0; | ||
@@ -133,2 +132,10 @@ loop(height, width, function(verticalPos, horizontalPos){ | ||
if (red == green && red == blue && alpha) { | ||
if (red == 0) { | ||
blackTotal++ | ||
} else if (red == 255) { | ||
whiteTotal++ | ||
} | ||
} | ||
pixelCount++; | ||
@@ -148,2 +155,4 @@ | ||
data.brightness = Math.floor(brightnessTotal / pixelCount); | ||
data.white = Math.floor(whiteTotal / pixelCount * 100); | ||
data.black = Math.floor(blackTotal / pixelCount * 100); | ||
@@ -157,3 +166,5 @@ triggerDataUpdate(); | ||
hiddenImage.setAttribute('crossorigin', 'anonymous'); | ||
if(useCrossOrigin) { | ||
hiddenImage.setAttribute('crossorigin', 'anonymous'); | ||
} | ||
@@ -720,2 +731,6 @@ hiddenImage.onerror = function () { | ||
if (options.useCrossOrigin !== undefined) { | ||
useCrossOrigin = options.useCrossOrigin; | ||
} | ||
return this; | ||
@@ -722,0 +737,0 @@ }; |
Sorry, the diff of this file is not supported yet
141736
931
90
8