Better resize methods (#498)

* Port resize to wasm

* Expose resize algorithms

* Lanczos3 working!

* lol copy paste

* Adding support for other resizers

* Don’t track generated README

* Cache wasm instance
This commit is contained in:
Jake Archibald
2019-03-06 17:20:25 +00:00
committed by GitHub
parent 8c35c3cdaa
commit 9e5b66d5f4
27 changed files with 435 additions and 60 deletions

View File

@@ -28,6 +28,16 @@ async function rotate(
return rotate(data, opts);
}
async function resize(
data: ImageData, opts: import('../resize/processor-meta').WorkerResizeOptions,
): Promise<ImageData> {
const { resize } = await import(
/* webpackChunkName: "process-resize" */
'../resize/processor');
return resize(data, opts);
}
async function optiPngEncode(
data: BufferSource, options: import('../optipng/encoder-meta').EncodeOptions,
): Promise<ArrayBuffer> {
@@ -53,7 +63,7 @@ async function webpDecode(data: ArrayBuffer): Promise<ImageData> {
return decode(data);
}
const exports = { mozjpegEncode, quantize, rotate, optiPngEncode, webpEncode, webpDecode };
const exports = { mozjpegEncode, quantize, rotate, resize, optiPngEncode, webpEncode, webpDecode };
export type ProcessorWorkerApi = typeof exports;
expose(exports, self);