Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
README.md | H A D | 25-Apr-2025 | 1.9 KiB | 61 | 43 | |
index.html | H A D | 25-Apr-2025 | 2.1 KiB | 78 | 69 | |
index_wasm.html | H A D | 25-Apr-2025 | 2.2 KiB | 79 | 71 | |
test_webp_js.webp | HD | 25-Apr-2025 | 1.3 MiB | |||
test_webp_wasm.webp | HD | 25-Apr-2025 | 1.3 MiB |
README.md
1# WebP JavaScript decoder 2 3``` 4 __ __ ____ ____ ____ __ ____ 5/ \\/ \ _ \ _ \ _ \ (__)/ __\ 6\ / __/ _ \ __/ _) \_ \ 7 \__\__/_____/____/_/ /____/____/ 8``` 9 10This file describes the compilation of libwebp into a JavaScript decoder using 11Emscripten and CMake. 12 13- install the Emscripten SDK following the procedure described at: 14 https://emscripten.org/docs/getting_started/downloads.html#installation-instructions-using-the-emsdk-recommended 15 After installation, you should have some global variable positioned to the 16 location of the SDK. In particular, $EMSDK should point to the top-level 17 directory containing Emscripten tools. 18 19- configure the project 'WEBP_JS' with CMake using: 20 21 ```shell 22 cd webp_js && \ 23 emcmake cmake -DWEBP_BUILD_WEBP_JS=ON ../ 24 ``` 25 26- compile webp.js using 'emmake make'. 27 28- that's it! Upon completion, you should have the 'webp.js', 'webp.js.mem', 29 'webp_wasm.js' and 'webp_wasm.wasm' files generated. 30 31The callable JavaScript function is WebPToSDL(), which decodes a raw WebP 32bitstream into a canvas. See webp_js/index.html for a simple usage sample (see 33below for instructions). 34 35## Demo HTML page 36 37The HTML page webp_js/index.html requires the built files 'webp.js' and 38'webp.js.mem' to be copied to webp_js/. An HTTP server to serve the WebP image 39example is also needed. With Python, just run: 40 41```shell 42cd webp_js && python3 -m http.server 8080 43``` 44 45and then navigate to http://localhost:8080 in your favorite browser. 46 47## Web-Assembly (WASM) version: 48 49CMakeLists.txt is configured to build the WASM version when using the option 50WEBP_BUILD_WEBP_JS=ON. The compilation step will assemble the files 51'webp_wasm.js' and 'webp_wasm.wasm' that you then need to copy to the webp_js/ 52directory. 53 54See webp_js/index_wasm.html for a simple demo page using the WASM version of the 55library. 56 57## Caveats 58 59- First decoding using the library is usually slower, due to just-in-time 60 compilation. 61