This project aim to show a practical usage example for WebAssembly where we decode a webp image format and transform it to a jpeg image.
With this, we could make any browser display a webp image even if they don't support the format.
WebAssembly is a binary format code that can be executed in a browser (desktop and mobile) and NodeJS. (?WeChat?)
Even though it's possible to write code directly in WebAssembly its main goal is to port code from other languages.
- C, C++
- Rust
- Go
- Python
curated list of WebAssembly projects
git clone https://github.com/alex-michaud/wasm-tutorial-webp-decode.git
Check if you already have Emscripten installed
emcc --version
If it returned a version number, make sure it's at least 2.X
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
emcc --version
git clone https://github.com/webmproject/libwebp
./webp.sh
-01 (simple optimizations)
-03 (advanced optimizations)
-0s (above 03)
-0z (above 0z)
-s OPTION=VALUE (options passed to the emscripten compiler)
-g0 (Make no effort to keep code debuggable)
-g3 (When compiling to object files, keep debug info, including JS whitespace, function names, and LLVM debug info)
-o webp_module.js (generate a target javascript file + companion wasm file)