UNPKG

magnitude-core

Version:
26 lines (25 loc) 814 B
import { Image as BamlImage } from '@boundaryml/baml'; import { StoredMedia } from './serde'; import { Sharp } from 'sharp'; import sharp from 'sharp'; export type ImageMediaType = `image/${string}`; export declare class Image { /** * Wrapper for a Sharp image with conveniences to go to/from base64, convert to BAML, or serialize as JSON */ private img; constructor(img: Sharp); static fromBase64(base64: string): Image; getFormat(): Promise<keyof sharp.FormatEnum>; /** * Convert the image to a JSON representation */ toJson(): Promise<StoredMedia>; toBase64(): Promise<string>; toBaml(): Promise<BamlImage>; getDimensions(): Promise<{ width: number; height: number; }>; resize(width: number, height: number): Promise<Image>; }