How to get image resolution data from uploaded image in express? [duplicate]

送分小仙女□ 提交于 2020-01-06 12:37:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!