From a543586e7a635c14ca8bdcbc884e959dd3080671 Mon Sep 17 00:00:00 2001 From: Michael Hart Date: Sun, 1 Apr 2012 00:23:21 -0300 Subject: [PATCH 1/2] Fix for lack of quantize response --- js/color-thief.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/color-thief.js b/js/color-thief.js index 63c6b21..ebecd63 100644 --- a/js/color-thief.js +++ b/js/color-thief.js @@ -92,6 +92,14 @@ function getDominantColor(sourceImage){ // Send array to quantize function which clusters values // using median cut algorithm var cmap = MMCQ.quantize(pixelArray, 5); + + if ( cmap === false ) { + // Clean up + image.removeCanvas(); + + return false; + } + var newPalette = cmap.palette(); // Clean up @@ -135,6 +143,14 @@ function createPalette(sourceImage, colorCount){ // Send array to quantize function which clusters values // using median cut algorithm var cmap = MMCQ.quantize(pixelArray, colorCount); + + if ( cmap === false ) { + // Clean up + image.removeCanvas(); + + return false; + } + var newPalette = cmap.palette(); // Clean up From 6c351ce0e8167ef08696cd84e412c9a7a47a73d2 Mon Sep 17 00:00:00 2001 From: Lokesh Dhakar Date: Sat, 21 Apr 2012 22:04:09 -0400 Subject: [PATCH 2/2] test --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index b57820a..2b3041c 100755 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + Color Thief