import { imageResize } from "./imageResize" export type NativeResizeMethod = "pixelated" | "low" | "medium" | "high" /** * 重新调整图像大小,使用浏览器的内置的 canvas。 */ export async function nativeResize( data: ImageData | Blob, dw: number, dh: number, options?: { sx?: number sy?: number sw?: number sh?: number method?: NativeResizeMethod } ): Promise { let canvas = (await imageResize(data, dw, dh, { sx: options?.sx, sy: options?.sy, sw: options?.sw, sh: options?.sh, method: options?.method, returnCanvas: true, })) // console.log("nativeResize canvas", canvas ) let ctx = canvas.getContext("2d") if (!ctx) throw new Error("Could not create canvas context") return ctx.getImageData(0, 0, Math.round(dw), Math.round(dh)) }