关于node.js:如何从快递上传的图片中获取图片分辨率数据? | 珊瑚贝

How to get image resolution data from uploaded image in express?

本问题已经有最佳答案,请猛点这里访问。


我正在使用 express 3 制作一个 http 服务器,该服务器将图像上传到指定文件夹中,但我无法在 req 对象中获得图像分辨率。
我尝试查看 req.files 和 req.files.images 和 req.files.headers 但我找不到该信息。
我怎样才能得到上传图片的结果。


在此处查看解决方案:Opening images on NodeJS and find out width/height

1
2
3
4
5
6
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 }
 })

确保您的项目中包含并安装了 imagemagick。

  • 我得到星期二,2013 年 12 月 24 日 01:00:25 GMT uncaughtException spawn ENOENT 错误:在 Process.ChildProcess._handle.onexit (child_process.js:771:34) 和我的应用程序退出。无论如何,我从 req.files.image.path 得到 “/home/bhanuc/win/winter/crowd-sourcing/public/uploads/56943??-nghb7g.jpg”
  • 您需要安装 imagick CLI,imagemagick.org/script/binary-releases.php,也在您的项目目录下运行 npm install imagemagick
  • 我们可以在 ubuntu 中安装它吗?
  • 这将是最简单的,在您的终端运行: sudo apt-get install imagemagick
  • 谢谢 !!!你拯救了我的一天:-)


来源:https://www.codenong.com/20761313/

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?