WebP encoder module of the JPG to WebP tool =========================================== This folder holds a build of libwebp's encoder, without any change to its source code. libwebp is distributed under a BSD license (3-clause), with an additional patent grant from Google: - libwebp 1.6.0 Copyright (c) 2010, Google Inc. All rights reserved. https://chromium.googlesource.com/webm/libwebp The build also contains the Emscripten 6.0.12 runtime (MIT or University of Illinois/NCSA license) and musl, its C library (Copyright (c) 2005-2020 Rich Felker, et al., MIT license), including math code under Sun Microsystems' fdlibm notice. When it is used --------------- Chrome, Edge and Firefox write WebP images themselves and never load this module. Safari cannot, on Mac, iPhone or iPad, and every browser on iPhone and iPad uses Safari's engine. There, the page loads this module in its conversion worker and writes each image with libwebp's simple API, with libwebp's default settings, as Chrome does: WebPEncodeRGBA at the quality chosen below 100, and WebPEncodeLosslessRGBA at 100. The image never leaves the device. Files ----- libwebp.js, libwebp.wasm The module: libwebp's encoder (src/enc, the src/dsp and src/utils files it uses, and sharpyuv) compiled with Emscripten, plain C with no SIMD and no threads. SHA-256 in SHA256SUMS. source/libwebp-1.6.0.tar.gz The exact source code of this build: the release file published by the WebM Project at https://storage.googleapis.com/downloads.webmproject.org/releases/webp/ (SHA-256 e4ab7009bf0629fd11982d4c2aa83964cf244cffba7347ecd39019a9e38c4564), signed with the "WebP release signing key", fingerprint 6B0E 6B70 976D E303 EDF2 F601 F9C3 D6BD B823 2B5D. source/build.sh The build script, with every option and flag used. COPYING-libwebp.txt, PATENTS-libwebp.txt, AUTHORS-libwebp.txt libwebp's license, Google's patent grant and libwebp's authors. LICENSE-emscripten.txt, LICENSE-musl.txt, NOTICE-fdlibm.txt The licenses and notices of the Emscripten runtime, musl and the fdlibm math code. Rebuilding ---------- 1. Install and activate emsdk 6.0.12 (https://emscripten.org) and curl. 2. Copy source/libwebp-1.6.0.tar.gz into : build.sh checks its SHA-256 and does not download it again. 3. Run: source/build.sh Built this way, in separate folders of the same machine, the output was byte-identical to libwebp.js and libwebp.wasm here (same SHA-256). The system libraries that come prebuilt with emsdk embed their own build paths, so another emsdk setup may give small differences. Replacing the library --------------------- The tool loads libwebp.js as an ES module inside its Web Worker, fetches libwebp.wasm, and calls the module's default export with { wasmBinary }. It then uses only these exports: _WebPEncodeRGBA, _WebPEncodeLosslessRGBA, _WebPFree, _WebPGetEncoderVersion, _malloc, _free and the HEAPU8 and HEAPU32 views of the module's memory. Any build of libwebp with those exports can take the place of these two files.