From 33f9114d0aac5719fa6725988776b18adfc400c0 Mon Sep 17 00:00:00 2001 From: "james.cryer" Date: Wed, 25 May 2016 11:15:53 +0100 Subject: [PATCH] Resolves bug address by PR #70. Removes defensive CORS from e6dab9aaf06415bd62cadb5d72a09bcc37b56128 and optimisation a1a41fc5260a1ba7567173ed3137ce850e32840a. Works for me. --- demoassets/main.js | 3 +++ index.html | 3 ++- resemble.js | 29 ++++++++++++++++++----------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/demoassets/main.js b/demoassets/main.js index f72e8a5..01bf319 100644 --- a/demoassets/main.js +++ b/demoassets/main.js @@ -108,6 +108,9 @@ $(function(){ resembleControl.ignoreNothing(); } else + if($this.is('#less')){ + resembleControl.ignoreLess(); + } if($this.is('#colors')){ resembleControl.ignoreColors(); } diff --git a/index.html b/index.html index 7ced660..09182e4 100644 --- a/index.html +++ b/index.html @@ -89,7 +89,8 @@
diff --git a/resemble.js b/resemble.js index 8340fc5..2626a6d 100644 --- a/resemble.js +++ b/resemble.js @@ -148,17 +148,9 @@ URL: https://github.com/Huddle/Resemble.js function loadImageData( fileData, callback ){ var fileReader; var hiddenImage = new Image(); - - if (!(typeof fileData === 'string' - && fileData.length > 6 - && fileData.charAt(4)===':' - && fileData.charAt(5)!=='/' - )) { - if (httpRegex.test(fileData) && !documentDomainRegex.test(fileData)) { - hiddenImage.setAttribute('crossorigin', 'anonymous'); - } - } - + + hiddenImage.setAttribute('crossorigin', 'anonymous'); + hiddenImage.onerror = function () { hiddenImage.onerror = null; //fixes pollution between calls images.push({ error : "Image load error."}); @@ -622,6 +614,21 @@ URL: https://github.com/Huddle/Resemble.js if(hasMethod) { param(); } return self; }, + ignoreLess: function(){ + + tolerance.red = 16; + tolerance.green = 16; + tolerance.blue = 16; + tolerance.alpha = 16; + tolerance.minBrightness = 16; + tolerance.maxBrightness = 240; + + ignoreAntialiasing = false; + ignoreColors = false; + + if(hasMethod) { param(); } + return self; + }, ignoreAntialiasing: function(){ tolerance.red = 32;