#
Image Effects
This script utilizes the ApexPainter
class from the apexify.js
library to apply multiple different filters to the provided image
.
#
Usage
1.Import the ApexPainter
class from the apexify.js
library:
const { ApexPainter } = require('apexify.js');
import { ApexPainter } from 'apexify.js';
2.Create an instance of the ApexPainter
class:
const painter = new ApexPainter();
3.Call the processImage
method with the image path and the array of filters:
const imagePath = 'path/to/your/image.jpg';
const filters = [
{ type: 'flip', horizontal: true, vertical: false },
{ type: 'mirror', horizontal: true, vertical: false },
{ type: 'rotate', deg: 90, mode: 'clamp' },
{ type: 'brightness', value: 0.5 },
{ type: 'contrast', value: 0.5 },
{ type: 'dither565' },
{ type: 'greyscale' },
{ type: 'invert' },
{ type: 'normalize' },
{ type: 'autocrop', tolerance: 0 },
{ type: 'crop', x: 100, y: 100, w: 200, h: 200 },
{ type: 'fade', factor: 0.5 },
{ type: 'opacity', factor: 0.5 },
{ type: 'opaque' },
{ type: 'gaussian', radius: 5 },
{ type: 'blur', radius: 5 },
{ type: 'posterize', levels: 5 },
{ type: 'sepia' },
{ type: 'pixelate', size: 10, x: 100, y: 100, w: 200, h: 200 },
];
try {
const processedImageBuffer = await painter.processImage(imagePath, filters);
} catch (error) {
console.error('Error processing image:', error.message);
}