/** * Canvas image post-processing shared by every MolVis surface. * * Trimming transparent margins and re-encoding are the same operations * whether the pixels came from the 3D stage's framebuffer or the 2D * sketch board, so both engines export images through this module and * users get one consistent result. It lives in `core` because the two * engines are peers and cannot import each other. * * Pure canvas work — no molrs, no engine types. */ export interface CropOptions { padding?: number; mimeType?: string; quality?: number; alphaThreshold?: number; } export interface CropBounds { x: number; y: number; width: number; height: number; } /** * Scan RGBA pixel data for the tight bounding box of non-transparent pixels. * Returns null when every pixel has alpha <= threshold (nothing was drawn). */ export declare function findAlphaBounds(pixels: Uint8ClampedArray, width: number, height: number, alphaThreshold?: number): CropBounds | null; /** * Decode a data URL and re-encode it as the given mime type (no cropping). */ export declare function reencodeImage(dataUrl: string, mimeType: string, quality?: number): Promise; /** * Crop a data URL to the explicit pixel bounds and re-encode. Bounds are * clamped to the image extent; empty intersection throws. */ export declare function cropToRect(dataUrl: string, bounds: CropBounds, mimeType?: string, quality?: number): Promise; /** * Decode a data URL, scan its alpha channel for drawn content, crop to the tight * bounds (with optional padding), and re-encode to the requested mime type. * * Returns the source data URL unchanged if the image is fully transparent. * The input must have an alpha channel (PNG from a transparent-background render). */ export declare function cropToContent(dataUrl: string, options?: CropOptions): Promise;