Giter VIP home page Giter VIP logo

cavif-rs's Introduction

cavif — PNG/JPEG to AVIF converter

Encoder/converter for AVIF images. Based on rav1e and avif-serialize, which makes it a pure Rust tool, with no C code!

Installation

➡️ Download the latest release ⬅️

The pre-built zip includes a portable static executable, with no dependencies, that runs on any Linux distro. It also includes executables for macOS and Windows.

Compatibility

  • Chrome 85 desktop,
  • Chrome on Android 12,
  • Firefox 91.

Running

Run in a terminal (hint: you don't need to type the path, terminals accept file drag'n'drop)

cavif image.png

It makes image.avif. You can adjust quality (it's in 1-100 scale):

cavif --quality 60 image.png

Usage

You can also specify multiple images (encoding is multi-threaded, so the more, the better!).

cavif [OPTIONS] IMAGES...
  • --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. There is no lossless compression support.
  • --speed=n — Encoding speed between 1 (best, but slowest) and 10 (fastest, but a blurry mess), the default value is 4. Speeds 1 and 2 are unbelievably slow, but make files ~3-5% smaller. Speeds 7 and above degrade compression significantly, and are not recommended.
  • --overwrite — Replace files if there's .avif already. By default the existing files are left untouched.
  • -o path — Write images to this path (instead of same-name.avif). If multiple input files are specified, it's interpreted as a directory.
  • --quiet — Don't print anything during conversion.

There are additional options that tweak AVIF color space. The defaults in cavif are chosen to be the best, so use these options only when you know it's necessary:

  • --premultiplied-alpha — Alternative compression mode that lowers quality of semi-transparent colors. Warning: at low qualities it may create black artifacts in transparent areas.
  • --dirty-alpha — Preserve RGB values of fully transparent pixels. By default irrelevant color of transparent pixels is cleared to avoid wasting space.
  • --color=rgb — Encode using RGB instead of YCbCr color space. Makes colors closer to lossless, but makes files larger. Use only if you need to avoid even smallest color shifts.

Building

To build it from source you need:

  • Rust 1.52 or later, preferably via rustup,
  • nasm 2.14 or later.

Then run in a terminal:

cargo install cavif

cavif-rs's People

Contributors

0xflotus avatar dbquarrel avatar est31 avatar kornelski avatar nucliweb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.