节点吉普 |颜色旋转
介绍
自旋修饰符是 Nodejs 中内置的颜色修饰符 | Jimp 将图像的色调旋转到给定的数量,从 -360 到 360。旋转到 0、360、-360 不会执行任何函数,因为它将色调设置回原来的状态。
句法:
image.color([
{ apply: 'spin', params: [value] }
]);
范围:
- value - 此参数存储要应用的色调旋转量。它的取值范围为 -360 到 360。
输入图像:
示例 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 spin modifier
image.color([{apply:'spin', params: [50]}])
.write('spin1.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 spin modifier
image.color([{apply:'spin', params: [50]}], function(err){
if (err) throw err;
})
.write('spin2.png');
}
main();
console.log("Image Processing Completed");
输出:
参考: https://www.npmjs.com/package/jimp