UNPKG

@thi.ng/imago

Version:

JSON & API-based declarative and extensible image processing trees/pipelines

43 lines 1.71 kB
import type { Maybe } from "@thi.ng/api"; import type { Metadata } from "sharp"; import { type Color, type Dim, type Gravity, type IntBufferLike, type Position, type Sides, type Size, type SizeRef, type SizeUnit } from "./api.js"; export declare const isIntBufferLike: (x: any) => x is IntBufferLike; export declare const ensureSize: (meta: Metadata) => false; export declare const coerceColor: (col: Color) => string | { r: number; g: number; b: number; alpha?: number; }; /** * * @remarks * The given `size` MUST already be resolved (in pixels), e.g. via an earlier * call to {@link computeSize}. `parentSize` is also in pixels. * * @param size * @param parentSize * @param opts */ export declare const positionOrGravity: ([w, h]: Dim, parentSize: Dim, { pos, gravity, origin, ref, unit, }: { pos?: Position; gravity?: Gravity; origin?: Gravity; ref?: SizeRef; unit?: SizeUnit; }) => { gravity: string; left?: undefined; top?: undefined; } | { left: Maybe<number>; top: Maybe<number>; gravity?: undefined; } | undefined; export declare const gravityFlags: (gravity: Gravity) => boolean[]; export declare const gravityPosition: (gravity: Gravity, [w, h]: Dim, [parentW, parentH]: Dim) => number[]; export declare const refSize: ([w, h]: Dim, ref?: SizeRef) => Dim; export declare const computeSize: (size: Size, curr: Dim, ref?: SizeRef, unit?: SizeUnit) => Dim; export declare const computeSizeWithAspect: (size: number, [w, h]: Dim, aspect: number, unit?: SizeUnit, clamp?: boolean) => Dim; export declare const computeMargins: (size: Size | Sides, curr: Dim, ref?: SizeRef, unit?: SizeUnit) => Sides; //# sourceMappingURL=utils.d.ts.map