Skip to content

Small node library for converting jpg and png images to webp file format with command line

License

Notifications You must be signed in to change notification settings

vkiss/simple-webp-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-webp-converter

npm version License: MIT

A simple Node.js library for converting PNG and JPG images to WebP format using webp-converter.

Features

  • Convert PNG and JPG images to WebP
  • CLI tool for easy integration into build scripts
  • Programmatic API for custom workflows
  • Configurable source patterns using glob

Installation

npm install simple-webp-converter --save-dev

Usage

CLI Usage

Add to your package.json scripts:

{
  "scripts": {
    "webp": "simple-webp-converter"
  }
}

Run the conversion:

npm run webp

This will create WebP copies of all PNG and JPG files in the project (excluding node_modules).

Configuration

Configure options in package.json under the "simple-webp-converter" key:

{
  "simple-webp-converter": {
    "src": "src/**/*.{png,jpg}",
    "quality": 90
  }
}

With this config, only images under the /src folder will be converted with 90% quality.

Programmatic Usage

const simpleWebpConverter = require("simple-webp-converter");

// Use default settings (converts **/*.{png,jpg} at quality 80)
simpleWebpConverter();

// Use custom source pattern and quality
simpleWebpConverter({
  src: "assets/**/*.{png,jpg}",
  quality: 90
});

Options

  • src (string): Glob pattern to match source images. Default: "**/*.{png,jpg}"
  • quality (number): WebP quality (0-100). Default: 80

Notes

  • Output files are created in the same directory as the source files with .webp extension.
  • Quality ranges from 0 (worst) to 100 (best).
  • Requires webp-converter which depends on WebP tools being installed on the system.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

MIT

About

Small node library for converting jpg and png images to webp file format with command line

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •