/** * @fileoverview Probes the intrinsic dimensions of an image by parsing its * container header. For animated formats, it retains the buffer to extract * full animation data (frames, loops, and duration) upon finalization. * * Supported Web formats: PNG (incl. APNG), JPEG, GIF, WebP, BMP, ICO, CUR, AVIF, and SVG. */ import TinyBufferReader from '../utils/TinyBufferReader.mjs'; export type AnimationProbeData = { /** * - Total number of frames. */ frames: number; /** * - Number of times to loop (0 usually means infinite). */ loopCount: number; /** * - Total duration of the animation in milliseconds. */ duration: number; }; export type ImageProbeSize = { /** * - The display width in pixels. */ width: number; /** * - The display height in pixels. */ height: number; /** * - The animation data. */ animation?: AnimationProbeData; }; export type ImageFormat = { /** * - The format identifier. */ name: string; /** * - The canonical MIME type. */ mime: string; /** * - A function that tests if the provided bytes match the format's signature. */ sniff: (bytes: Uint8Array) => boolean; /** * - A function that parses the container to extract image dimensions. */ parse: (reader: TinyBufferReader) => ImageProbeSize | null; }; /** * Reads the intrinsic dimensions and animation frames of a web image from its container header. */ declare class TinyImageProbe { #private; finalize(): { animation: AnimationProbeData; } | null; /** * @param {string} [type] - The MIME type from the response headers. Unused, kept for API compatibility. * @param {number} [maxBytes] - The maximum number of header bytes to buffer. * @throws {RangeError} If `maxBytes` is not a positive number. */ constructor(type?: string, maxBytes?: number); /** * Appends a chunk and returns the dimensions once they are known. * @param {Uint8Array} chunk - The bytes received so far. * @returns {ImageProbeSize|null} The dimensions, or null when more data is needed. * @throws {TypeError} If `chunk` is not a Uint8Array. */ push(chunk: Uint8Array): ImageProbeSize | null; /** * Releases the buffered header. * @returns {void} */ close(): void; } export default TinyImageProbe; //# sourceMappingURL=TinyImageProbe.d.mts.map