image-to-webp
v1.0.6
Published
A NodeJS Package to convert JPG, PNG images to WebP
Downloads
116
Maintainers
Readme
image-to-webp
Convert Image (JPG/PNG) to WebP for good compression and better performance. Resulting in faster website load.
https://www.npmjs.com/package/image-to-webp
Installation
npm i image-to-webp
Example
const { imageToWebp } = require("image-to-webp");
const outputFilePath = await imageToWebp("./myimg.jpeg",90);
console.log(outputFilePath);
Options
imagePath: provide string image path here, you can provide the temporary uploaded image path which is returned by packages like Formidable or Multer.
quality: it accept number value from 0-100, 0 (For high compression and lossy image), 100 (Less compression). Defult value is 80.
imageToWebp()
function returns the path of Converted WebP image. this package stores all images to temporary folder. so using returned path by this method, either you can move the image from tmp
directory to public directory in your backend or upload it to any cloud storage provider such as AWS S3.