WebP codec information
devlibwebp (version v1.0.2) and is licensed under the BSD license.repository·dev·Indexed 12 days ago
https://github.com/googlechromelabs/squooshAn image compression web application that performs compression tasks locally in the browser. It includes a suite of codecs for formats like AVIF, WebP, and WebP2, as well as tools for quantization (ImageQuant) and resizing (HQX). The project provides a framework for implementing decoders, encoders, processors, and preprocessors using WebAssembly and Docker-based build pipelines.
libwebp (version v1.0.2) and is licensed under the BSD license.When using the decode method, the returned RawImage object contains the following three fields:
buffer: The raw RGBA pixel data.width: The width of the decoded image in pixels.height: The height of the decoded image in pixels.Squoosh categorizes features into four distinct types based on their role in the image processing pipeline:
Squoosh processes all image compression locally on your device; images are never sent to a server.
However, the application uses Google Analytics to collect the following metadata:
When you build a codec, it generates a .js file and a .wasm file. Loading the .js file creates a global object named <codec name>_<enc or dec> which follows the Emscripten Module API.
Important: To ensure the .wasm file is loaded correctly, you will likely need to configure the Module["locateFile"] function to point to the correct path of the .wasm file.
When developing a feature, files are organized into specific folders that determine their scope and visibility:
client/: Files included in the client project.worker/: Files included in the worker project.shared/: Files included in the shared project. Both the client and worker projects have access to the shared project.When using libjpeg-turbo, observe the following universal restrictions:
libjpeg-turbo Project, or its contributors in advertising, publicity, or to endorse/promote products derived from this software without specific prior written permission.libjpeg-turbo Project do not warrant the software to be free of defects and accept no liability for undesirable consequences resulting from its use.Each codec sub-project in the codecs/ directory is a self-contained project that can be built using Docker. To build a codec, run the following commands within the specific codec's directory:
npm installnpm run buildSuccessful builds produce two files:
<codec name>_<enc or dec>.js<codec name>_<enc or dec>.wasm$ npm install
$ npm run buildThe visdif codec requires a manual monkey-patch of the Emscripten dlmalloc.c file to adjust the MALLOC_ALIGNMENT definition before building. Follow these steps within a Docker container to patch the environment and compile the codec.
/emsdk/upstream/emscripten/system/lib/dlmalloc.c to change the alignment from 16U to 2 * sizeof(void *).libdlmalloc using embuilder.emmake make.$ docker run --rm -it -v $(PWD):/src squoosh-cpp "/bin/bash"
# Apply the patch to dlmalloc.c
# cat << EOF | patch /emsdk/upstream/emscripten/system/lib/dlmalloc.c
# 659c659
# < #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *)))
# ---
# > #define MALLOC_ALIGNMENT ((size_t)(16U))
# EOF
# Build steps
# emcc --clear-cache
# /emsdk/upstream/embuilder build libdlmalloc --force
# emmake makeIf you are distributing a modified version of the libjpeg-turbo source code, you must adhere to the following requirements:
README.ijg file in your distribution and must not alter any of its copyright or license text.To develop for Squoosh locally, you need to clone the repository, install the necessary Node packages, build the application, and then start the development server. Ensure you have npm installed on your system.
# 1. Clone the repository
# (Use your preferred git client)
# 2. Install node packages
npm install
# 3. Build the app
npm run build
# 4. Start the development server
npm run dev