UNPKG

@thi.ng/pixel

Version:

Typedarray integer & float pixel buffers w/ customizable formats, blitting, drawing, convolution

46 lines 1.65 kB
import { type Canvas2DOpts, type CanvasContext } from "@thi.ng/canvas"; /** * Creates canvas for given image and draws image, optionally with given * new size. If no width/height is given, the canvas will be of same * size as image. If `parent` is given, the canvas is appended to it as * child. * * @param img - * @param width - * @param height - * @param parent - */ export declare const imageCanvas: (img: HTMLImageElement, width?: number, height?: number | undefined, parent?: HTMLElement, opts?: Partial<Canvas2DOpts>) => CanvasContext; /** * Async function. Loads image from given `src` URL. By default, the image will * have its `crossorigin` HTML attribute set to 'anonymous' to avoid errors with * tainted image data in canvas elements. Can be reconfigured via optional * `cors` arg. * * @remarks * References: * * - https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin * - https://stackoverflow.com/a/55136314/294515 * * Also see {@link imageFromFile} to load from local file. * * @param src - * @param cors - */ export declare const imageFromURL: (src: string, cors?: string) => Promise<HTMLImageElement>; /** * @deprecated renamed to {@link imageFromURL} */ export declare const imagePromise: (src: string, cors?: string) => Promise<HTMLImageElement>; /** * Async function. Loads image from given `file` via the FileReader Web API, * e.g. as part of a drag & drop workflow. * * @remarks * See {@link imageFromURL} for loading an image via URL. * * @param file */ export declare const imageFromFile: (file: File) => Promise<HTMLImageElement>; //# sourceMappingURL=image.d.ts.map