image_to_webp 1.0.0 copy "image_to_webp: ^1.0.0" to clipboard
image_to_webp: ^1.0.0 copied to clipboard

Convert PNG/JPG images to WebP using a webp.yaml config file (CLI + API).

image_to_webp #

Convert PNG/JPG images to WebP using a webp.yaml config file.

Features #

  • Works as a Dart CLI: dart run image_to_webp
  • Config-driven: define folders in webp.yaml
  • Two scan modes:
    • some_dir/* converts only files directly inside the folder
    • some_dir/** converts recursively (including subfolders)
  • Progress output in the terminal (percent + counters)
  • Optional cleanup: -d/--delete deletes source images after converting

Requirements #

  • Usually: nothing to install. The tool uses a bundled cwebp binary shipped via the Dart dependency.
  • Fallback: if your architecture isn’t bundled, it will try cwebp from your $PATH.

Installing cwebp (only if fallback is needed) #

macOS (Homebrew):

brew install webp

Ubuntu/Debian:

sudo apt-get update && sudo apt-get install -y webp

Windows (Chocolatey):

choco install webp

Installation #

Add it to your dev dependencies:

dart pub add --dev image_to_webp

Usage (CLI) #

Create webp.yaml in the project root where you run the command:

paths:
  - assets/*     # only files directly inside assets/
  - assets/**    # recursively
quality: 80      # optional, default: 80 (0..100)

Run:

dart run image_to_webp

Delete originals after successful conversion:

dart run image_to_webp -d

Usage (Dart API) #

You can also call the same logic programmatically:

import 'dart:io';
import 'package:image_to_webp/image_to_webp.dart';

Future<void> main() async {
  final code = await runImageToWebp(
    const ['--config', 'webp.yaml'],
    stdout: stdout,
    stderr: stderr,
  );
  if (code != 0) exit(code);
}

Example project #

See example/main.dart.

Notes #

  • Outputs *.webp alongside the original file (same folder, same basename).
  • Skips files that are already WebP.
1
likes
160
points
88
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Convert PNG/JPG images to WebP using a webp.yaml config file (CLI + API).

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

args, package_config, path, webp, yaml

More

Packages that depend on image_to_webp