iiif-processor
Version:
IIIF 2.1 & 3.0 Image API modules for NodeJS
107 lines (101 loc) • 3.46 kB
text/typescript
import sharp, { Sharp } from 'sharp';
import { D as Dimensions, C as CalculatorOptions, a as Calculated, M as MaxDimensions, b as ContentResult, P as ProcessorResult, V as VersionModule } from './contracts-BZUndhBZ.mjs';
export { E as ErrorResult, R as RedirectResult } from './contracts-BZUndhBZ.mjs';
declare class IIIFError extends Error {
statusCode?: number;
constructor(message: string, opts?: {
statusCode?: number;
});
}
declare class Operations {
private keepMetadata?;
private pages;
private sharpOptions?;
private calculator;
private pageThreshold;
constructor(version: number, dims: Dimensions[], opts: CalculatorOptions & {
sharp?: Record<string, unknown>;
pageThreshold?: number;
});
region(v: string): this;
size(v: string): this;
rotation(v: string): this;
quality(v: string): this;
format(v: string, density?: number): this;
info(): Calculated;
canonicalPath(): string;
withMetadata(v: boolean): this;
private computePage;
pipeline(): Sharp;
}
type DimensionFunction = (input: {
id: string;
baseUrl: string;
}) => Promise<Dimensions | Dimensions[]>;
type StreamResolver = (input: {
id: string;
baseUrl: string;
}) => Promise<NodeJS.ReadableStream>;
type StreamResolverWithCallback = (input: {
id: string;
baseUrl: string;
}, callback: (stream: NodeJS.ReadableStream) => Promise<unknown>) => Promise<unknown>;
type ProcessorOptions = {
dimensionFunction?: DimensionFunction;
max?: {
width: number;
height?: number;
area?: number;
};
includeMetadata?: boolean;
density?: number;
debugBorder?: boolean;
iiifVersion?: number;
pageThreshold?: number;
pathPrefix?: string;
sharpOptions?: Record<string, unknown>;
request?: string;
};
declare class Processor {
private errorClass;
private Implementation;
private sizeInfo?;
private sharpOptions?;
id: string;
baseUrl: string;
version: number;
request: string;
streamResolver: StreamResolver | StreamResolverWithCallback;
filename?: string;
info?: string;
region: string;
size: string;
rotation: string;
quality: string;
format: string;
dimensionFunction: DimensionFunction;
max?: MaxDimensions;
includeMetadata: boolean;
density?: number | null;
debugBorder: boolean;
pageThreshold?: number;
constructor(url: string, streamResolver: StreamResolver | StreamResolverWithCallback, opts?: ProcessorOptions);
setOpts(opts: any): this;
initialize(streamResolver: StreamResolver | StreamResolverWithCallback): this;
withStream({ id, baseUrl }: {
id: string;
baseUrl: string;
}, callback: (s: NodeJS.ReadableStream) => Promise<unknown>): Promise<unknown>;
defaultDimensionFunction({ id, baseUrl }: {
id: string;
baseUrl: string;
}): Promise<Dimensions[]>;
dimensions(): Promise<Dimensions[]>;
infoJson(): Promise<ContentResult>;
operations(dim: Dimensions[]): Operations;
applyBorder(transformed: sharp.Sharp): Promise<sharp.Sharp>;
iiifImage(): Promise<ContentResult>;
execute(): Promise<ProcessorResult>;
}
declare const Versions: Record<2 | 3, VersionModule>;
export { ContentResult, type DimensionFunction, IIIFError, Processor, type ProcessorOptions, ProcessorResult, type StreamResolver, type StreamResolverWithCallback, Versions };