PNGjs-Image本地 PNG 操作库

联合创作 · 2023-09-29 22:30

PNGjs-Image 是本地 PNG 操作库。

示例代码:

var image = PNGImage.createImage(100, 300);
// Get width and height
console.log(image.getWidth());
console.log(image.getHeight());
// Set a pixel at (20, 30) with red, having an alpha value of 100 (half-transparent)
image.setAt(20, 30, { red:255, green:0, blue:0, alpha:100 });
// Get index of coordinate in the image buffer
var index = image.getIndex(20, 30);
// Print the red color 
valueconsole.log(image.getRed(index));
// Get low level image object with buffer from the 'pngjs' package
var pngjs = image.getImage();

image.writeImage('path/to/file', function () {    
console.log('Written to the file');
})
浏览 2
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报