mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-18 19:49:04 +00:00
Properly split encoder and decoder
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Codecs
|
||||
|
||||
This folder contains a self-contained sub-project for each codec that squoosh supports.
|
||||
This folder contains a self-contained sub-project for each encoder and decoder that squoosh supplies.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -11,22 +11,6 @@ $ npm install
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
This will build two files: `<codec name>_codec.js` and `<codec name>_codec.wasm`. Due to some current limitations in Emscripten, both of these files have to be served from the root folder. When the `.js` file is loaded, a global `<codec name>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
|
||||
This will build two files: `<codec name>_<enc or dec>.js` and `<codec name>_<enc or dec>.wasm`. It will most likely be necessary to set [`Module["locateFile"]`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html#affecting-execution) to sucessfully load the `.wasm` file. When the `.js` file is loaded, a global `<codec name>_<enc or dec>` is created with the same API as an [Emscripten `Module`](https://kripken.github.io/emscripten-site/docs/api_reference/module.html).
|
||||
|
||||
Each codec offers at least 2 functions:
|
||||
|
||||
- `void encode(uint8_t* img_in, int width, int height, float quality)`
|
||||
- `void decode(???)`
|
||||
|
||||
Example:
|
||||
|
||||
```html
|
||||
<!-- *_codec.{wasm,js} need to be in / -->
|
||||
<script src="/mozjpeg_codec.js"></script>
|
||||
<script>
|
||||
mozjpeg.onRuntimeInitialized = _ => {
|
||||
const encode = mozjpeg.cwrap('encode', '', ['number', 'number', 'number', 'number']);
|
||||
/* ... */
|
||||
};
|
||||
</script>
|
||||
```
|
||||
Each codec will document its API in its README.
|
||||
|
||||
Reference in New Issue
Block a user