/** * AnnotationImageManager - Based on PDF.js ImageManager * * Manages images used by annotation editors with memory optimization. * Features: * - Caching with reference counting * - Memory management (converts to blob when not in use) * - Multiple image sources: File, URL, Blob, Canvas * - SVG support with aspect ratio preservation * - Unique ID generation and validation */ export interface ImageData { bitmap: ImageBitmap | HTMLImageElement; id: string; refCounter: number; isSvg: boolean; url?: string; file?: File; blobPromise?: Promise; svgUrl?: string; } export interface ImageManagerOptions { baseId?: string; } /** * Utility function to generate unique IDs */ declare function generateUuid(): string; /** * Utility function to fetch data from URL */ declare function fetchImageData(url: string): Promise; declare function validateFileSize(file: File, maxSize?: number): boolean; declare function validateFileMimeType(file: File, mimeTypes?: string[]): boolean; declare function isSVGFittingCanvas(): Promise; export declare class AnnotationImageManager { private readonly baseId; private idCounter; private cache; constructor(options?: ImageManagerOptions); /** * Get image data from cache or create new entry */ private get; /** * Handle SVG image loading with aspect ratio preservation */ private handleSvgImage; /** * Get image from File object */ getFromFile(file: File): Promise; /** * Get image from URL */ getFromUrl(url: string): Promise; /** * Get image from Blob with custom ID */ getFromBlob(id: string, blobPromise: Promise): Promise; /** * Get image by ID (restore from cache) */ getFromId(id: string): Promise; /** * Get image from Canvas element */ getFromCanvas(id: string, canvas: HTMLCanvasElement): ImageData; /** * Get SVG URL by ID */ getSvgUrl(id: string): string | null; /** * Delete image by ID (decrement reference counter) */ deleteId(id: string): void; /** * Check if ID belongs to this manager */ isValidId(id: string): boolean; /** * Get all cached image IDs */ getCachedIds(): string[]; /** * Get cache statistics */ getCacheStats(): { totalImages: number; loadedImages: number; totalMemory: number; }; /** * Clear all cached images */ clear(): void; /** * Convert ImageBitmap to data URL (for export/clipboard) */ bitmapToDataUrl(imageData: ImageData): Promise; /** * Create ImageBitmap from existing ImageData for serialization */ serializeBitmap(imageData: ImageData, options?: { width?: number; height?: number; preserveAspectRatio?: boolean; }): Promise; } export declare const annotationImageManager: AnnotationImageManager; export { generateUuid, fetchImageData, isSVGFittingCanvas, validateFileSize, validateFileMimeType };