Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Cross-platform image decoder(webp/png/jpeg/gif) and encoder(webp/png/jpeg) for Node.js
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, with the quality of 50
quality : 50 //保存图片到文件,图片质量为50
});
if node >= 10.x, please install images@latest
Platform | Architecture | Node Version |
---|---|---|
Windows | x64 | 8, 9, 10, 11, 12 |
OSX | X64 | 8, 9, 10, 11, 12 |
Linux* | x64 | 8, 9, 10, 11, 12 |
if node <= 9.x, please install images@3.1.1
Platform | Architecture | Node Version |
---|---|---|
Windows | x86 & x64 | 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 10 |
OSX | X64 | 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 9, 10 |
Linux* | x86 & x64 | 0.9.11, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 8, 10 |
$ npm install images
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])
Load and decode image from file
从指定文件加载并解码图像
Create a new transparent image
创建一个指定宽高的透明图像
Load and decode image from a buffer
从Buffer数据中解码图像
Copy from another image
从另一个图像中复制区域来创建图像
eg:images(200, 100).fill(0xff, 0x00, 0x00, 0.5)
Fill image with color
以指定颜色填充图像
Draw image on the current image position( x , y )
在当前图像( x , y )上绘制 image 图像
eg:images("input.png").encode("jpg", {operation:50})
Encode image to buffer, config is image setting.
以指定格式编码当前图像到Buffer,config为图片设置,目前支持设置JPG图像质量
Return buffer
返回填充好的Buffer
Note:The operation will cut off the chain
注意:该操作将会切断调用链
See:.save(file[, type[, config]])
参考:.save(file[, type[, config]])
eg:images("input.png").encode("output.jpg", {operation:50})
Encoding and save the current image to a file, if the type is not specified, type well be automatically determined according to the file, config is image setting. eg: { operation:50 }
编码并保存当前图像到 file ,如果type未指定,则根据 file 自动判断文件类型,config为图片设置,目前支持设置JPG图像质量
Get size of the image or set the size of the image,if the height is not specified, then scaling based on the current width and height
获取或者设置图像宽高,如果height未指定,则根据当前宽高等比缩放
Set the size of the image,if the height is not specified, then scaling based on the current width and height
设置图像宽高,如果height未指定,则根据当前宽高等比缩放, 默认采用 bicubic 算法。
Get width for the image or set width of the image
获取或设置图像宽度
Get height for the image or set height of the image
获取或设置图像高度
Set the limit size of each image
设置库处理图片的大小限制,设置后对所有新的操作生效(如果超限则抛出异常)
Set the garbage collection threshold
设置图像处理库自动gc的阈值(当新增内存使用超过该阈值时,执行垃圾回收)
Get used memory (in bytes)
得到图像处理库占用的内存大小(单位为字节)
Forced garbage collection
强制调用V8的垃圾回收机制
FAQs
Cross-platform image decoder(webp/png/jpeg/gif) and encoder(webp/png/jpeg) for Node.js
We found that images demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.