Node Jimp | Цвет xor

Опубликовано: 6 Августа, 2021

Вступление
Модификатор xor - это встроенный модификатор цвета в Nodejs | Jimp, который обрабатывает два цвета как битовые поля и применяет операцию XOR к красному, зеленому и синему компонентам данного изображения.

image.color ([
  {применить: 'xor', параметры: значение}
]);

Параметр:

  • value - этот параметр хранит цвет, к которому должна применяться операция xor.

Входные изображения:

Пример 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
// color function having xor modifier
image.color([{apply: 'xor' , params: [ 'green' ]}])
.write( 'xor1.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
// color function having xor modifier
image.color([{apply: 'xor' , params: [ 'blue' ]}], function (err){
if (err) throw err;
})
.write( 'xor2.png' );
}
main();
console.log( "Image Processing Completed" );

Выход:

Ссылка: https://www.npmjs.com/package/jimp