【发布时间】:2018-03-24 19:28:51
【问题描述】:
所以我有一个sample.jpg 文件,我想检查它的尺寸。
想要的逻辑是这样的:
var img = require('./sample.jpg');
console.log(typeof img) // returns string -> Image
console.log(img.height) // returns number -> 300
console.log(img.width) // returns nubmer -> 250
不要介意typeof 的回归。我只是不想得到尺寸。但这是我要去的地方的简单分解。有没有办法使用 node 或纯 js 来做到这一点?
【问题讨论】:
-
好像有个热门node package to do that
标签: javascript node.js