Name Date Size #Lines LOC

..--

README.mdH A D25-Apr-20251.9 KiB6143

index.htmlH A D25-Apr-20252.1 KiB7869

index_wasm.htmlH A D25-Apr-20252.2 KiB7971

test_webp_js.webpHD25-Apr-20251.3 MiB

test_webp_wasm.webpHD25-Apr-20251.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