Browse Source

Allow passing src to load image bypassing fileReader

pull/6/head
Dr. Kibitz 11 years ago
parent
commit
40f531415b
  1. 20
      resemble.js

20
resemble.js

@ -77,12 +77,8 @@ URL: https://github.com/Huddle/Resemble.js
} }
function loadImageData( fileData, callback ){ function loadImageData( fileData, callback ){
var hiddenImage = new Image(); var fileReader,
var fileReader = new FileReader(); hiddenImage = new Image();
fileReader.onload = function (event) {
hiddenImage.src = event.target.result;
};
hiddenImage.onload = function() { hiddenImage.onload = function() {
@ -100,8 +96,16 @@ URL: https://github.com/Huddle/Resemble.js
callback(imageData, width, height); callback(imageData, width, height);
}; };
fileReader.readAsDataURL(fileData); if (typeof fileData === 'string') {
hiddenImage.src = fileData;
} else {
fileReader = new FileReader();
fileReader.onload = function (event) {
hiddenImage.src = event.target.result;
};
fileReader.readAsDataURL(fileData);
}
} }
function isColorSimilar(a, b, color){ function isColorSimilar(a, b, color){

Loading…
Cancel
Save