Installations
npm install images
Score
76.3
Supply Chain
99.5
Quality
81
Maintenance
84
Vulnerability
100
License
Releases
Contributors
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
17.0.1
NPM Version
8.1.0
Statistics
1,557 Stars
210 Commits
205 Forks
47 Watching
6 Branches
10 Contributors
Updated on 27 Nov 2024
Bundle Size
3.68 kB
Minified
1.50 kB
Minified + Gzipped
Languages
C++ (88.94%)
JavaScript (7.33%)
C (2.34%)
Python (1.4%)
Total Downloads
Cumulative downloads
Total Downloads
2,122,174
Last day
-20%
1,412
Compared to previous day
Last week
-4.2%
8,798
Compared to previous week
Last month
3%
40,252
Compared to previous month
Last year
7.4%
318,709
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
No dependencies detected.
Cross-platform image decoder(png/jpeg/gif) and encoder(png/jpeg) for Node.js
Node.js轻量级跨平台图像编解码库
1var images = require("images"); 2 3images("input.jpg") //Load image from file 4 //加载图像文件 5 .size(400) //Geometric scaling the image to 400 pixels width 6 //等比缩放图像到400像素宽 7 .draw(images("logo.png"), 10, 10) //Drawn logo at coordinates (10,10) 8 //在(10,10)处绘制Logo 9 .save("output.jpg", { //Save the image to a file, with the quality of 50 10 quality : 50 //保存图片到文件,图片质量为50 11 });
Support 支持情况
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 |
- The 32-bit system is not supported for the time being.
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 |
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 images
API 接口
node-images provide jQuery-like Chaining API,You can start the chain like this:
node-images 提供了类似jQuery的链式调用API,您可以这样开始:
1/* Load and decode image from file */ 2/* 从指定文件加载并解码图像 */ 3images(file) 4 5/* Create a new transparent image */ 6/* 创建一个指定宽高的透明图像 */ 7images(width, height) 8 9/* Load and decode image from a buffer */ 10/* 从Buffer数据中解码图像 */ 11images(buffer[, start[, end]]) 12 13/* Copy from another image */ 14/* 从另一个图像中复制区域来创建图像 */ 15images(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.
以指定格式编码当前图像到Buffer,config为图片设置,目前支持设置JPG图像质量
Return buffer
返回填充好的Buffer
Note:The operation will cut off the chain
注意:该操作将会切断调用链
See:.save(file[, type[, config]])
参考:.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图像质量
.size([width[, height]])
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未指定,则根据当前宽高等比缩放
.resize(width[, height])
Set the size of the image,if the height is not specified, then scaling based on the current width and height
设置图像宽高,如果height未指定,则根据当前宽高等比缩放, 默认采用 bicubic 算法。
.width([width])
Get width for the image or set width of the image
获取或设置图像宽度
.height([height])
Get height for the image or set height of the image
获取或设置图像高度
images.setLimit(width, height)
Set the limit size of each image
设置库处理图片的大小限制,设置后对所有新的操作生效(如果超限则抛出异常)
images.setGCThreshold(value)
Set the garbage collection threshold
设置图像处理库自动gc的阈值(当新增内存使用超过该阈值时,执行垃圾回收)
images.getUsedMemory()
Get used memory (in bytes)
得到图像处理库占用的内存大小(单位为字节)
images.gc()
Forced garbage collection
强制调用V8的垃圾回收机制
Stable Version
The latest stable version of the package.
Stable Version
3.2.4
HIGH
1
7.5/10
Summary
images vulnerable to Denial of Service
Affected Versions
<= 3.2.4
Patched Versions
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: vendor/darwin-arm64-binding.node:1
- Warn: binary detected: vendor/darwin-x64-binding.node:1
- Warn: binary detected: vendor/linux-x64-binding.node:1
- Warn: binary detected: vendor/win32-x64-binding.node:1
Reason
Found 2/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v3.0.2 not signed: https://api.github.com/repos/zhangyuanwei/node-images/releases/14748871
- Warn: release artifact v3.0.1 not signed: https://api.github.com/repos/zhangyuanwei/node-images/releases/6596373
- Warn: release artifact v3.0.2 does not have provenance: https://api.github.com/repos/zhangyuanwei/node-images/releases/14748871
- Warn: release artifact v3.0.1 does not have provenance: https://api.github.com/repos/zhangyuanwei/node-images/releases/6596373
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 10 are checked with a SAST tool
Score
2.2
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More