节点吉普 |颜色混合
介绍
mix修饰符是 Nodejs 中内置的颜色修饰符 | Jimp 通过它们的 RGB 分量值和数量混合颜色是叠加颜色的不透明度。
句法:
image.color([
{ apply: 'mix', params: [color : value] }
]);
范围:
- color – 此参数存储要应用的颜色。
- value - 此参数存储要应用的颜色混合量。
输入图像:
示例 1:
// 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 hue modifier
image.color([{apply:'mix', params: ['blue', 60]}])
.write('mix1.png');
}
main();
console.log("Image Processing Completed");
输出:
示例 2:cb(可选参数)
// 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 hue modifier
image.color([{apply:'mix', params: ['green', 50]}], function(err){
if (err) throw err;
})
.write('mix2.png');
}
main();
console.log("Image Processing Completed");
输出:
参考: https://www.npmjs.com/package/jimp