/** * ImageDataHelper * * Utility class for working with image data, including raster and SVG sources. * Provides methods to render images (data URLs, inline SVG strings, external URLs) into a canvas * and to convert them into Uint8Array (PNG bytes by default). * * Features: * - Supports raster and SVG input * - Handles inline SVG strings, data:image/svg+xml URLs, and external SVG URLs * - Preserves aspect ratio by default, can disable if needed * - Produces crisp rendering for SVG when resizing * - Backward-compatible: does not modify existing functions in your code */ export declare class ImageDataHelper { /** * Convert a canvas to Uint8Array (PNG by default). */ static canvasToUint8Array(canvas: HTMLCanvasElement, type?: string, quality?: number): Promise; /** * Detect whether input is an SVG (data URL or inline string). */ private static isSvgSource; /** * Decode an SVG from a data: URL or return raw SVG string. */ private static decodeSvgStringIfNeeded; /** * Extract intrinsic width/height or viewBox from SVG text. */ private static getSvgIntrinsicSize; /** * Inject/replace width/height and preserveAspectRatio attributes in SVG text. */ private static setSvgSize; /** * Render any image (raster or SVG) into a canvas of the requested size. * - Works with inline SVG, data:image/svg+xml, and external SVG URLs (fetched if same-origin or CORS allowed). * - Preserves aspect ratio by default. */ static imageDataToCanvasWithSize(src: string, targetWidth?: number, targetHeight?: number, keepAspectRatio?: boolean): Promise; /** * High-level helper: * Render the provided image into a canvas of the given size and return the PNG bytes as Uint8Array. * * @param src - raster or SVG source (data URL, inline string, external URL) * @param targetWidth - output width in pixels (optional) * @param targetHeight - output height in pixels (optional) * @param keepAspectRatio - preserve aspect ratio (default: true) */ static dataUrlToUint8ArrayWithSize(src: string, targetWidth?: number, targetHeight?: number, keepAspectRatio?: boolean): Promise; }