import { ExtractInfoResultImage } from '../image/imageInfo'; import { IFile, Rgba, Size } from '../types'; /** * Default File implementation with utilities for creating from file system or urls. * * Also instances have utilities to cache and get image information like size, mimeType, image comparison, * interacting with HTML DOM, etc. */ export declare class File implements IFile { readonly name: string; readonly content: IFile['content']; readonly url?: string; /** * Stores size for those image formats that don't store size information such as RGBA */ width?: number; /** * Stores size for those image formats that don't store size information such as RGBA */ height?: number; protected _info: ExtractInfoResultImage[] | undefined; protected _pixels?: Rgba[]; constructor(name: string, content: IFile['content'], isProtected?: boolean, url?: string, width?: number, height?: number); /** * Same as [info] but returning only the first image's data. */ infoOne(): Promise; /** * Get image information, like geometry, important numbers, mimeType, etc. * The first time it calls `identify` command, but then it will cache ths value. */ info(): Promise; size(): Promise; widthXHeight(): Promise; mimeType(): Promise; pixel(x: number, y: number): Promise; rgba(x: number, y: number): Promise; /** * it will compute all pixel colors so following [pixel] and [rgba] calls will be fast */ pixelCalculate(): Promise; /** * Creates a DataUrl like `data:image/png;name=f.png;base64,` using given base64 content, mimeType and fileName. */ asDataUrl(mime?: string): Promise; /** * Returns base64 representation of this image in an encoded format like PNG */ asBase64(file: File): string; /** * Returns base64 representation of this image in an encoded format like PNG */ equals(file?: File): Promise; /** * Returns base64 representation of this image in an encoded format like PNG */ asArrayBuffer(): Promise; static equals: ((a: string | IFile, b: string | IFile) => boolean); asHTMLImageData(): Promise; asRGBAImageData(): Promise; sizeDepthArgs(onlyIfRGBA?: boolean): Promise; static getSizeDepthArgs(f: File, onlyIfRGBA?: boolean): Promise; /** * Creates a DataUrl like `data:image/png;name=f.png;base64,` using given base64 content, mimeType and fileName. */ static toDataUrl(file: File, mime?: string): Promise; /** * Creates a File from given url. In Node.js urls must be absolute!. */ static fromUrl(url: string, o?: RequestInit & ResolveOptions): Promise; /** * Creates a File from given ArrayBuffer. */ static fromArrayBuffer(b: ArrayBuffer, o?: ResolveOptions): Promise; /** * Creates a File from given file system path. Only Node.js. */ static fromFile(f: string, o?: ResolveOptions): File | undefined; /** * Returns the file content as plain string. This is useful to read the content of a .json or .txt file * but not for images or other binary file content. */ static asString(f: IFile): string; /** * Returns base64 representation of this image in an encoded format like PNG */ static toBase64(file: File): string; /** * Loads file from given base64 string. */ static fromBase64(base64: string, name: string): File; /** * Loads file from given data url string. */ static fromDataUrl(dataUrl: string, name: string): File; /** * Loads files from files in html input element of type "file". */ static fromHtmlFileInputElement(el: HTMLInputElement): Promise>; /** * Shortcut for [resolve] that returns the first result. */ static resolveOne(files: string | IFile | undefined | (string | IFile | undefined)[], options?: ResolveOptions): Promise; /** * Given paths, urls or files it will try to load them all and return a list of File for those succeed. */ static resolve(files: string | IFile | undefined | (string | IFile | undefined)[], options?: ResolveOptions): Promise; static isFile(f: any): f is File; static asFile(f: string | IFile): File; static asPath(f: string | IFile): string; static fromRGBAImageData(d: RGBAImageData, name?: string): File; static fromHTMLImageData(d: ImageData, name?: string): File; static fileExists(f: string | IFile): Promise; } export interface ResolveOptions { protected?: boolean; name?: string; } interface RGBAImageData { width: number; height: number; data: Uint8ClampedArray; } export {};