From 7bb1c8c74221d213bfa250167f63a56c7d4111d7 Mon Sep 17 00:00:00 2001 From: Martin Laine Date: Tue, 15 Jul 2014 14:42:06 +0100 Subject: [PATCH 1/2] Fix how largeImageThreshold option is set --- resemble.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resemble.js b/resemble.js index 84bce19..c7a03c5 100644 --- a/resemble.js +++ b/resemble.js @@ -597,7 +597,9 @@ URL: https://github.com/Huddle/Resemble.js pixelTransparency = options.transparency || pixelTransparency; - largeImageThreshold = options.largeImageThreshold || largeImageThreshold; + if (options.largeImageThreshold !== undefined) { + largeImageThreshold = options.largeImageThreshold; + } return this; }; From 4610e8bb362173ebdb0468f8c0f8fa8de481043b Mon Sep 17 00:00:00 2001 From: Norman Ma Date: Mon, 28 Jul 2014 11:33:32 +1000 Subject: [PATCH 2/2] Updated image data loader to accept ImageData directly, pixelCount typo --- resemble.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/resemble.js b/resemble.js index a09934b..97dd8bc 100644 --- a/resemble.js +++ b/resemble.js @@ -76,7 +76,7 @@ URL: https://github.com/Huddle/Resemble.js function parseImage(sourceImageData, width, height){ - var pixleCount = 0; + var pixelCount = 0; var redTotal = 0; var greenTotal = 0; var blueTotal = 0; @@ -89,7 +89,7 @@ URL: https://github.com/Huddle/Resemble.js var blue = sourceImageData[offset + 2]; var brightness = getBrightness(red,green,blue); - pixleCount++; + pixelCount++; redTotal += red / 255 * 100; greenTotal += green / 255 * 100; @@ -97,10 +97,10 @@ URL: https://github.com/Huddle/Resemble.js brightnessTotal += brightness / 255 * 100; }); - data.red = Math.floor(redTotal / pixleCount); - data.green = Math.floor(greenTotal / pixleCount); - data.blue = Math.floor(blueTotal / pixleCount); - data.brightness = Math.floor(brightnessTotal / pixleCount); + data.red = Math.floor(redTotal / pixelCount); + data.green = Math.floor(greenTotal / pixelCount); + data.blue = Math.floor(blueTotal / pixelCount); + data.brightness = Math.floor(brightnessTotal / pixelCount); triggerDataUpdate(); } @@ -129,7 +129,12 @@ URL: https://github.com/Huddle/Resemble.js if (typeof fileData === 'string') { hiddenImage.src = fileData; - } else { + } else if (typeof fileData.data !== 'undefined' + && typeof fileData.width === 'number' + && typeof fileData.height === 'number') { + images.push(fileData); + callback(fileData, fileData.width, fileData.height); + } else { fileReader = new FileReader(); fileReader.onload = function (event) { hiddenImage.src = event.target.result;