https://github.com/leancodepl/flutter_webp
Asset transformer for converting images into WebP files.
https://github.com/leancodepl/flutter_webp
flutter webp
Last synced: 9 months ago
JSON representation
Asset transformer for converting images into WebP files.
- Host: GitHub
- URL: https://github.com/leancodepl/flutter_webp
- Owner: leancodepl
- License: apache-2.0
- Created: 2024-05-20T09:58:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-18T14:13:29.000Z (almost 2 years ago)
- Last Synced: 2025-01-07T17:21:23.668Z (over 1 year ago)
- Topics: flutter, webp
- Language: Dart
- Homepage: https://pub.dev/packages/webp
- Size: 152 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# webp
[![webp pub.dev badge][pub-badge]][pub-badge-link]
[![][build-badge]][build-badge-link]
Asset transformer for converting images into WebP files.
## Install package
```
flutter pub add webp
```
## Package usage
Add to your `pubspec.yaml`.
### Default usage
If run without additional arguments, the default value of the quality parameter = 75 with lossy compression will be used.
```yaml
flutter:
assets:
- path: assets/logo.jpg
transformers:
- package: webp
```
### Usage with params
```yaml
flutter:
assets:
- path: assets/logo.jpg
transformers:
- package: webp
args: ['--quality=65', '--hint=graph', '--af']
```
By default, the package runs the embedded precompiled cwebp binary. You can use the one specified in your `$PATH` by adding the `--from_path` flag.
```yaml
flutter:
assets:
- path: assets/logo.jpg
transformers:
- package: webp
args: ['--from_path']
```
## cwebp parameters
Here are some commonly used parameters for cwebp:
- `-q`, `--quality`: Set the quality factor for the output image. The value should be between 0 and 100, with 100 being the highest quality. For example, `--quality=80`.
- `--lossless`: Encode the image without any loss. For images with fully transparent area, the invisible pixel values (R/G/B or Y/U/V) will be preserved only if the `--exact` option is used..
- `-m`, `--method`: Set the compression method. The value can be `0` (fastest), `1` (default), `2` (slowest), or `3` (best quality). For example, `--method=2`.
- `-f`, `--filter`: Set the filter strength. The value can be between 0 and 100, with 0 being no filtering and 100 being maximum filtering. For example, `--filter=50`.
- `-s`, `--size`: Set the target size for the output image. The value should be in bytes. For example, `--size=500000`.
For a complete list of parameters and their descriptions, please refer to the [cwebp documentation](https://developers.google.com/speed/webp/docs/cwebp).
## Supported architectures
The package provides cwebp binaries for the following architectures:
- windows-x64,
- macos-x64,
- macos-arm64,
- linux-x64,
- linux-arm64.
Note: You can still use the package on other architectures with cwebp from your `$PATH`.
## Learn more
- [Asset transformers in Flutter](https://docs.flutter.dev/ui/assets/asset-transformation)
---
Built with ☕️ by LeanCode
[pub-badge]: https://img.shields.io/pub/v/webp
[pub-badge-link]: https://pub.dev/packages/webp
[build-badge]: https://img.shields.io/github/actions/workflow/status/leancodepl/flutter_webp/check.yml
[build-badge-link]: https://github.com/leancodepl/flutter_webp/actions/workflows/check.yml