get-image-data
Advanced tools
Comparing version
14
index.js
@@ -5,4 +5,10 @@ var fs = require('fs') | ||
module.exports = function(path, callback) { | ||
fs.readFile(path, function(error, file) { | ||
module.exports = function(input, callback) { | ||
if (Buffer.isBuffer(input)) { | ||
load(null, input) | ||
} else { | ||
fs.readFile(input, load) | ||
} | ||
function load(error, buffer) { | ||
if (error) { | ||
@@ -14,3 +20,3 @@ callback(error) | ||
var image = new Canvas.Image | ||
image.src = file | ||
image.src = buffer | ||
@@ -22,3 +28,3 @@ var canvas = new Canvas( | ||
callback(null, shared(canvas)(image)) | ||
}) | ||
} | ||
} |
{ | ||
"name": "get-image-data", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A browser/server utility that extracts RGBA data from images.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var data = require('../') | ||
var fs = require('fs') | ||
require('./shared')(data, { | ||
trad: __dirname + '/images/trad.jpg', | ||
jerry: __dirname + '/images/jerry.jpg', | ||
astronaut: __dirname + '/images/astronaut.jpg' | ||
fs.readFile(__dirname + '/images/astronaut.jpg', function(err, buf){ | ||
require('./shared')(data, { | ||
trad: __dirname + '/images/trad.jpg', | ||
jerry: __dirname + '/images/jerry.jpg', | ||
astronaut: buf | ||
}) | ||
}) |
1105421
0.01%127
6.72%3
50%