You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

image-to-webp

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-to-webp

A NodeJS Package to convert JPG, PNG images to WebP

1.0.6
latest
Version published
Weekly downloads
12
50%
Maintainers
1
Weekly downloads
 
Created

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.

FAQs

Package last updated on 29 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts