https://github.com/nucliweb/cavif-bin
cavif bin-wrapper that makes it seamlessly available as a local dependency
https://github.com/nucliweb/cavif-bin
Last synced: 10 months ago
JSON representation
cavif bin-wrapper that makes it seamlessly available as a local dependency
- Host: GitHub
- URL: https://github.com/nucliweb/cavif-bin
- Owner: nucliweb
- License: mit
- Created: 2021-01-02T13:59:43.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-19T14:08:36.000Z (almost 5 years ago)
- Last Synced: 2025-03-28T05:51:05.537Z (11 months ago)
- Language: JavaScript
- Size: 5.85 MB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cavif-bin
cavif bin-wrapper that makes it seamlessly available as a local dependency
> I hope that this package will be part of the imagemin plugins as an [imagemin-avif](https://github.com/nucliweb/imagemin-avif) `WIP`
## About AVIF

[AVIF] offers significant compression gains vs. JPEG and WebP, with a recent Netflix study showing 50% savings vs. standard JPEG and > 60% savings on 4:4:4 content
## Underhood
`cavif-bin` use [cavif](https://github.com/kornelski/cavif-rs) **v0.6.6** with [BSD 3-Clause License](https://github.com/kornelski/cavif-rs/blob/main/LICENSE) and Copyright (c) 2020, [Kornel](https://github.com/kornelski), as a AVIF coder.
### Encoder options
| Option | Description |
| ------ | ----------- |
| --quality=n | Quality from 1 (worst) to 100 (best), the default value is 80. The numbers have different meaning than JPEG's quality scale. Beware when comparing codecs. |
| --speed=n | Encoding speed between 1 (best, but slowest) and 10 (fastest, but a blurry mess), the default value is 1. Encoding of AVIF is pretty slow, so you need either a) beefy multicore machine b) avoid large images c) patience. |
| --overwrite | Replace files if there's .avif already. By default existing files are left untouched. |
-o path | Write output to this path instead of samefile.avif. If multiple input files are specified, it's interpreted as a directory. |
| --quiet | Don't print anything during conversion. |
| --premultiplied-alpha | Warning: currently incompatible with libavif. Improves compression of transparent images by clearing RGB of fully transparent pixels and lowering quality of semi-transparent colors. |
| --dirty-alpha | Don't change RGB values of transparent pixels. By default irrelevant color of transparent pixels is cleared to avoid wasting space. |
| --color=rgb | encode using RGB color space instead of YCbCr color space. Makes color closer to lossless, but makes files larger. |
## Install
```bash
npm install cavif-bin
```
## Usage
```js
const {execFile} = require('child_process');
const cavif = require('cavif-bin');
execFile(cavif, ['input.png','--quality=74', '-o', 'output.avif'], err => {
if (err) throw err;
console.log('Image is converted!');
});
```
## CLI
You can install `cavif` globally.
```bash
npm install --global cavif-bin
```
And use it as a CLI command.
```bash
cavif --help
```
## AVIF browsers support
* Chrome Desktop 85+
* Firefox 63+ (with `media.av1.enabled` activated)
* Firefox for Android 64+ (with `media.av1.enabled` and `media.av1.use-dav1d` activated)
* Edge 18+ (with `AV1 Video Extension` installed)
## License
MIT © [nucliweb](https://github.com/nucliweb)
[AVIF]: https://aomediacodec.github.io/av1-avif/