Skip to content

Commit 7bb3425

Browse files
committed
Added blueShift to MagickImage.
1 parent 314e2b8 commit 7bb3425

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/magick-image.ts

+21
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,17 @@ export interface IMagickImage extends IDisposable {
589589
*/
590590
blackThreshold(threshold: Percentage, channels: Channels): void;
591591

592+
/**
593+
* Simulate a scene at nighttime in the moonlight.
594+
*/
595+
blueShift(): void;
596+
597+
/**
598+
* Simulate a scene at nighttime in the moonlight.
599+
* @param factor The factor to use.
600+
*/
601+
blueShift(factor: number): void;
602+
592603
/**
593604
* Blur image with the default blur factor (0x1).
594605
*/
@@ -2574,6 +2585,16 @@ export class MagickImage extends NativeInstance implements IMagickImage {
25742585
});
25752586
}
25762587

2588+
blueShift(): void
2589+
blueShift(factor: number): void
2590+
blueShift(factorOrUndefined?: number): void {
2591+
const factor = this.valueOrDefault(factorOrUndefined, 1.5);
2592+
this.useException(exception => {
2593+
const instance = ImageMagick._api._MagickImage_BlueShift(this._instance, factor, exception.ptr);
2594+
this._setInstance(instance, exception);
2595+
});
2596+
}
2597+
25772598
blur(): void;
25782599
blur(channels: Channels): void;
25792600
blur(radius: number, sigma: number): void;

tests/magick-image/blue-shift.spec.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
3+
Licensed under the Apache License, Version 2.0.
4+
*/
5+
6+
import { ErrorMetric } from '@src/enums/error-metric';
7+
import { TestFiles } from '@test/test-files';
8+
9+
describe('MagickImage#blueShift', () => {
10+
it('should change pixels of the image', () => {
11+
TestFiles.Images.Builtin.logo.use(image => {
12+
image.blueShift(1.5);
13+
14+
expect(image).toHavePixelWithColor(235, 65, '#ffbfbf');
15+
expect(image).toHavePixelWithColor(340, 260, '#838a9f');
16+
});
17+
});
18+
19+
it('should use the correct default factor value', () => {
20+
TestFiles.Images.Builtin.logo.use(image => {
21+
image.clone(other => {
22+
image.blueShift();
23+
other.blueShift(1.5);
24+
25+
const difference = other.compare(image, ErrorMetric.RootMeanSquared);
26+
expect(difference).toBe(0);
27+
})
28+
});
29+
});
30+
});

0 commit comments

Comments
 (0)