get-image-data
Advanced tools
Comparing version
@@ -0,1 +1,2 @@ | ||
var get = require('get-image') | ||
var shared = require('./shared') | ||
@@ -20,12 +21,7 @@ | ||
var image = new Image | ||
if (!/^data/.test(path)) { | ||
image.crossOrigin = true | ||
} | ||
image.src = path | ||
image.onerror = callback | ||
image.onload = function() { | ||
callback(null, shared(canvas)(image)) | ||
} | ||
get(path, function(error, image) { | ||
error ? | ||
callback(error) : | ||
callback(null, shared(canvas)(image)) | ||
}) | ||
} |
18
index.js
var fs = require('fs') | ||
var Canvas = require('canvas') | ||
var get = require('get-image') | ||
var shared = require('./shared') | ||
module.exports = function(input, callback) { | ||
if (Buffer.isBuffer(input)) { | ||
load(null, input) | ||
} else { | ||
fs.readFile(input, load) | ||
} | ||
function load(error, buffer) { | ||
module.exports = function (input, callback) { | ||
get(input, function(error, image) { | ||
if (error) { | ||
@@ -17,6 +12,3 @@ callback(error) | ||
} | ||
var image = new Canvas.Image | ||
image.src = buffer | ||
var canvas = new Canvas( | ||
@@ -27,3 +19,3 @@ image.width, image.height | ||
callback(null, shared(canvas)(image)) | ||
} | ||
}) | ||
} |
{ | ||
"name": "get-image-data", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A browser/server utility that extracts RGBA data from images.", | ||
@@ -11,3 +11,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"canvas": "~1.1.1" | ||
"canvas": "~1.1.1", | ||
"get-image": "^1.0.0" | ||
}, | ||
@@ -24,9 +25,32 @@ "devDependencies": { | ||
"browsers": { | ||
"ie": [8, 9, 10], | ||
"chrome": [20, 25, 29], | ||
"firefox": [4, 19, 24], | ||
"safari": [5.1, 6], | ||
"opera": [10, 12, 15], | ||
"iphone": [6], | ||
"android": [4.2] | ||
"ie": [ | ||
8, | ||
9, | ||
10 | ||
], | ||
"chrome": [ | ||
20, | ||
25, | ||
29 | ||
], | ||
"firefox": [ | ||
4, | ||
19, | ||
24 | ||
], | ||
"safari": [ | ||
5.1, | ||
6 | ||
], | ||
"opera": [ | ||
10, | ||
12, | ||
15 | ||
], | ||
"iphone": [ | ||
6 | ||
], | ||
"android": [ | ||
4.2 | ||
] | ||
} | ||
@@ -33,0 +57,0 @@ }, |
Sorry, the diff of this file is not supported yet
1105540
0.01%2
100%118
-7.09%+ Added
+ Added
+ Added
+ Added