mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-18 19:49:04 +00:00
Start integrating quantizer in the main data flow
This commit is contained in:
@@ -1,7 +1,18 @@
|
||||
import QuantizerWorker from './Quantizer.worker';
|
||||
|
||||
export const name = 'Image Quanitzer';
|
||||
export async function quantize(data: ImageData): Promise<ImageData> {
|
||||
export async function quantize(data: ImageData, opts: QuantizeOptions): Promise<ImageData> {
|
||||
const quantizer = await new QuantizerWorker();
|
||||
return quantizer.quantize(data);
|
||||
return quantizer.quantize(data, opts);
|
||||
}
|
||||
|
||||
export interface QuantizeOptions {
|
||||
maxNumColors: number;
|
||||
dither: number;
|
||||
}
|
||||
|
||||
// These come from struct WebPConfig in encode.h.
|
||||
export const defaultOptions: QuantizeOptions = {
|
||||
maxNumColors: 256,
|
||||
dither: 1.0,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user