From 2d11034368845ebcf28d7ac13b1d3233bd93c5f1 Mon Sep 17 00:00:00 2001 From: Martin Laine Date: Tue, 15 Jul 2014 11:41:31 +0100 Subject: [PATCH] Add largeImageThreshold option to control when to skip pixels --- README.md | 9 +++++++-- resemble.js | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 62e1041..a40312f 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,16 @@ resemble.outputSettings({ blue: 255 }, errorType: 'movement', - transparency: 0.3 + transparency: 0.3, + largeImageThreshold: 1200 }); // resembleControl.repaint(); ``` +By default, the comparison algorithm skips pixels when the image width or height is larger than 1200 pixels. This is there to mitigate performance issues. + +You can switch this modify this behaviour by setting the `largeImageThreshold` option to a different value. Set it to **0** to switch it off completely. + -------------------------------------- -Created by [James Cryer](http://github.com/jamescryer) and the Huddle development team. \ No newline at end of file +Created by [James Cryer](http://github.com/jamescryer) and the Huddle development team. diff --git a/resemble.js b/resemble.js index a09934b..84bce19 100644 --- a/resemble.js +++ b/resemble.js @@ -33,9 +33,11 @@ URL: https://github.com/Huddle/Resemble.js } } }; - + var errorPixelTransformer = errorPixelTransform.flat; + var largeImageThreshold = 1200; + _this['resemble'] = function( fileData ){ var data = {}; @@ -347,7 +349,7 @@ URL: https://github.com/Huddle/Resemble.js var skip; - if( (width > 1200 || height > 1200) && ignoreAntialiasing){ + if(!!largeImageThreshold && ignoreAntialiasing && (width > largeImageThreshold || height > largeImageThreshold)){ skip = 6; } @@ -592,9 +594,11 @@ URL: https://github.com/Huddle/Resemble.js if(options.errorType && errorPixelTransform[options.errorType] ){ errorPixelTransformer = errorPixelTransform[options.errorType]; } - + pixelTransparency = options.transparency || pixelTransparency; + largeImageThreshold = options.largeImageThreshold || largeImageThreshold; + return this; };