Mamsaac Mamsaac - 5 months ago 10
Javascript Question

Opening images on NodeJS and finding out width/height

Thanks a lot in advance for the future help. What I need is the equivalent of a "new Image()" (and then myImage.src... etc) but on NodeJS. I will thank whoever answers quickly deep in my heart... and well, also saying "thanks!" :P

Answer

There's node-imagemagick, (you'll need to have ImageMagick, obviously).

var im = require('imagemagick');
im.identify('kittens.jpg', function(err, features){
  if (err) throw err
  console.log(features)
  // { format: 'JPEG', width: 3904, height: 2622, depth: 8 }
})