UNPKG

@athenox/talos

Version:

Talos: a backend you describe instead of write. Declare a schema, write the rules in plain language, map URLs to sentences; a small built-in model turns them into query plans.

32 lines (31 loc) • 1.43 kB
/** * What an uploaded image becomes before it is stored: at most `width` × * `height` (not enlarged, unless `enlarge` or `fit: 'cover'`), re-encoded as `format` at `quality`, rotated * upright and stripped of its metadata (EXIF, GPS). `fit: 'cover'` crops to * fill the box instead (square avatars). */ export type ImageOptions = { width?: number; height?: number; fit?: 'inside' | 'cover'; format?: 'jpeg' | 'webp' | 'avif' | 'png'; quality?: number; /** keep the metadata (off by default: a phone photo carries its GPS position) */ keepMetadata?: boolean; /** enlarge a smaller image to the box; default: only with `fit: 'cover'`, whose output is always exactly the box */ enlarge?: boolean; }; /** * sharp, from the app's own dependencies — Talos does not ship an image * library, the app that stores images does. `useImages(sharp)` sets it * explicitly; otherwise it is imported by name (a literal import, so a * bundler's file tracing copies it into a production build — `.output` run on * its own had no sharp), then looked up from the working directory. */ export declare function useImages(sharp: unknown): void; export declare const extOf: (o: ImageOptions) => string | undefined; export declare function imageSize(data: Buffer): Promise<{ width?: number; height?: number; }>; export declare function processImage(data: Buffer, o: ImageOptions): Promise<Buffer>;