问题
I am using express 3 to make a http server which uploads the image in a designated folder but I am not able to get the image resolution in the req object . I tried looking in req.files and req.files.images and req.files.headers but I could not find that information . How can I get the resoultion of the uploaded image .
回答1:
See solution here: Opening images on NodeJS and finding out width/height
var im = require('imagemagick');
im.identify(req.files.images.path, function(err, features){
if (err) throw err
console.log(features)
// { format: 'JPEG', width: 3904, height: 2622, depth: 8 }
})
Make sure you have imagemagick included and installed in your project.
来源:https://stackoverflow.com/questions/20761313/how-to-get-image-resolution-data-from-uploaded-image-in-express