UNPKG

javascript-binary-converter

Version:

A utility package to quickly handle and convert various Javascript binary objects

25 lines (24 loc) 1.11 kB
import { ImageCreationConfig } from "../sharedTypes"; declare type ImageTypes = 'image/png' | 'image/jpeg'; declare type ImageToBlobConfig = { type?: ImageTypes; height?: number; width?: number; }; declare type ScaledDimensionsConfig = Required<Pick<ImageCreationConfig, 'maxSize'>> & Dimensions; declare type Dimensions = { width: number; height: number; }; export declare function binaryToImage(binary: Blob | File, config?: ImageCreationConfig): Promise<HTMLImageElement>; export declare function getBlobWithModifiedImageSize(binary: Blob | File, config: Required<Omit<ImageCreationConfig, 'type'>>): Promise<unknown>; /** * Reduce the dimensions of an image, while maintaining its ratio. */ export declare function getScaledDimensions({ width: w, height: h, maxSize }: ScaledDimensionsConfig): { width: number; height: number; }; export declare function imageToBlob(image: HTMLImageElement, config: ImageToBlobConfig): Promise<unknown>; export declare function imageToCanvas(image: HTMLImageElement, config: Dimensions): HTMLCanvasElement; export {};