#
Converting Image Extension
This script utilizes the ApexPainter
class from the apexify.js
library to convert image extensions into various formats such as PNG, JPEG, AVIF, WebP, SVG, and more.
#
Usage
To convert an image extension using the ApexPainter
class, follow these steps:
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();
- Define the options for converting:
- Provide the file path of the image.
- Provide the extension you want to convert to.
const image = './image.png';
const newExtension = 'png';
- Generate The Converted Image:
const outputConvertedImage = await painter.imgConverter(image, newExtension);
console.log(outputConvertedImage); // Returns a buffer image.