tree: 3c154e7d0958827ba8237c29ebaf09f948721d9d [path history] [tgz]
  1. tests/
  2. tools/
  3. avifinfo.c
  4. avifinfo.h
  5. avifinfo.php
  6. avifinfo.rs
  7. Cargo.toml
  8. CMakeLists.txt
  9. LICENSE
  10. PATENTS
  11. README.md
  12. SECURITY.md
README.md

AVIF-info

libavifinfo is a standalone library that can be used to extract the width, height, bit depth, number of channels and other metadata from an AVIF payload.

See avifinfo.h for details on the API and avifinfo.c for the implementation. See tests/avifinfo_demo.cc for API usage examples.

How to use

libavifinfo can be used when only a few AVIF features are needed and when linking to or including libavif is not an option. For decoding an image or extracting more features, please rely on libavif.

Note: The C implementation AvifInfoGetFeatures() is designed to return the same avifImage field values as avifDecoderParse(). However libavifinfo is often more permissive and may return features of images considered invalid by libavif.

C implementation

Coding style

Google C/C++ Style Guide is used in this project.

Build

avifinfo.c is written in C. To build from this directory:

cmake -S . -B build && \
cmake --build build --config Release

Test

GoogleTest is required for the C++ tests (e.g. sudo apt install libgtest-dev).

cmake -S . -B build -DAVIFINFO_BUILD_TESTS=ON && \
cmake --build build --config Debug && \
ctest --test-dir build build

PHP implementation

The PHP implementation of libavifinfo is a subset of the C API.

libavifinfo was implemented into php-src natively and is available through getimagesize() at head. If it is not available in the PHP release version you use, you can fallback to avifinfo.php instead.

See tests/avifinfo_test.php for a usage example.

PHP test

cd tests && \
php avifinfo_test.php

Rust implementation

The Rust implementation of libavifinfo is similar to the C API.

cargo build

See tests/avifinfo_test.rs for a usage example.

Rust test

cargo test

Development

Submitting patches

If you would like to contribute to libavifinfo, please follow the steps for libaom at https://aomedia.googlesource.com/aom/#submitting-patches. Summary:

  • Log in at https://aomedia.googlesource.com
  • Sign in at https://aomedia-review.googlesource.com
  • Execute the contributor agreement if necessary, see http://aomedia.org/license
  • Test all implementations as described in this document
  • Copy the commit message hook: cd libavifinfo && curl -Lo .git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg && chmod u+x .git/hooks/commit-msg
  • Create a commit
  • git push https://aomedia.googlesource.com/libavifinfo/ HEAD:refs/for/main
  • Request a review from a project maintainer

Known users of libavifinfo

  • Chromium uses the C impl to extract the gain map item for HDR tone mapping (removed in Oct 2024).
  • PHP-src uses the C impl to parse image features without relying on libavif or libheif.
  • WordPress uses the PHP impl to support AVIF images with older versions of PHP.

Bug reports

Bug reports can be filed in the Alliance for Open Media issue tracker.