don*_*aka 7 javascript node.js apng
有可能以某种方式使用nodejs将PNG图像连接到APNG动画图像吗?
我发现只有PHP库:链接
UPNG.js可以解析和构建 APNG 文件 - https://github.com/photopea/UPNG.js
从自述文件 -
UPNG.js 支持 APNG 并且该界面需要“框架”。
UPNG.encode(imgs, w, h, cnum, [dels])
Run Code Online (Sandbox Code Playgroud)imgs: array of frames. A frame is an ArrayBuffer containing the pixel data (RGBA, 8 bits per channel) w, h : width and height of the image cnum: number of colors in the result; 0: all colors (lossless PNG) dels: array of delays for each frame (only when 2 or more frames) returns an ArrayBuffer with binary data of a PNG file
UPNG.js 可以对 PNG 文件进行有损缩小,类似于 TinyPNG 和其他工具。它使用 k-means 算法执行颜色量化。
最后一个参数 cnum 允许有损压缩。将其设置为零以进行无损压缩,或写入图像中允许的颜色数量。较小的值会生成较小的文件。或者仅使用 0 表示无损/256 表示有损。
小智 1
我不确定nodejs,但你可以尝试APNG-canvas。APNG 使用 HTML5 (-webkit-canvas)、JavaScript (jQuery)。
“APNG-canvas 是一个库,用于在支持画布的浏览器(Google Chrome、Internet Explorer 9、Apple Safari)中显示动画 PNG 文件。”
工作演示在这里。