// Generated by dts-bundle v0.7.3 // Dependencies for this module: // ../rxjs import { Observable, Subject } from 'rxjs'; import { Subject } from 'rxjs'; export interface ImgstryBrowserOptions { thread: ImgstryThreadOptions; } /** * (Exposes image processing methods for html canvas) * * @export * @class Imgstry * @extends {ImgstryEditor} * @implements {IDisposable} */ export declare class Imgstry extends ImgstryEditor implements IDisposable { readonly canvas: HTMLCanvasElement; static getCanvas: (selector: string | HTMLCanvasElement) => HTMLCanvasElement; static loadImage: (src: string) => Promise; readonly context: CanvasRenderingContext2D; draw$: Subject; histogram$: Observable; get width(): number; get height(): number; /** * Creates an instance of Imgstry. * * @param {HTMLCanvasElement} canvas (specifies the canvas base for imgstry) * @param {Partial} _options (specifies the canvas base for imgstry) * @constructor */ constructor(canvas: HTMLCanvasElement, _options?: Partial); /** * Draws an image on the canvas. * * @param {HTMLImageElement} image The source image that will be drawn on the canvas. * @memberof Imgstry * @returns {void} */ drawImage(image: HTMLImageElement): void; /** * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. * * @param {string} [type='image/png'] The standard MIME type for the image format to return. * If you do not specify this parameter, the default value is a PNG format image. * @returns {string} The image encoded as a data url. * @memberof Imgstry */ toDataUrl(type?: string): string; reset(): ImgstryProcessor; clone(source: ImageData): ImageData; createImageData(source: ImageData): ImageData; get imageData(): ImageData; set imageData(image: ImageData); renderSync(target?: RenderTarget): Imgstry; render(target?: RenderTarget): Promise; /** * Destroys the thread and clears the canvas of data. * * @memberof Imgstry * @returns {void} */ dispose(): void; } /** * Core logic for the imgstry editor. * Defines all the processing logic. * * @export * @abstract * @class ImgstryProcessor * @ignore */ export declare abstract class ImgstryProcessor { /** * Width of the image. * * @type {number} * @memberOf ImgstryProcessor */ abstract width: number; /** * Height of the image. * * @type {number} * @memberOf ImgstryProcessor */ abstract height: number; /** * Original copy of the processed image. * * @type {ImageData} * @memberOf ImgstryProcessor */ protected _original: ImageData | null; /** * Encodes the canvas data to a data URI. * * @param {string} type The standard MIME type for the image format to return. * If you do not specify this parameter, the default value is a PNG format image. * @returns {string} The image encoded as a data url. * @memberof Imgstry */ abstract toDataUrl(type: string): string; /** * Resets the image to the original state. * * @abstract * @returns {ImgstryProcessor} The current processor instance. * * @memberOf ImgstryProcessor */ abstract reset(): ImgstryProcessor; /** * Clone image data * * @abstract * @param {ImageData} source The source image data. * @returns {ImageData} The cloned canvas image data. * @memberOf ImgstryProcessor */ abstract clone(source: ImageData): ImageData; /** * Create image data based on a source * * @abstract * @param {ImageData} source The source image data. * @returns {ImageData} The new image data. * @memberOf ImgstryProcessor */ abstract createImageData(source: ImageData): ImageData; /** * Gets the image data. * * @abstract * @type {ImageData} * @memberOf ImgstryProcessor */ abstract get imageData(): ImageData; /** * Sets the image data. * * @abstract * * @memberOf ImgstryProcessor */ abstract set imageData(imgData: ImageData); /** * Returns the channel histogram of the image. * * @readonly * @type {HistogramData} * @memberof ImgstryProcessor */ get histogram(): HistogramData; /** * Applies a series of filters to the image. * * @param {OperationOption[]} options The set of operations. * @param {boolean} [reset] If the image should be reset to its original state before applying operations. * @returns {ImgstryProcessor} The current processor instance * @memberof ImgstryProcessor */ batch(options: OperationOption[], reset?: boolean): ImgstryProcessor; } /** * Defines the imgstry editor schema. * * @export * @interface ImgstryEditor * @template T */ export declare abstract class ImgstryEditor extends ImgstryProcessor { protected _operations: OperationOption[]; /** * Turn the image black and white with the provided ratio. * * @param {[number, number, number]} [ratio] an array of rations for each RGB channel the total sum must be 1 * @returns {T} the current editor instance * @memberof ImgstryEditor */ blackAndWhite(ratio?: [number, number, number]): ImgstryEditor; /** * Increase / decrease image constrast. * * @param {number} value contrast intensity * @returns {T} the current editor instance * @memberof ImgstryEditor */ contrast(value: number): ImgstryEditor; /** * Increase / decrease image brightness. * * @param {number} value brightness intensity * @returns {T} the current editor instance * @memberof ImgstryEditor */ brightness(value: number): ImgstryEditor; /** * Increase / decrease image saturation. * * @param {number} value saturation intensity * @returns {T} the current editor instance * @memberof ImgstryEditor */ saturation(value: number): ImgstryEditor; /** * Shift the image hue. * * @param {number} value hue shift value (-180, 180) * @returns {T} the current editor instance * @memberof ImgstryEditor */ hue(value: number): ImgstryEditor; /** * Apply sepia with the specified intensity. * * @param {number} value desired intensity of the sepia effect * @returns {T} the current editor instance * @memberof ImgstryEditor */ sepia(value: number): ImgstryEditor; /** * Increase / decrease image gamma. * * @param {number} value gamma intensity * @returns {T} the current editor instance * @memberof ImgstryEditor */ gamma(value: number): ImgstryEditor; /** * Add a provided amount of noise to the image. * * @param {number} value noise amount * @returns {T} the current editor instance * @memberof ImgstryEditor */ noise(value: number): ImgstryEditor; /** * Increase / decrease image vibrance. * * @param {number} value vibrance intensity * @returns {T} the current editor instance * @memberof ImgstryEditor */ vibrance(value: number): ImgstryEditor; /** * Invert the image colors. * * @returns {T} the current editor instance * @memberof ImgstryEditor */ invert(): ImgstryEditor; /** * Apply a color tint to the image. * * @param {string} color the hex color code of the desired tint * @returns {T} the current editor instance * @memberof ImgstryEditor */ tint(color: string): ImgstryEditor; /** * Fill the canvas with a color. * * @param {string} color the hex color code of the desired tint * @returns {T} the current editor instance * @memberof ImgstryEditor */ fill(color: string): ImgstryEditor; /** * Apply a kernel to the active image * * @param {Kernel | Array} kernel a square matrice that will be applied to the image * @returns {T} the current editor instance * @memberof ImgstryEditor */ convolve(kernel: Kernel | number[][]): ImgstryEditor; /** * Clears the operation list. * * @returns {T} the current editor instance * @memberof ImgstryEditor */ clear(): this; /** * Apply the requested operations to the image. * * @param {RenderTarget} target the processing target * @returns {T} the current editor instance * @memberof ImgstryEditor */ renderSync(target?: RenderTarget): ImgstryEditor; /** * Apply the requested operations to the image using a worker thread. * * @param {RenderTarget} target the processing target * @returns {Promise} a promise that resolves in the current editor instance * @memberof ImgstryEditor */ abstract render(target: RenderTarget): Promise; } export declare namespace Operation { const DEFAULT: { blackAndWhite: { ratio: [number, number, number]; }; rgb: { max: number; min: number; }; }; const lookup: (lut: Record) => (pixel: Rgb) => Rgb; const hue: (value: number) => (pixel: Rgb) => Rgb; const sepia: (value: number) => (pixel: Rgb) => Rgb; const gamma: (value: number) => (pixel: Rgb) => Rgb; const noise: (value: number) => (pixel: Rgb) => Rgb; const vibrance: (value: number) => (pixel: Rgb) => Rgb; const invert: () => (pixel: Rgb) => Rgb; const tint: (color: string) => (pixel: Rgb) => Rgb; const fill: (color: string) => () => Rgb; const blackAndWhite: ([rRatio, gRatio, bRatio]?: [number, number, number]) => (pixel: Rgb) => Rgb; const contrast: (value: number) => (pixel: Rgb) => Rgb; const brightness: (value: number) => (pixel: Rgb) => Rgb; const saturation: (value: number) => (pixel: Rgb) => Rgb; } /** * Thread execution data. * * @export * @interface IThreadData * @extends {IThreadResult} */ export interface IThreadData extends IThreadResult { operations: OperationOption[]; } /** * Thread result data. * * @export * @interface IThreadResult */ export interface IThreadResult { imageData: ImageData; guid?: string; } /** * Defines the imgstry thread schema. * * @export * @interface ImgstryThread */ export interface IImgstryThread { /** * Starts a worker thread and initiates the request operations. * * @param {IThreadData} { * imageData, * operations, * } * @returns {Promise} * @memberof ImgstryThread */ run({ imageData, operations, }: IThreadData): Promise; } /** * Holds a collection of operation method names. * * @type OperationMethod */ export declare type OperationMethod = keyof typeof Operation | 'convolve'; /** * Defines possible operation values. */ export declare type OperationValue = number | string | [number, number, number] | Kernel | number[][] | null; /** * Imgstry filter option defintion * * @interface FilterOption */ export interface OperationOption { /** * Applied filter method * * @type {string} * @memberOf FilterOption */ name: OperationMethod; /** * Applied filter value * * @type {(number | string)} * @memberOf FilterOption */ value: OperationValue; /** * Evalution priority * * @type {number} * @memberOf FilterOption */ priority: number; } /** * Histogram data arrays. * * @export * @interface HistogramData */ export interface HistogramData { /** * Global channel distribution * * @type {number[]} * @memberof HistogramData */ all: number[]; /** * Color distribution per channel. * * @type {{ * red: number[], * green: number[], * blue: number[], * }} * @memberof HistogramData */ channel: { red: number[]; green: number[]; blue: number[]; }; } /** * Defines the traverse information passed to the delegate. * * @interface TraversalPixelInfo */ export interface TraversalPixelInfo { /** * Holds the pixel position information. * * @type {{ * x: number; * y: number; * offset: number; * }} * @memberof TraversalPixelInfo */ position: { x: number; y: number; offset: number; }; /** * Total number of pixels in the image. * * @type {number} * @memberof TraversalPixelInfo */ total: number; } export declare type RenderTarget = 'current' | 'original'; /** * Browser thread option contract. * * @export * @interface ImgstryThreadOptions */ export interface ImgstryThreadOptions { isEnabled?: boolean; isDebugEnabled?: boolean; } /** * Thread communication layer for the browser. * * @export * @class ImgstryThread * @implements {IImgstryThread} * @implements {IDisposable} * @ignore */ export declare class ImgstryThread implements IImgstryThread, IDisposable { process$: Subject; /** * Creates an instance of ImgstryThread. * @param {ImgstryThreadOptions} _options The thread options. * @memberof ImgstryThread {isEnabled, isDebugEnabled} * @constructor */ constructor(_options: ImgstryThreadOptions); /** * Queues a new set of operations, throttled @ 250ms. * * @param {IThreadData} data { * imageData, * operations, * } * @returns {Promise} A promise with the resulting image. * @memberof ImgstryThread */ run({ imageData, operations, }: IThreadData): Promise; /** * Terminates the current worker thread and completes active streams. * * @memberof ImgstryThread * @returns {void} */ dispose(): void; } /** * Internal web worker data definition. * * @export * @interface IWorkerData * @extends {IWorkerResult} * @ignore */ export interface IWorkerData extends IWorkerResult { operations: OperationOption[]; } /** * Internal web worker result definition. * * @export * @interface IWorkerResult * @ignore */ export interface IWorkerResult { buffer: ArrayBuffer; width: number; height: number; guid: string; } export interface IDisposable { dispose(): void; } export interface KernelIndex { x: number; y: number; } export declare class Kernel { width: number; height: number; constructor(_kernel: number[][]); forEach(delegate: (value: number, index: KernelIndex) => void): void; } /** * * * @export * @class Pixel * @template IColor */ export declare class Pixel implements IPoint { color?: T | undefined; get x(): number; set x(value: number); get y(): number; set y(value: number); get colorSpace(): ColorSpace; constructor(_x: number, _y: number, color?: T | undefined); } export declare const EdgeDetection: () => number[][]; export declare const GaussianBlur: (radius?: number, sigma?: number) => number[][]; export declare enum ColorSpace { Empty = "Empty", Rgb = "Rgb", Cmyk = "Cmyk", Hex = "Hex", Hsv = "Hsv" } /** * Color interface, describes a colorspace. * * @export * @interface IColor */ export interface IColor { /** * Returns the colorspace value associated to this color. * * @type {ColorSpace} * @memberof IColor */ kind: ColorSpace; /** * Converts the color to HSV. * * @returns {IColor} * @memberof IColor */ toHsv(): IColor; /** * Converts the color to RGB. * * @returns {IColor} * @memberof IColor */ toRgb(): IColor; /** * Converts the color to CMYK. * * @returns {IColor} * @memberof IColor */ toCmyk(): IColor; /** * Converts the color to HEX. * * @returns {IColor} * @memberof IColor */ toHex(): IColor; /** * Clamps the color values to prevent bleeding. * * @returns {IColor} * @memberof IColor */ clamp(): IColor; } export interface ICmyk { c: number; m: number; y: number; k: number; } /** * CMYK colorspace. * * @export * @class Cmyk * @implements {IColor} */ export declare class Cmyk implements IColor { c: number; m: number; y: number; k: number; get kind(): ColorSpace; constructor({ c, m, y, k }?: ICmyk); toRgb(): Rgb; toHsv(): Hsv; toCmyk(): Cmyk; toHex(): Hex; clamp(): Cmyk; } export interface IRgb { r: number; g: number; b: number; } /** * Rgb colorspace. * * @export * @class Rgb * @implements {IColor} */ export declare class Rgb implements IRgb, IColor { r: number; g: number; b: number; get kind(): ColorSpace; constructor({ r, g, b }?: IRgb); toHsv(): Hsv; toRgb(): Rgb; toCmyk(): Cmyk; toHex(): Hex; clamp(): Rgb; } export interface IHsv { h: number; s: number; v: number; } /** * HSV colorspace. * * @export * @class Hsv * @implements {IColor} */ export declare class Hsv implements IColor { h: number; s: number; v: number; get kind(): ColorSpace; constructor({ h, s, v }?: IHsv); toRgb(): Rgb; toHsv(): Hsv; toCmyk(): Cmyk; toHex(): Hex; clamp(): Hsv; } /** * HEX colorspace. * * @export * @class Hex * @implements {IColor} */ export declare class Hex implements IColor { value: string; get kind(): ColorSpace; constructor(color?: string); toRgb(): Rgb; toHsv(): Hsv; toCmyk(): Cmyk; toHex(): Hex; clamp(): Hex; } export interface IPoint { x: number; y: number; } export declare class Point implements IPoint { x: number; y: number; constructor({ x, y }?: IPoint); distanceTo: (point: IPoint) => number; } export interface IPointResult { index: number; point: IPoint | null; } export declare class SplinePointSet implements Iterable { static get notFound(): IPointResult; get first(): Point; get length(): number; constructor(points?: IPoint[]); [Symbol.iterator](): { next: () => IteratorResult; }; push(...points: IPoint[]): number; update(index: number, { x, y }: IPoint): IPointResult; find: (point: IPoint) => IPointResult; forEach: (predicateFn: (value: Point, index: number) => void) => void; remove(index: number): Point | undefined; indexOfClosest(coordinate: IPoint, maxRange: number, transform: (p: IPoint) => IPoint): number; closest: (coordinate: IPoint, maxRange: number, transform: (p: IPoint) => IPoint) => IPointResult; }