节点 Jimp |颜色阴影
简介 色调修改器是 Nodejs | Jimp 中的一个内置颜色修改器,它将黑色混合到图像中。 语法:
image.color([
{ apply: 'shade', params: 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 shade modifier
image.color([{apply:'shade', params: [60]}])
.write('sahde1.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 shade modifier
image.color([{apply:'shade', params: [30]}], function(err){
if (err) throw err;
})
.write('shade2.png');
}
main();
console.log("Image Processing Completed");
输出: 参考:https://www.npmjs.com/package/jimp
版权属于:月萌API www.moonapi.com,转载请注明出处