节点吉普 |颜色变亮
介绍
Brighten 修饰符是Nodejs中内置的颜色修饰符 | Jimp 用于将图像增亮到给定的量,范围在 0 到 100 之间。
句法:
image.color([
{ apply: 'brighten', params: [value] }
]);
范围:
- value – 此参数存储要应用的亮度量。它的取值范围为 0 – 100。
输入图像:
示例 1:
Javascript
// npm install --save jimp
// import jimp library to the environment
var Jimp = require('jimp');
// User-Defined Function to read the images
async function main() {
const image = await Jimp.read
('https://media.geeksforgeeks.org/wp-content/uploads/20190328185307/gfg28.png');
// color function having brighten modifier
image.color([{apply:'brighten', params: [50]}])
.write('brighten1.png');
}
main();
console.log("Image Processing Completed");
Javascript
// npm install --save jimp
// import jimp library to the environment
var Jimp = require('jimp');
// User-Defined Function to read the images
async function main() {
const image = await Jimp.read
('https://media.geeksforgeeks.org/wp-content/uploads/20190328185333/gfg111.png');
// color function having brighten modifier
image.color([{apply:'brighten', params: [50]}], function(err){
if (err) throw err;
})
.write('brighten2.png');
}
main();
console.log("Image Processing Completed");
输出:
示例 2:cb(可选参数)
Javascript
// npm install --save jimp
// import jimp library to the environment
var Jimp = require('jimp');
// User-Defined Function to read the images
async function main() {
const image = await Jimp.read
('https://media.geeksforgeeks.org/wp-content/uploads/20190328185333/gfg111.png');
// color function having brighten modifier
image.color([{apply:'brighten', params: [50]}], function(err){
if (err) throw err;
})
.write('brighten2.png');
}
main();
console.log("Image Processing Completed");
输出:
参考: https://www.npmjs.com/package/jimp