在NodeJS上打开图像并找出宽度/高度 [英] Opening images on NodeJS and finding out width/height

查看:91
本文介绍了在NodeJS上打开图像并找出宽度/高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常感谢您提供未来的帮助。我需要的是相当于new Image()(然后是myImage.src ......等)但是在NodeJS上。我会感谢那些在我内心深处迅速回答的人......好吧,也说谢谢! :P

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

推荐答案

node-imagemagick ,(显然你需要有ImageMagick)。

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 }
})

这篇关于在NodeJS上打开图像并找出宽度/高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆