import { AvifEncodeOptions, codecs as encoders, JxlEncodeOptions, MozJPEGEncodeOptions, OxiPngEncodeOptions, preprocessors, QuantOptions, ResizeOptions, RotateOptions, WebPEncodeOptions, WP2EncodeOptions } from './codecs.js'; import WorkerPool from './worker_pool.js'; import type ImageData from './image_data'; export { ImagePool, encoders, preprocessors }; declare type EncoderKey = keyof typeof encoders; declare type PreprocessorKey = keyof typeof preprocessors; declare type PreprocessOptions = { resize?: Partial> & (Pick | Pick); quant?: Partial; rotate?: Partial; }; declare type EncodeResult = { optionsUsed: object; binary: Uint8Array; extension: string; size: number; }; declare type EncoderOptions = { mozjpeg?: Partial; webp?: Partial; avif?: Partial; jxl?: Partial; wp2?: Partial; oxipng?: Partial; }; declare function decodeFile({ file, }: { file: ArrayBuffer | ArrayLike; }): Promise<{ bitmap: ImageData; size: number; }>; declare function preprocessImage({ preprocessorName, options, image, }: { preprocessorName: PreprocessorKey; options: any; image: { bitmap: ImageData; }; }): Promise<{ bitmap: ImageData; }>; declare function encodeImage({ bitmap: bitmapIn, encName, encConfig, optimizerButteraugliTarget, maxOptimizerRounds, }: { bitmap: ImageData; encName: EncoderKey; encConfig: any; optimizerButteraugliTarget: number; maxOptimizerRounds: number; }): Promise; declare type EncodeParams = { operation: 'encode'; } & Parameters[0]; declare type DecodeParams = { operation: 'decode'; } & Parameters[0]; declare type PreprocessParams = { operation: 'preprocess'; } & Parameters[0]; declare type JobMessage = EncodeParams | DecodeParams | PreprocessParams; /** * Represents an ingested image. */ declare class Image { file: ArrayBuffer | ArrayLike; workerPool: WorkerPool; decoded: Promise<{ bitmap: ImageData; }>; encodedWith: { [key in EncoderKey]?: EncodeResult; }; constructor(workerPool: WorkerPool, file: ArrayBuffer | ArrayLike); /** * Define one or several preprocessors to use on the image. * @param {PreprocessOptions} preprocessOptions - An object with preprocessors to use, and their settings. * @returns {Promise} - A promise that resolves when all preprocessors have completed their work. */ preprocess(preprocessOptions?: PreprocessOptions): Promise; /** * Define one or several encoders to use on the image. * @param {object} encodeOptions - An object with encoders to use, and their settings. * @returns {Promise<{ [key in keyof T]: EncodeResult }>} - A promise that resolves when the image has been encoded with all the specified encoders. */ encode(encodeOptions: { optimizerButteraugliTarget?: number; maxOptimizerRounds?: number; } & T): Promise<{ [key in keyof T]: EncodeResult; }>; } /** * A pool where images can be ingested and squooshed. */ declare class ImagePool { workerPool: WorkerPool; /** * Create a new pool. * @param {number} [threads] - Number of concurrent image processes to run in the pool. */ constructor(threads: number); /** * Ingest an image into the image pool. * @param {ArrayBuffer | ArrayLike} file - The image that should be ingested and decoded. * @returns {Image} - A custom class reference to the decoded image. */ ingestImage(file: ArrayBuffer | ArrayLike): Image; /** * Closes the underlying image processing pipeline. The already processed images will still be there, but no new processing can start. * @returns {Promise} - A promise that resolves when the underlying pipeline has closed. */ close(): Promise; } //# sourceMappingURL=index.d.ts.map