Search code examples
node.jsgraphicsmagick

Get image dimensions from url path


I am trying to load the dimensions of an image from url. So far I've tried using GraphicsMagick but it gives me ENOENT error.

Here's the code so far I've written.

var gm = require('gm');

...

gm(img.attribs.src).size(function (err, size) {
      if (!err) {
            if( size.width>200 && size.height>200)
            {
                console.log('Save this image');
            }
      }
}); 

Where img.attribs.src contains the url source path of the image.

Update

value of img.attribs.src

http://rack.1.mshcdn.com/assets/header_logo.v2-30574d105ad07318345ec8f1a85a3efa.png


Solution

  • I've used this library to perform the operation successfully.