Adding resize preprocessor (#152)

* Adding resize preprocessor

* Using ! on form

* Haha oops

* Using createImageBitmapPolyfill

* Updating package.json

* Oops again

* Ooops again
This commit is contained in:
Jake Archibald
2018-09-05 15:46:26 +01:00
committed by GitHub
parent 700b1f15cd
commit ea5d3c2d78
11 changed files with 286 additions and 19 deletions

View File

@@ -154,8 +154,35 @@ export async function sniffMimeType(blob: Blob): Promise<string> {
return '';
}
export function createImageBitmapPolyfill(blob: Blob): Promise<ImageBitmap> {
return createImageBitmap(blob);
type CreateImageBitmapInput = HTMLImageElement | SVGImageElement | HTMLVideoElement |
HTMLCanvasElement | ImageBitmap | ImageData | Blob;
export function createImageBitmapPolyfill(
image: CreateImageBitmapInput,
options?: ImageBitmapOptions,
): Promise<ImageBitmap>;
export function createImageBitmapPolyfill(
image: CreateImageBitmapInput,
sx: number,
sy: number,
sw: number,
sh: number,
options?: ImageBitmapOptions,
): Promise<ImageBitmap>;
export function createImageBitmapPolyfill(
image: CreateImageBitmapInput,
sxOrOptions?: number | ImageBitmapOptions,
sy?: number,
sw?: number,
sh?: number,
options?: ImageBitmapOptions,
): Promise<ImageBitmap> {
if (sxOrOptions === undefined || typeof sxOrOptions !== 'number') {
// sxOrOptions is absent or an options object
return createImageBitmap(image, sxOrOptions);
}
// sxOrOptions is a number
return createImageBitmap(image, sxOrOptions, sy!, sw!, sh!, options);
}
/**