Media Morph is a versatile JavaScript library for processing images and videos using sharp and fluent-ffmpeg. This package allows you to transform media files into various formats with ease.
To install Media Morph, run the following command:
npm install mediamorphasync processImage(inputPath, outputFormats);
async processVideo(inputPath, outputFormats);const MediaMorph = require('mediamorph');
const mediaMorph = new MediaMorph();
(async () => {
try {
const results = await mediaMorph.processImage('path/to/image.png', ['jpeg', 'webp']);
console.log('Transformed Images:', results);
} catch (error) {
console.error('Error processing image:', error);
}
})();const MediaMorph = require('my-npm-package');
const mediaMorph = new MediaMorph();
(async () => {
try {
const results = await mediaMorph.processVideo('path/to/video.mp4', ['avi', 'mov']);
console.log('Transformed Videos:', results);
} catch (error) {
console.error('Error processing video:', error);
}
})();