| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

Node.js 图像处理包:gm

gm 是 Node.js 的 GraphicsMagick 和 ImageMagick。

常规使用:

var fs = require('fs')    , gm = require('./gm');    // resize and remove EXIF profile data  gm('/path/to/my/img.jpg')  .resize(240, 240)  .noProfile()  .write('/path/to/resize.png', function (err) {    if (!err) console.log('done');  });    // obtain the size of an image  gm('/path/to/my/img.jpg')  .size(function (err, size) {    if (!err)      console.log(size.width > size.height ? 'wider' : 'taller than you');  });    // output all available image properties  gm('/path/to/img.png')  .identify(function (err, data) {    if (!err) console.log(data)  });    // pull out the first frame of an animated gif and save as png  gm('/path/to/animated.gif[0]')  .write('/path/to/firstframe.png', function (err) {    if (err) console.log('aaw, shucks');  });    // auto-orient an image  gm('/path/to/img.jpg')  .autoOrient()  .write('/path/to/oriented.jpg', function (err) {    if (err) ...  })    // crazytown  gm('/path/to/my/img.jpg')  .flip()  .magnify()  .rotate('green', 45)  .blur(7, 3)  .crop(300, 300, 150, 130)  .edge(3)  .write('/path/to/crazy.jpg', function (err) {    if (!err) console.log('crazytown has arrived');  })    // annotate an image  gm('/path/to/my/img.jpg')  .stroke("#ffffff")  .drawCircle(10, 10, 20, 10)  .font("Helvetica.ttf", 12)  .drawText(30, 20, "GMagick!")  .write("/path/to/drawing.png", function (err) {    if (!err) console.log('done');  });    // creating an image  gm(200, 400, "#ddff99f3")  .drawText(10, 50, "from scratch")  .write("/path/to/brandNewImg.jpg", function (err) {    // ...  });

项目主页:http://www.open-open.com/lib/view/home/1431338638263

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1431338638263.html
Node.js 图形/图像处理