sf-static/portfolio/node_modules/imgr/lib/size.js

20 lines
515 B
JavaScript
Raw Normal View History

2023-02-28 18:21:07 +00:00
var imagesize = require('imagesize')
, fs = require('fs');
/**
* Get the dimensions of an image.
*
* @param {String} path
* @param {Function} callback - receives (err, dimensions)
*/
module.exports = function (path, callback) {
var stream = fs.createReadStream(path);
imagesize(stream, function (err, dimensions) {
if (err) err = new Error('The image dimensions could not be determined (the image may be invalid).');
stream.destroy();
callback(err, dimensions);
});
};