A WebAssembly-based image converter for the AVIF format, enabling fast encoding and decoding in browser or Node.js environments.
- Encode JPEG/PNG images to AVIF
- Decode AVIF to RGBA pixel data
- WebAssembly (WASM) module with JavaScript bindings
- Lightweight, high-performance, and portable
- CMake ≥ 3.13
- Emscripten SDK
- Node.js (optional, for CLI/testing)
git clone https://github.com/fahara02/ConvAvif.git
cd ConvAvif
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
emmake makeActivate the Emscripten environment and generate build files:
Windows (Binaryen) Note If you're on Windows, ensure Binaryen is installed by following COMPILING_WIN32 instructions. After installing, run:
emcc --generate-configThis configures the path to
wasm-opt.exe. Otherwise,emmakemay fail with abinaryen executable not founderror.
# Initialize and activate emsdk (adjust path as needed)
source /path/to/emsdk/emsdk_env.sh
# Configure build with CMake
emcmake cmake -S . -B build
# Compile
cmake --build buildUpon success, the build/ directory will contain:
imageconverter.jsimageconverter.wasm
Include the generated script in your HTML page:
<script src="build/imageconverter.js"></script>
<script>
Module.onRuntimeInitialized = () => {
// Example: call a function to encode raw pixel data
// Module._encodeToAvif(ptr, width, height, quality);
};
</script>const createModule = require('./build/imageconverter.js');
createModule().then(Module => {
// Example: use Module._encodeToAvif(...)
});Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/awesome. - Commit your changes and push:
git push origin feature/awesome. - Open a Pull Request against
main.
Distributed under the MIT License. See LICENSE for details.
- libavif
- Emscripten
- Inspired by community efforts in high-efficiency image formats.