/// /// /** One `fallback` raster to produce, keyed by resource and placement size. */ export interface SvgFallbackJob { key: string; svg: Buffer; width: number; height: number; } /** * Produce the `fallback` raster for every placement of every SVG resource. * * `enabled: false` returns an empty map, so each `ImageRun` falls back to the * vector bytes exactly as it does when a raster cannot be produced. docx.js * requires the slot to be filled, so there is nothing else to put in it: the * document stays correct in Word 2016+ and in LibreOffice, and only readers * old enough to need the raster lose the image. That is the trade the caller * is making, and it is the difference between a one-second render and a * one-minute one. */ export declare function rasterizeSvgFallbacks(jobs: readonly SvgFallbackJob[], enabled?: boolean): Promise>; /** * Rasterize inline SVG for the `fallback` slot of an SVG `ImageRun`. * * Word 2016+ draws the vector, but every older Word and non-SVG consumer * renders the fallback instead — so shipping the SVG bytes under a `png` type * gave those readers a broken image. Returns `undefined` when rasterization is * unavailable or fails; the caller then keeps the historical bytes, which is * no worse than before and never fails the render. */ export declare function rasterizeSvgFallback(svg: Buffer, transformation: { width: number; height: number; }): Promise; export interface ImageDimensions { width: number; height: number; } export interface CalculatedDimensions { width: number; height: number; } export interface ImageBufferResult { buffer: Buffer; contentType?: string; } /** * Parse width value - accepts either number (pixels) or percentage string * @param width - Width value as number or percentage string (e.g., "90%") * @param availableWidthPx - Available document width in pixels * @returns Width in pixels */ export declare function parseWidthValue(width: number | string, availableWidthPx: number): number; /** * Parse a generic dimension value (number in px or percentage string) * @param value - numeric pixels or percentage string (e.g., "100%") * @param availablePx - available pixels for percentage reference */ export declare function parseDimensionValue(value: number | string, availablePx: number): number; /** * Check if a string is a valid URL */ export declare function isValidUrl(string: string): boolean; /** * Check if a string is a base64 data URI * Supports format: data:image/[type];base64,[data] */ export declare function isBase64Image(string: string): boolean; /** * Decode base64 data URI to Buffer * @param dataUri - Base64 data URI (e.g., "data:image/png;base64,iVBORw0KGgo...") * @returns Decoded image buffer */ export declare function decodeBase64Image(dataUri: string): Buffer; /** * Extract MIME type from base64 data URI * @param dataUri - Base64 data URI (e.g., "data:image/svg+xml;base64,...") * @returns MIME type (e.g., "image/svg+xml") or undefined if not found */ export declare function extractMimeTypeFromDataUri(dataUri: string): string | undefined; /** * Detect image type from file extension * @param path - File path or URL * @returns Image type (jpg, png, gif, bmp, svg) or undefined */ export declare function detectImageTypeFromExtension(path: string): 'jpg' | 'png' | 'gif' | 'bmp' | 'svg' | undefined; /** * Detect image type from MIME type * @param mimeType - MIME type string (e.g., "image/svg+xml", "image/png") * @returns Image type (jpg, png, gif, bmp, svg) or undefined */ export declare function detectImageTypeFromMimeType(mimeType: string): 'jpg' | 'png' | 'gif' | 'bmp' | 'svg' | undefined; /** * Detect image type from path or base64 data URI * Prioritizes: response Content-Type > MIME type from base64 > file extension > default to 'png' * @param imagePath - File path, URL, or base64 data URI * @param responseContentType - Optional Content-Type header from HTTP response * @returns Image type (jpg, png, gif, bmp, svg) */ export declare function detectImageType(imagePath: string, responseContentType?: string): 'jpg' | 'png' | 'gif' | 'bmp' | 'svg'; /** * Download image from URL and return buffer * Uses native fetch with automatic redirect following and proper headers * * The messages leave the URL out: every caller names the source in the error * it builds around this one, and the status alone is what this one adds. */ export declare function downloadImageFromUrl(url: string): Promise; /** * Resolve the effective image source string from image component props. * Precedence: raw inline `svg` markup (wrapped into an svg data URI) > `base64` * data URI > `path` (file/URL). Returns undefined when no source is provided. * * Raw SVG is encoded as a base64 svg+xml data URI so it flows through the same * pipeline as any other source (getImageBuffer / detectImageType / dimensions). */ export declare function resolveImageSource(props: { svg?: string; base64?: string; path?: string; }): string | undefined; /** * Get image buffer from base64 data URI, URL, or local file */ export declare function getImageBuffer(imagePath: string): Promise; /** * Get the dimensions of an image file or URL */ export declare function getImageDimensions(imagePath: string): Promise; /** * Get the dimensions of bytes already in hand. * * The point is that it takes bytes rather than a location. A caller that has * loaded an image and then asks `getImageDimensions` for its size fetches the * same URL twice — doubling the network traffic, and, if the response changes * between the two, embedding one image while sizing it from another (#267). * `label` is only used in the message. */ export declare function readImageDimensions(bytes: Buffer, label: string): ImageDimensions; /** * Calculate missing dimension while preserving aspect ratio */ export declare function calculateMissingDimension(originalWidth: number, originalHeight: number, targetWidth?: number, targetHeight?: number): CalculatedDimensions; /** * Calculate image dimensions with aspect ratio preservation and fallback constraints */ export declare function calculateImageDimensions(imagePath: string, targetWidth?: number, targetHeight?: number, fallbackWidth?: number, fallbackHeight?: number): Promise; //# sourceMappingURL=imageUtils.d.ts.map