diff --git a/src/defines/magick-define.ts b/src/defines/magick-define.ts index 76379c10..72dfa56c 100644 --- a/src/defines/magick-define.ts +++ b/src/defines/magick-define.ts @@ -5,7 +5,7 @@ import { IDefine } from './define'; import { MagickFormat } from '../magick-format'; export class MagickDefine implements IDefine { - constructor (format: MagickFormat, name: string, value: string) { + constructor(format: MagickFormat, name: string, value: string) { this.format = format; this.name = name; this.value = value; diff --git a/src/formats/dng/dng-read-defines.ts b/src/formats/dng/dng-read-defines.ts index 029c7e97..ade7dfbf 100644 --- a/src/formats/dng/dng-read-defines.ts +++ b/src/formats/dng/dng-read-defines.ts @@ -7,8 +7,8 @@ import { IDefine } from '../../defines/define'; import { MagickFormat } from '../../magick-format'; export class DngReadDefines extends DefinesCreator { - constructor () { - super(MagickFormat.Dng); + constructor() { + super(MagickFormat.Dng); } disableAutoBrightness?: boolean; diff --git a/src/gravity.ts b/src/gravity.ts index 5512eaf7..c2803328 100644 --- a/src/gravity.ts +++ b/src/gravity.ts @@ -18,7 +18,7 @@ export enum Gravity { /** @internal */ export function* _getEdges(gravities: Gravity[]): Generator { for (const gravity of gravities) { - switch(gravity) { + switch (gravity) { case Gravity.North: yield 'north' break diff --git a/src/image-magick.ts b/src/image-magick.ts index 111d820f..2a8cd8f3 100644 --- a/src/image-magick.ts +++ b/src/image-magick.ts @@ -68,7 +68,7 @@ export class ImageMagick { /** @internal */ async _initialize(wasmLocationOrData?: string | ByteArray): Promise { await this.loader(wasmLocationOrData); - } + } /** @internal */ static get _api(): ImageMagickApi { @@ -97,7 +97,7 @@ export class ImageMagick { static read(fileName: string, settings: MagickReadSettings, func: (image: IMagickImage) => Promise): Promise; static read(fileName: string, func: (image: IMagickImage) => TReturnType): TReturnType; static read(fileName: string, func: (image: IMagickImage) => Promise): Promise; - static read(colorOrArrayOrFileName: MagickColor | ByteArray | string, widthOrFormatOrSetttingsOrFunc: number | MagickFormat | MagickReadSettings | ((image: IMagickImage) => TReturnType | Promise) , heightOrFunc?: number | ((image: IMagickImage) => TReturnType | Promise), func?: (image: IMagickImage) => TReturnType | Promise): TReturnType | Promise { + static read(colorOrArrayOrFileName: MagickColor | ByteArray | string, widthOrFormatOrSetttingsOrFunc: number | MagickFormat | MagickReadSettings | ((image: IMagickImage) => TReturnType | Promise), heightOrFunc?: number | ((image: IMagickImage) => TReturnType | Promise), func?: (image: IMagickImage) => TReturnType | Promise): TReturnType | Promise { return MagickImage._use(image => { let callback = func; if (colorOrArrayOrFileName instanceof MagickColor) { diff --git a/src/internal/disposable-array.ts b/src/internal/disposable-array.ts index ba6b853a..6824c6f3 100644 --- a/src/internal/disposable-array.ts +++ b/src/internal/disposable-array.ts @@ -16,11 +16,11 @@ export class DisposableArray implements IDisposable { this._bytes = ImageMagick._api.HEAPU8.subarray(pointer, pointer + length); } - func(array : DisposableArray): TReturnType | Promise { + func(array: DisposableArray): TReturnType | Promise { if (array._bytes === undefined) return array._func(new Uint8Array()); else - return array._func(array._bytes); + return array._func(array._bytes); } dispose(): void { diff --git a/src/internal/disposable.ts b/src/internal/disposable.ts index 6900b9e2..fc44df92 100644 --- a/src/internal/disposable.ts +++ b/src/internal/disposable.ts @@ -21,7 +21,7 @@ export class Disposable { } } catch (error) { instance.dispose(); - throw(error); + throw (error); } } } diff --git a/src/internal/exception/exception.ts b/src/internal/exception/exception.ts index 944e24c9..4e37e2e3 100644 --- a/src/internal/exception/exception.ts +++ b/src/internal/exception/exception.ts @@ -86,8 +86,7 @@ export class Exception { return error; const relatedErrors: MagickError[] = []; - for (let i = 0; i < nestedCount; i++) - { + for (let i = 0; i < nestedCount; i++) { const related = ImageMagick._api._MagickExceptionHelper_Related(exception, i); const relatedSeverity = Exception.getErrorSeverity(related); const relatedError = Exception.createError(related, relatedSeverity); diff --git a/src/internal/magick-rectangle.ts b/src/internal/magick-rectangle.ts index f8903c2e..9c30c756 100644 --- a/src/internal/magick-rectangle.ts +++ b/src/internal/magick-rectangle.ts @@ -17,8 +17,8 @@ export class MagickRectangle { let width = geometry.width; let height = geometry.height; if (geometry.isPercentage) { - width = new Percentage(geometry.width).multiply(image.width); - height = new Percentage(geometry.height).multiply(image.height); + width = new Percentage(geometry.width).multiply(image.width); + height = new Percentage(geometry.height).multiply(image.height); } ImageMagick._api._MagickRectangle_Width_Set(rectangle, width); diff --git a/src/log-event-types.ts b/src/log-event-types.ts index fb6b437c..78c5bbe5 100644 --- a/src/log-event-types.ts +++ b/src/log-event-types.ts @@ -1,8 +1,7 @@ // Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. // Licensed under the Apache License, Version 2.0. -export enum LogEventTypes -{ +export enum LogEventTypes { None = 0x000000, Accelerate = 0x00001, Annotate = 0x00002, diff --git a/src/magick-geometry.ts b/src/magick-geometry.ts index bef28b4d..25668771 100644 --- a/src/magick-geometry.ts +++ b/src/magick-geometry.ts @@ -43,7 +43,7 @@ export class MagickGeometry { } else { const instance = ImageMagick._api._MagickGeometry_Create(); try { - _withString(widthOrValueOrX, valuePtr => { + _withString(widthOrValueOrX, valuePtr => { const flags = ImageMagick._api._MagickGeometry_Initialize(instance, valuePtr); if (flags === GeometryFlags.NoValue) throw new MagickError('invalid geometry specified'); diff --git a/src/magick-image.ts b/src/magick-image.ts index fd81884d..6d92da62 100644 --- a/src/magick-image.ts +++ b/src/magick-image.ts @@ -83,7 +83,7 @@ export interface IMagickImage extends IDisposable { colorFuzz: Percentage; colormapSize: number; colorSpace: ColorSpace; - colorType : ColorType; + colorType: ColorType; comment: string | null; compose: CompositeOperator; readonly compression: CompressionMethod; @@ -500,7 +500,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { get interlace(): Interlace { return ImageMagick._api._MagickImage_Interlace_Get(this._instance); } - get interpolate(): PixelInterpolateMethod { return ImageMagick._api._MagickImage_Interpolate_Get(this._instance);} + get interpolate(): PixelInterpolateMethod { return ImageMagick._api._MagickImage_Interpolate_Get(this._instance); } set interpolate(value: PixelInterpolateMethod) { ImageMagick._api._MagickImage_Interpolate_Set(this._instance, value); } get label(): string | null { @@ -619,7 +619,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { const channels = this.valueOrDefault(channelsOrUndefined, Channels.Undefined); Exception.use(exception => { - ImageMagick._api._MagickImage_BrightnessContrast(this._instance, brightness.toDouble(), contrast.toDouble(), channels, exception.ptr); + ImageMagick._api._MagickImage_BrightnessContrast(this._instance, brightness.toDouble(), contrast.toDouble(), channels, exception.ptr); }); } @@ -634,7 +634,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { charcoal(radius: number, sigma: number): void; charcoal(radiusOrUndefined?: number, sigmaOrUndefined?: number): void { const radius = radiusOrUndefined === undefined ? 0 : radiusOrUndefined; - const sigma =sigmaOrUndefined === undefined ? 1 :sigmaOrUndefined; + const sigma = sigmaOrUndefined === undefined ? 1 : sigmaOrUndefined; Exception.use(exception => { const instance = ImageMagick._api._MagickImage_Charcoal(this._instance, radius, sigma, exception.ptr); this._setInstance(instance, exception); @@ -688,7 +688,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { composite(image: IMagickImage, compose: CompositeOperator, point: Point, channels: Channels): void; composite(image: IMagickImage, compose: CompositeOperator, point: Point, args: string): void; composite(image: IMagickImage, compose: CompositeOperator, point: Point, args: string, channels: Channels): void; - composite(image: IMagickImage, composeOrPoint?: CompositeOperator | Point, pointOrArgsOrChannels?: Point | string | Channels, channelsOrArgs?: Channels | string, channelsOrUndefined?: Channels): void { + composite(image: IMagickImage, composeOrPoint?: CompositeOperator | Point, pointOrArgsOrChannels?: Point | string | Channels, channelsOrArgs?: Channels | string, channelsOrUndefined?: Channels): void { let x = 0; let y = 0; let compose = CompositeOperator.In; @@ -741,7 +741,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, channels: Channels): void; compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string): void; compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string, channels: Channels): void; - compositeGravity(image: IMagickImage, gravity: Gravity, composeOrPoint?: CompositeOperator | Point, pointOrArgsOrChannels?: Point | string | Channels, channelsOrArgs?: Channels | string, channelsOrUndefined?: Channels): void { + compositeGravity(image: IMagickImage, gravity: Gravity, composeOrPoint?: CompositeOperator | Point, pointOrArgsOrChannels?: Point | string | Channels, channelsOrArgs?: Channels | string, channelsOrUndefined?: Channels): void { let x = 0; let y = 0; let compose = CompositeOperator.In; @@ -833,8 +833,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { }); } - cropToTiles(geometry: MagickGeometry): IMagickImageCollection - { + cropToTiles(geometry: MagickGeometry): IMagickImageCollection { return Exception.use(exception => { return _withString(geometry.toString(), geometryPtr => { const images = ImageMagick._api._MagickImage_CropToTiles(this._instance, geometryPtr, exception.ptr); @@ -1236,7 +1235,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { }); } - separate(func: (images: IMagickImageCollection) => TReturnType ): TReturnType; + separate(func: (images: IMagickImageCollection) => TReturnType): TReturnType; separate(func: (images: IMagickImageCollection) => Promise): Promise; separate(func: (images: IMagickImageCollection) => TReturnType, channels: Channels): TReturnType; separate(func: (images: IMagickImageCollection) => Promise, channels: Channels): Promise; @@ -1334,7 +1333,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { Exception.use(exception => { const instance = ImageMagick._api._MagickImage_Splice(this._instance, geometryPtr, exception.ptr); this._setInstance(instance, exception); - }); + }); }); } @@ -1344,7 +1343,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { const channels = this.valueOrDefault(channelsOrUndefined, Channels.Default); return Exception.usePointer(exception => { const list = ImageMagick._api._MagickImage_Statistics(this._instance, channels, exception); - const statistics = Statistics._create(this, list, channels); + const statistics = Statistics._create(this, list, channels); ImageMagick._api._Statistics_DisposeList(list); return statistics; }); @@ -1564,7 +1563,7 @@ export class MagickImage extends NativeInstance implements IMagickImage { private readOrPing(ping: boolean, fileNameOrArrayOrColor: string | ByteArray | MagickColor, settingsOrWidthOrUndefined?: MagickReadSettings | number, heightOrUndefined?: number): void { Exception.use(exception => { - const readSettings = settingsOrWidthOrUndefined instanceof MagickReadSettings ? settingsOrWidthOrUndefined : new MagickReadSettings(this._settings); + const readSettings = settingsOrWidthOrUndefined instanceof MagickReadSettings ? settingsOrWidthOrUndefined : new MagickReadSettings(this._settings); readSettings._ping = ping; this._settings._ping = ping; diff --git a/src/magick.ts b/src/magick.ts index 31dfd63b..20d64a30 100644 --- a/src/magick.ts +++ b/src/magick.ts @@ -41,7 +41,7 @@ export class Magick { } const eventTypeString = Magick.getEventTypeString(eventTypes); - _withString(eventTypeString, instance => ImageMagick._api._Magick_SetLogEvents(instance)); + _withString(eventTypeString, instance => ImageMagick._api._Magick_SetLogEvents(instance)); } /** @internal */ @@ -89,7 +89,7 @@ export class Magick { case LogEventTypes.Wand: return 'Wand'; case LogEventTypes.None: default: - return 'None'; + return 'None'; } } } diff --git a/src/pixel-intensity-method.ts b/src/pixel-intensity-method.ts index 73ceb719..d92dfad5 100644 --- a/src/pixel-intensity-method.ts +++ b/src/pixel-intensity-method.ts @@ -1,8 +1,7 @@ // Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. // Licensed under the Apache License, Version 2.0. -export enum PixelIntensityMethod -{ +export enum PixelIntensityMethod { Undefined, Average, Brightness, diff --git a/src/pixels/pixel-collection.ts b/src/pixels/pixel-collection.ts index b4651e69..482f337b 100644 --- a/src/pixels/pixel-collection.ts +++ b/src/pixels/pixel-collection.ts @@ -44,7 +44,7 @@ export class PixelCollection extends NativeInstance implements IPixelCollection static _use(image: IMagickImage, func: (pixels: IPixelCollection) => TReturnType): TReturnType; /** @internal */ static _use(image: IMagickImage, func: (pixels: IPixelCollection) => Promise): Promise; - static _use(image: IMagickImage, func: (pixels: IPixelCollection) => TReturnType | Promise): TReturnType | Promise{ + static _use(image: IMagickImage, func: (pixels: IPixelCollection) => TReturnType | Promise): TReturnType | Promise { const pixels = new PixelCollection(image); return Disposable._disposeAfterExecution(pixels, func); } diff --git a/src/primary-info.ts b/src/primary-info.ts index f8fdaa19..f5e76e28 100644 --- a/src/primary-info.ts +++ b/src/primary-info.ts @@ -4,9 +4,9 @@ import { ImageMagick } from "./image-magick"; export class PrimaryInfo { - private _x : number; - private _y : number; - private _z : number; + private _x: number; + private _y: number; + private _z: number; constructor(x: number, y: number, z: number) { this._x = x; diff --git a/src/settings/magick-settings.ts b/src/settings/magick-settings.ts index 591be4e6..bfd94eb0 100644 --- a/src/settings/magick-settings.ts +++ b/src/settings/magick-settings.ts @@ -68,8 +68,8 @@ export class MagickSettings { return this._options[nameOrFormat] ?? null; } - setDefine(name: string, value: string ): void; - setDefine(format: MagickFormat, name: string, value: string ): void; + setDefine(name: string, value: string): void; + setDefine(format: MagickFormat, name: string, value: string): void; setDefine(format: MagickFormat, name: string, value: number): void; setDefine(format: MagickFormat, name: string, value: boolean): void; setDefine(nameOrFormat: MagickFormat | string, nameOrValue: string, value?: string | number | boolean): void { @@ -98,7 +98,7 @@ export class MagickSettings { const clone = new MagickSettings(); Object.assign(clone, this); return clone; - } + } /** @internal */ _use(func: (settings: NativeMagickSettings) => TReturnType): TReturnType { diff --git a/src/settings/montage-settings.ts b/src/settings/montage-settings.ts index c90b1fce..6c26bdfd 100644 --- a/src/settings/montage-settings.ts +++ b/src/settings/montage-settings.ts @@ -8,13 +8,13 @@ import { MagickGeometry } from '../magick-geometry'; import { NativeMontageSettings } from './native-montage-settings'; export class MontageSettings { - backgroundColor? : MagickColor; + backgroundColor?: MagickColor; - borderColor? : MagickColor; + borderColor?: MagickColor; borderWidth?: number; - fillColor? : MagickColor; + fillColor?: MagickColor; font?: string; @@ -30,7 +30,7 @@ export class MontageSettings { shadow?: boolean; - strokeColor? : MagickColor; + strokeColor?: MagickColor; textureFileName?: string; @@ -38,7 +38,7 @@ export class MontageSettings { title?: string; - transparentColor? : MagickColor; + transparentColor?: MagickColor; /** @internal */ _use(func: (settings: NativeMontageSettings) => TReturnType): TReturnType diff --git a/src/statistics.ts b/src/statistics.ts index a1e2509b..7b265218 100644 --- a/src/statistics.ts +++ b/src/statistics.ts @@ -40,7 +40,7 @@ export class Statistics implements IStatistics { image.channels.forEach(channel => { if (((channels >> channel) & 0x01) != 0) - instance.addChannel(list, channel); + instance.addChannel(list, channel); }); instance.addChannel(list, PixelChannel.Composite); @@ -51,7 +51,7 @@ export class Statistics implements IStatistics { private addChannel(list: number, channel: PixelChannel) { const instance = ImageMagick._api._Statistics_GetInstance(list, channel); if (instance !== 0) { - this._channels[channel] = new ChannelStatistics(channel, instance); + this._channels[channel] = new ChannelStatistics(channel, instance); } } } diff --git a/tests/defines/defines-creator.spec.ts b/tests/defines/defines-creator.spec.ts index e34fe56b..92a92688 100644 --- a/tests/defines/defines-creator.spec.ts +++ b/tests/defines/defines-creator.spec.ts @@ -7,11 +7,11 @@ import { MagickFormat } from '../../src/magick-format'; import { MagickReadSettings } from '../../src/settings/magick-read-settings'; class TestDefinesCreator extends DefinesCreator { - constructor () { + constructor() { super(MagickFormat.A); } - getDefines (): IDefine[] { + getDefines(): IDefine[] { return [this.createDefine('test', 'empty')]; } } diff --git a/tests/image-magick/read-collection.spec.ts b/tests/image-magick/read-collection.spec.ts index 2887a69a..c2243685 100644 --- a/tests/image-magick/read-collection.spec.ts +++ b/tests/image-magick/read-collection.spec.ts @@ -75,7 +75,9 @@ describe('ImageMagick#readCollection', () => { await ImageMagick.readCollection(TestImages.roseSparkleGif.data, settings, async () => { await bogusAsyncMethod(); }); - }).rejects.toThrowError('ImproperImageHeader'); + }) + .rejects + .toThrowError('ImproperImageHeader'); }); it('should read image from array with settings', () => { diff --git a/tests/image-magick/read-from-canvas.spec.ts b/tests/image-magick/read-from-canvas.spec.ts index 4982dccc..c9c11bac 100644 --- a/tests/image-magick/read-from-canvas.spec.ts +++ b/tests/image-magick/read-from-canvas.spec.ts @@ -13,10 +13,10 @@ describe('ImageMagick#readFromCanvas', () => { canvas.width = 1; canvas.height = 2; - window.HTMLCanvasElement.prototype.getContext = vi.fn(function(contextId: string) { + window.HTMLCanvasElement.prototype.getContext = vi.fn(function (contextId: string) { expect(contextId).toBe('2d'); return { - getImageData: function(x: number, y: number, width: number, height: number) { + getImageData: function (x: number, y: number, width: number, height: number) { expect(x).toBe(0); expect(y).toBe(0); expect(width).toBe(canvas.width); @@ -47,10 +47,10 @@ describe('ImageMagick#readFromCanvas', () => { canvas.width = 1; canvas.height = 2; - window.HTMLCanvasElement.prototype.getContext = vi.fn(function(contextId: string) { + window.HTMLCanvasElement.prototype.getContext = vi.fn(function (contextId: string) { expect(contextId).toBe('2d'); return { - getImageData: function(x: number, y: number, width: number, height: number) { + getImageData: function (x: number, y: number, width: number, height: number) { expect(x).toBe(0); expect(y).toBe(0); expect(width).toBe(canvas.width); diff --git a/tests/magick-color/to-string.spec.ts b/tests/magick-color/to-string.spec.ts index ded6548f..c83987e9 100644 --- a/tests/magick-color/to-string.spec.ts +++ b/tests/magick-color/to-string.spec.ts @@ -17,7 +17,7 @@ describe('MagickColor#toString', () => { }); it('should return cmyka color for cmyk color', () => { - const color = new MagickColor(10, 20, 30,40, 50); + const color = new MagickColor(10, 20, 30, 40, 50); expect(color.toString()).toBe('cmyka(10,20,30,40,0.1961)'); }); diff --git a/tests/magick-format-info/all.spec.ts b/tests/magick-format-info/all.spec.ts index d60aa026..9c329ade 100644 --- a/tests/magick-format-info/all.spec.ts +++ b/tests/magick-format-info/all.spec.ts @@ -9,9 +9,9 @@ describe('MagickFormatInfo#all', () => { MagickFormatInfo.all.forEach(formatInfo => { try { expect(formatInfo.format).not.toBe(MagickFormat.Unknown); - } catch(err) { + } catch (err) { console.error(`Missing Magickformat for: ${formatInfo.description}.`); - throw(err); + throw (err); } }); }); diff --git a/tests/magick-image/bounding-box.spec.ts b/tests/magick-image/bounding-box.spec.ts index dee87b19..d0dfc3da 100644 --- a/tests/magick-image/bounding-box.spec.ts +++ b/tests/magick-image/bounding-box.spec.ts @@ -19,11 +19,11 @@ describe('MagickImage#boundingBox', () => { it('should return null when there is no bounding box', async () => { TestImages.Builtin.wizard.use(image => { - image.inverseOpaque(MagickColors.Purple, MagickColors.Black); + image.inverseOpaque(MagickColors.Purple, MagickColors.Black); const rectangle = image.boundingBox; expect(rectangle).toBeNull(); - }); + }); }); }); diff --git a/tests/magick-image/channels.spec.ts b/tests/magick-image/channels.spec.ts index b4d62565..6e0ee9f4 100644 --- a/tests/magick-image/channels.spec.ts +++ b/tests/magick-image/channels.spec.ts @@ -7,7 +7,7 @@ import { TestImages } from '../test-images'; describe('MagickImage#channels', () => { it('should return the correct channels', () => { - TestImages.Builtin.logo.use(image => { + TestImages.Builtin.logo.use(image => { const channels = image.channels; expect(channels.length).toBe(3); diff --git a/tests/magick-image/composite-gravity.spec.ts b/tests/magick-image/composite-gravity.spec.ts index 1628573a..fdfb700d 100644 --- a/tests/magick-image/composite-gravity.spec.ts +++ b/tests/magick-image/composite-gravity.spec.ts @@ -9,7 +9,7 @@ import { MagickColors } from '../../src/magick-colors'; import { Point } from '../../src/point'; describe('MagickImage#compositeGravity', () => { - it('should use the gravity', () => { + it('should use the gravity', () => { ImageMagick.read(MagickColors.Red, 3, 3, (image) => { ImageMagick.read(MagickColors.White, 1, 1, (white) => { @@ -122,24 +122,24 @@ describe('MagickImage#compositeGravity', () => { }); it('should use the gravity and position', () => { - ImageMagick.read(MagickColors.Red, 3, 3, (image) => { - ImageMagick.read(MagickColors.White, 1, 1, (white) => { - - image.compositeGravity(white, Gravity.Northeast, new Point(1, 1)); - expect(image).toHavePixelWithColor(1, 1, MagickColors.White); - }); - }); - }); - - it('should use the gravity, position and channels', () => { - ImageMagick.read(MagickColors.Red, 3, 3, (image) => { - ImageMagick.read(MagickColors.White, 1, 1, (white) => { - - image.compositeGravity(white, Gravity.Southwest, new Point(1, 1), Channels.Green); - expect(image).toHavePixelWithColor(1, 1, MagickColors.Yellow); - }); - }); - }); + ImageMagick.read(MagickColors.Red, 3, 3, (image) => { + ImageMagick.read(MagickColors.White, 1, 1, (white) => { + + image.compositeGravity(white, Gravity.Northeast, new Point(1, 1)); + expect(image).toHavePixelWithColor(1, 1, MagickColors.White); + }); + }); + }); + + it('should use the gravity, position and channels', () => { + ImageMagick.read(MagickColors.Red, 3, 3, (image) => { + ImageMagick.read(MagickColors.White, 1, 1, (white) => { + + image.compositeGravity(white, Gravity.Southwest, new Point(1, 1), Channels.Green); + expect(image).toHavePixelWithColor(1, 1, MagickColors.Yellow); + }); + }); + }); it('should use the gravity, operator and position', () => { ImageMagick.read(MagickColors.Red, 3, 3, (image) => { diff --git a/tests/magick-image/composite.spec.ts b/tests/magick-image/composite.spec.ts index 9401eea9..7273ab9f 100644 --- a/tests/magick-image/composite.spec.ts +++ b/tests/magick-image/composite.spec.ts @@ -143,7 +143,7 @@ describe('MagickImage#composite', () => { it('should remove the artifact when offset and arguments are specified', () => { ImageMagick.read(MagickColors.Red, 1, 1, (image) => { ImageMagick.read(MagickColors.White, 1, 1, (blur) => { - image.composite(blur, CompositeOperator.Blur, new Point(1, 1), '3'); + image.composite(blur, CompositeOperator.Blur, new Point(1, 1), '3'); expect(image.artifactNames.length).toBe(0); }); @@ -162,7 +162,7 @@ describe('MagickImage#composite', () => { it('should remove the artifact when offset, arguments and channels are specified', () => { ImageMagick.read(MagickColors.Red, 1, 1, (image) => { ImageMagick.read(MagickColors.White, 1, 1, (blur) => { - image.composite(blur, CompositeOperator.Blur, new Point(1, 1), '3', Channels.Red); + image.composite(blur, CompositeOperator.Blur, new Point(1, 1), '3', Channels.Red); expect(image.artifactNames.length).toBe(0); }); diff --git a/tests/magick-image/crop-to-tiles.spec.ts b/tests/magick-image/crop-to-tiles.spec.ts index 1924f234..c95cec33 100644 --- a/tests/magick-image/crop-to-tiles.spec.ts +++ b/tests/magick-image/crop-to-tiles.spec.ts @@ -18,24 +18,24 @@ afterEach(() => { describe('MagickImage#cropToTiles', () => { it('should crop the image to tiles', () => { - const images = image.cropToTiles(new MagickGeometry(2, 2)); + const images = image.cropToTiles(new MagickGeometry(2, 2)); - expect(images.length).toBe(4); + expect(images.length).toBe(4); - const first = images[0]; - expect(first.width).toBe(2); - expect(first.height).toBe(2); + const first = images[0]; + expect(first.width).toBe(2); + expect(first.height).toBe(2); - const second = images[1]; - expect(second.width).toBe(1); - expect(second.height).toBe(2); + const second = images[1]; + expect(second.width).toBe(1); + expect(second.height).toBe(2); - const third = images[2]; - expect(third.width).toBe(2); - expect(third.height).toBe(1); + const third = images[2]; + expect(third.width).toBe(2); + expect(third.height).toBe(1); - const fourth = images[3]; - expect(fourth.width).toBe(1); - expect(fourth.height).toBe(1); + const fourth = images[3]; + expect(fourth.width).toBe(1); + expect(fourth.height).toBe(1); }); }); diff --git a/tests/magick-image/crop.spec.ts b/tests/magick-image/crop.spec.ts index f3e66d9c..f19791e3 100644 --- a/tests/magick-image/crop.spec.ts +++ b/tests/magick-image/crop.spec.ts @@ -20,36 +20,36 @@ afterEach(() => { describe('MagickImage#crop', () => { it('should crop the image', () => { - image.crop(1, 1); + image.crop(1, 1); - expect(image.width).toBe(1); - expect(image.height).toBe(1); - expect(image).toHavePixelWithColor(0, 0, '#ffffffff'); + expect(image.width).toBe(1); + expect(image.height).toBe(1); + expect(image).toHavePixelWithColor(0, 0, '#ffffffff'); }); it('should crop the image with the specified gravity', () => { - image.crop(1, 1, Gravity.Center); + image.crop(1, 1, Gravity.Center); - expect(image.width).toBe(1); - expect(image.height).toBe(1); - expect(image).toHavePixelWithColor(0, 0, '#000000ff'); + expect(image.width).toBe(1); + expect(image.height).toBe(1); + expect(image).toHavePixelWithColor(0, 0, '#000000ff'); }); it('should crop the image with the specified geometry', () => { - image.crop(new MagickGeometry('2x2')); + image.crop(new MagickGeometry('2x2')); - expect(image.width).toBe(2); - expect(image.height).toBe(2); - expect(image).toHavePixelWithColor(0, 0, '#ffffffff'); - expect(image).toHavePixelWithColor(1, 1, '#000000ff'); + expect(image.width).toBe(2); + expect(image.height).toBe(2); + expect(image).toHavePixelWithColor(0, 0, '#ffffffff'); + expect(image).toHavePixelWithColor(1, 1, '#000000ff'); }); it('should crop the image with the specified geometry and gravity', () => { - image.crop(new MagickGeometry('2x2'), Gravity.Southeast); + image.crop(new MagickGeometry('2x2'), Gravity.Southeast); - expect(image.width).toBe(2); - expect(image.height).toBe(2); - expect(image).toHavePixelWithColor(0, 0, '#000000ff'); - expect(image).toHavePixelWithColor(1, 1, '#ffffffff'); + expect(image.width).toBe(2); + expect(image.height).toBe(2); + expect(image).toHavePixelWithColor(0, 0, '#000000ff'); + expect(image).toHavePixelWithColor(1, 1, '#ffffffff'); }); }); diff --git a/tests/magick-image/evaluate.spec.ts b/tests/magick-image/evaluate.spec.ts index 67555e30..bf13906b 100644 --- a/tests/magick-image/evaluate.spec.ts +++ b/tests/magick-image/evaluate.spec.ts @@ -44,7 +44,7 @@ describe('MagickImage#evaluate', () => { ImageMagick.read(MagickColors.White, 2, 1, mask => { mask.getPixels(pixels => { - pixels.setPixel(0, 0, [ 0, 0, 0 ]); + pixels.setPixel(0, 0, [0, 0, 0]); }); image.setWriteMask(mask); diff --git a/tests/magick-image/extent.spec.ts b/tests/magick-image/extent.spec.ts index 54ade55e..1920260b 100644 --- a/tests/magick-image/extent.spec.ts +++ b/tests/magick-image/extent.spec.ts @@ -19,10 +19,10 @@ afterEach(() => { describe('MagickImage#extent', () => { it('should extent the image', () => { - image.extent(2, 3); + image.extent(2, 3); - expect(image.width).toBe(2); - expect(image.height).toBe(3); + expect(image.width).toBe(2); + expect(image.height).toBe(3); }); it('should extent the image with the specified color', () => { @@ -31,55 +31,55 @@ describe('MagickImage#extent', () => { expect(image.width).toBe(2); expect(image.height).toBe(3); expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); - }); + }); - it('should extent the image with the specified gravity', () => { - image.backgroundColor = MagickColors.Magenta; - image.extent(2, 3, Gravity.Southeast); + it('should extent the image with the specified gravity', () => { + image.backgroundColor = MagickColors.Magenta; + image.extent(2, 3, Gravity.Southeast); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); + }); - it('should extent the image with the specified geometry', () => { - image.extent(new MagickGeometry(2, 3)); + it('should extent the image with the specified geometry', () => { + image.extent(new MagickGeometry(2, 3)); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + }); - it('should extent the image with the specified geometry and offset', () => { - image.backgroundColor = MagickColors.Magenta; - image.extent(new MagickGeometry(-1, -1, 2, 3)); + it('should extent the image with the specified geometry and offset', () => { + image.backgroundColor = MagickColors.Magenta; + image.extent(new MagickGeometry(-1, -1, 2, 3)); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); + }); - it('should extent the image with the specified geometry and color', () => { - image.extent(new MagickGeometry(2, 3), MagickColors.Magenta); + it('should extent the image with the specified geometry and color', () => { + image.extent(new MagickGeometry(2, 3), MagickColors.Magenta); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - expect(image).toHavePixelWithColor(1, 1, MagickColors.Magenta); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + expect(image).toHavePixelWithColor(1, 1, MagickColors.Magenta); + }); - it('should extent the image with the specified geometry and gravity', () => { - image.backgroundColor = MagickColors.Magenta; - image.extent(new MagickGeometry(2, 3), Gravity.Southwest); + it('should extent the image with the specified geometry and gravity', () => { + image.backgroundColor = MagickColors.Magenta; + image.extent(new MagickGeometry(2, 3), Gravity.Southwest); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); + }); - it('should extent the image with the specified geometry, gravity and color', () => { - image.extent(new MagickGeometry(2, 3), Gravity.Southwest, MagickColors.Magenta); + it('should extent the image with the specified geometry, gravity and color', () => { + image.extent(new MagickGeometry(2, 3), Gravity.Southwest, MagickColors.Magenta); - expect(image.width).toBe(2); - expect(image.height).toBe(3); - expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); - }); + expect(image.width).toBe(2); + expect(image.height).toBe(3); + expect(image).toHavePixelWithColor(0, 0, MagickColors.Magenta); + }); }); diff --git a/tests/magick-image/grayscale.spec.ts b/tests/magick-image/grayscale.spec.ts index 00d3852c..74b16802 100644 --- a/tests/magick-image/grayscale.spec.ts +++ b/tests/magick-image/grayscale.spec.ts @@ -5,7 +5,7 @@ import { ErrorMetric } from '../../src/error-metric'; import { PixelChannel } from '../../src/pixel-channel'; import { PixelIntensityMethod } from '../../src/pixel-intensity-method'; import { TestImages } from '../test-images'; - + describe('MagickImage#grayscale', () => { it('should use the default pixel intensity method', () => { TestImages.Color.purple.use(imageA => { diff --git a/tests/magick-image/inverse-opaque.spec.ts b/tests/magick-image/inverse-opaque.spec.ts index d4970eb9..f05923f5 100644 --- a/tests/magick-image/inverse-opaque.spec.ts +++ b/tests/magick-image/inverse-opaque.spec.ts @@ -6,7 +6,7 @@ import { MagickColors } from '../../src/magick-colors'; describe('MagickImage#inverseOpaque', () => { it('should change the everything except the target color to the fill color', () => { - ImageMagick.read(MagickColors.Red, 1,1, image => { + ImageMagick.read(MagickColors.Red, 1, 1, image => { image.extent(2, 1, MagickColors.Green); image.inverseOpaque(MagickColors.Red, MagickColors.Purple); diff --git a/tests/magick-image/opaque.spec.ts b/tests/magick-image/opaque.spec.ts index 5fa462b0..f84fcf79 100644 --- a/tests/magick-image/opaque.spec.ts +++ b/tests/magick-image/opaque.spec.ts @@ -6,7 +6,7 @@ import { MagickColors } from '../../src/magick-colors'; describe('MagickImage#opaque', () => { it('should change the target color to the fill color', () => { - ImageMagick.read(MagickColors.Red, 1,1, image => { + ImageMagick.read(MagickColors.Red, 1, 1, image => { image.extent(2, 1, MagickColors.Green); image.opaque(MagickColors.Red, MagickColors.Purple); diff --git a/tests/magick-image/read-from-canvas.spec.ts b/tests/magick-image/read-from-canvas.spec.ts index eb0a7e01..308d1b81 100644 --- a/tests/magick-image/read-from-canvas.spec.ts +++ b/tests/magick-image/read-from-canvas.spec.ts @@ -23,10 +23,10 @@ describe('MagickImage#readFromCanvas', () => { canvas.width = 1; canvas.height = 2; - window.HTMLCanvasElement.prototype.getContext = vi.fn(function(contextId: string) { + window.HTMLCanvasElement.prototype.getContext = vi.fn(function (contextId: string) { expect(contextId).toBe('2d'); return { - getImageData: function(x: number, y: number, width: number, height: number) { + getImageData: function (x: number, y: number, width: number, height: number) { expect(x).toBe(0); expect(y).toBe(0); expect(width).toBe(canvas.width); diff --git a/tests/magick-image/write-to-canvas.spec.ts b/tests/magick-image/write-to-canvas.spec.ts index e3fdc7bd..3c8f4058 100644 --- a/tests/magick-image/write-to-canvas.spec.ts +++ b/tests/magick-image/write-to-canvas.spec.ts @@ -22,15 +22,15 @@ describe('MagickImage#writeToCanvas', () => { const window = new JSDOM().window; const canvas = window.document.createElement('canvas'); - window.HTMLCanvasElement.prototype.getContext = vi.fn(function(contextId: string) { + window.HTMLCanvasElement.prototype.getContext = vi.fn(function (contextId: string) { expect(contextId).toBe('2d'); return { - createImageData: function(width: number, height: number) { + createImageData: function (width: number, height: number) { return { - data: new Array(width*height*4) + data: new Array(width * height * 4) }; }, - putImageData: function(imageData: ImageData, x: number, y: number) { + putImageData: function (imageData: ImageData, x: number, y: number) { expect(x).toBe(0); expect(y).toBe(0); diff --git a/tests/pixels/pixel-collection/set-area.spec.ts b/tests/pixels/pixel-collection/set-area.spec.ts index 82309822..ce66fc44 100644 --- a/tests/pixels/pixel-collection/set-area.spec.ts +++ b/tests/pixels/pixel-collection/set-area.spec.ts @@ -21,7 +21,7 @@ afterEach(() => { describe('PixelCollection#setArea', () => { it('should set the pixels at the specified location', () => { - const data = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; + const data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; pixels.setArea(0, 0, 2, 2, data); expect(image).toHavePixelWithColor(0, 0, MagickColors.Black); diff --git a/tests/pixels/pixel-collection/set-pixel.spec.ts b/tests/pixels/pixel-collection/set-pixel.spec.ts index a5414779..c012591a 100644 --- a/tests/pixels/pixel-collection/set-pixel.spec.ts +++ b/tests/pixels/pixel-collection/set-pixel.spec.ts @@ -21,7 +21,7 @@ afterEach(() => { describe('PixelCollection#setPixel', () => { it('should set the pixels at the specified location', () => { - const data = [ 0, 0, 0, 0 ]; + const data = [0, 0, 0, 0]; pixels.setPixel(1, 0, data); expect(image).toHavePixelWithColor(0, 0, MagickColors.White);