Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Node.js
node.js轻量级跨平台图像编解码库
var images = require("images");images("input.jpg") //Load image from file
//加载图像文件
.size(400) //Geometric scaling the image to 400 pixels width
//等比缩放图像到400像素宽
.draw(images("logo.png"), 10, 10) //Drawn logo at coordinates (10,10)
//在(10,10)处绘制Logo
.save("output.jpg", { //Save the image to a file,whih quality 50
quality : 50 //保存图片到文件,图片质量为50
});
Features 功能特性
Lightweight:no need to install any image processing library.
轻量级:无需安装任何图像处理库。
Cross-platform: Released a compiled .node file on windows, just download and start.
跨平台:Windows下发布了编译好的.node文件,下载就能用。
Easy-to-use: Provide jQuery-like chaining API.Simple and reliable!
方便用:jQuery风格的API,简单可依赖。
Installation 安装
$ npm install imagesAPI 接口
node-images provide jQuery-like Chaining API,You can start the chain like this:
node-images 提供了类似jQuery的链式调用API,您可以这样开始:
/* Load and decode image from file */
/* 从指定文件加载并解码图像 */
images(file)/* Create a new transparent image */
/* 创建一个指定宽高的透明图像 */
images(width, height)
/* Load and decode image from a buffer */
/* 从Buffer数据中解码图像 */
images(buffer[, start[, end]])
/* Copy from another image */
/* 从另一个图像中复制区域来创建图像 */
images(image[, x, y, width, height])
images(file)
Load and decode image from file从指定文件加载并解码图像
images(width, height)
Create a new transparent image创建一个指定宽高的透明图像
images(buffer[, start[, end]])
Load and decode image from a buffer从Buffer数据中解码图像
images(image[, x, y, width, height])
Copy from another image从另一个图像中复制区域来创建图像
.fill(red, green, blue[, alpha])
eg:images(200, 100).fill(0xff, 0x00, 0x00, 0.5) Fill image with color以指定颜色填充图像
.draw(image, x, y)
Draw image on the current image position( x , y )在当前图像( x , y )上绘制 image 图像
.encode(type[, config])
eg:images(“input.png”).encode(“jpg”, {operation:50}) Encode image to buffer, config is image setting.









