import { type MediaCropSource } from '../content/imageCrop.js'; import { type MediaVariant } from '../content/imageVariants.js'; /** * Structural type for the Cloudflare Images binding — only the surface actually used, declared * locally so `@taprootcms/core` does not need `@cloudflare/workers-types` installed downstream. * Same reason and same shape as `R2BucketLike`. */ export interface ImagesBindingLike { input(stream: ReadableStream | ArrayBuffer | Uint8Array): ImageTransformerLike; } export interface ImageTransformerLike { transform(options: { width?: number; height?: number; fit?: string; trim?: { top?: number; left?: number; width?: number; height?: number; }; }): ImageTransformerLike; output(options: { format?: string; quality?: number; }): Promise; } export interface ImageResultLike { image(): ReadableStream; contentType(): string; } export declare function isResizable(mimeType: string): boolean; /** * Resize stored bytes, or answer `undefined` to mean "serve what you already have". * * **Every failure here is a fallback, never an error.** A transform that throws — an unsupported * source, a monthly transformation allowance reached, a binding that is not present because the * deployment is Node or the operator has not added it — must produce the original image rather than * a broken one. An image is the part of a page a visitor most visibly loses, and no resize is worth * a 500 on it. The caller gets `undefined` and serves the stored object exactly as it did before * this existed, which is also what makes the whole feature safe to ship to deployments that cannot * use it. * * `fit: 'scale-down'` is what stops an enlargement. `variantWidthsFor` already declines to offer a * rung above the source, but that is a claim about what a *cooperating* consumer asks for, and this * route answers whatever arrives in a URL. */ export declare function resizeImage(images: ImagesBindingLike | undefined, bytes: Uint8Array, sourceMimeType: string, variant: MediaVariant, source?: MediaCropSource): Promise<{ bytes: ReadableStream; contentType: string; } | undefined>;