/** * Image Transformation Service * * Provides on-the-fly image resize, crop, format conversion, and quality * adjustment using the `sharp` library. Results are cached in an LRU * in-memory cache to avoid redundant processing. */ /** Options that can be specified via query parameters. */ export interface ImageTransformOptions { width?: number; height?: number; quality?: number; format?: "webp" | "avif" | "jpeg" | "png"; fit?: "cover" | "contain" | "fill" | "inside" | "outside"; } /** * Parse transform options from URL query parameters. * Returns `null` when no transformation is requested. */ export declare function parseTransformOptions(query: Record): ImageTransformOptions | null; /** Check whether a content type is a transformable image. */ export declare function isTransformableImage(contentType: string): boolean; /** * Apply image transformations and return the result buffer + content type. */ export declare function transformImage(buffer: Buffer | Uint8Array, options: ImageTransformOptions): Promise<{ data: Buffer; contentType: string; }>; /** * Simple LRU cache for transformed images. * * Entries expire after `maxAgeMs` (default: 1 hour) and the cache * evicts the oldest entry when `maxEntries` is exceeded. */ export declare class TransformCache { private cache; private readonly maxEntries; private readonly maxAgeMs; private readonly maxTotalBytes; private totalBytes; constructor(maxEntries?: number, maxAgeMs?: number, maxTotalBytes?: number); /** Build a deterministic cache key from file key + transform options. */ buildKey(fileKey: string, options: ImageTransformOptions): string; get(cacheKey: string): { data: Buffer; contentType: string; } | null; set(cacheKey: string, data: Buffer, contentType: string): void; }