Skip to content

Commit

Permalink
case typo in index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Pomax committed Aug 17, 2014
1 parent 1f84a6c commit c2ff131
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "rgbanalyse",
"version": "0.1.10",
"version": "0.1.11",
"homepage": "https://pomax.github.io/RGBAnalyse",
"repository": {
"type" : "git",
Expand Down
4 changes: 3 additions & 1 deletion index.html
Expand Up @@ -209,7 +209,9 @@ <h1>Some example images</h1>
div.appendChild(img);
img.onload = function(evt) {
var img = evt.target;
setTimeout(function() { analyse(img); }, 100);
setTimeout(function() {
analyse(img);
}, 100);
};
img.src = "images/img" + idx + ".jpg";
document.getElementById("images").appendChild(div);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -4,4 +4,4 @@
this code is to be considered under an MIT
license (http://opensource.org/licenses/MIT)
*/
module.exports = require("./src/RGBanalyse");
module.exports = require("./src/RGBAnalyse");
11 changes: 6 additions & 5 deletions release/RGBAnalyse.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/common.js
Expand Up @@ -183,7 +183,10 @@

/**
* If browser, use canvas to deal with an Image(). If node,
* load image data from file.
* load image data from file. Note that the browser version
* can take both an Image or a Canvas element as "img" input,
* because you might load images through JS decoders in the
* browser to circumvent incorrect application of color profiles.
*/
getImageData: (function() {
if(typeof window === "undefined") return require("./getimagedata");
Expand All @@ -195,6 +198,10 @@
}.bind(this);
return setTimeout(fn, 100);
}

if(img instanceof HTMLCanvasElement) {
img = { src: img.toDataURL("image/png") };
}

var nimg = new Image();
nimg.src = img.src;
Expand All @@ -204,6 +211,7 @@
canvas.height = img.height;
var ctx = canvas.getContext('2d');
ctx.drawImage(img,0,0);

try {
var data = ctx.getImageData(0,0,canvas.width,canvas.height).data;
handler(false, {
Expand Down

0 comments on commit c2ff131

Please sign in to comment.