🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

image-to-webp

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

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
Source
npm
Version published
Weekly downloads
7
-58.82%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

webp

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