/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import type { ImageSize } from '../@types/collection-types.js'; import type { IStorageProvider, StoredFileLocation } from '../@types/storage-types.js'; import type { BylineLogger } from '../logger/index.js'; export interface ImageMeta { width: number | null; height: number | null; format: string | null; } export interface ImageVariantResult { name: string; storagePath: string; width: number | undefined; height: number | undefined; format: string; } export interface ProcessImageResult { meta: ImageMeta; variants: ImageVariantResult[]; } /** * Returns true for MIME types that should skip Sharp processing. * SVGs are vector files — Sharp cannot meaningfully resize or convert them, * and they do not benefit from the responsive-image pipeline. */ export declare function isBypassMimeType(mimeType: string): boolean; /** * Extract basic image metadata (dimensions + format) from a buffer using Sharp. * Returns nulls for non-image or unrecognised formats. */ export declare function extractImageMeta(buffer: Buffer, mimeType: string): Promise; /** * Generate the named image variants (sizes) defined in `UploadConfig.sizes` * and persist them through the configured `IStorageProvider`. * * - SVG and GIF files are skipped entirely (bypass types). * - Each variant is uploaded as a sibling object to `storedFile.storagePath`, * using the naming convention: `/-.` * (POSIX paths — both local filesystem keys and S3 object keys). * - Variant bytes are produced in-memory by Sharp and written via * `storage.upload(buffer, { targetStoragePath })` — no direct filesystem * access, so the function is provider-agnostic. * - Returns an array of `ImageVariantResult` describing what was created. */ export declare function generateImageVariants(sourceBuffer: Buffer, mimeType: string, storedFile: StoredFileLocation, storage: IStorageProvider, sizes: ImageSize[], logger?: BylineLogger): Promise;