如何在Node.js中调整图像大小? [英] How to resize an image in Node.js?

查看:73
本文介绍了如何在Node.js中调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从电子商务网站中收集信息,该信息图像中也有该信息.下载的图像尺寸不同.我想要该图像的默认大小.如何执行Node.js?

I am scrapping information from e-commerce websites, in that information image also is there. Downloaded images are in different sizes. I want that images in default size. How to do it Node.js?

推荐答案

您可以为此创建 gulp/grunt 任务,也可以使用名为 gm 的可用模块: GM模块

You can create a gulp/grunt task for this OR you can use available module called gm :GM MODULE

var gm = require('gm');

gm('/path/to/image.jpg')
.resize(353, 257)
.autoOrient()
.write(writeStream, function (err) {
  if (!err) console.log(' hooray! ');
});

这篇关于如何在Node.js中调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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