Is it possible to get the width and height of an image in node.js (on the server side, not the client side)? I need to find the width and height of an image in a node.js lib
Installing GraphicsMagick
or ImageMagick
isn't at all needed, determining the dimensions of a image is as easy as looking at the header. image-size
is a pure javascript implementation of said feature which is very easy to use.
https://github.com/netroy/image-size
var sizeOf = require('image-size');
sizeOf('images/funny-cats.png', function (err, dimensions) {
console.log(dimensions.width, dimensions.height);
});