Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Motion Blur #105

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/magick-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface IMagickImage extends IDisposable {
modulate(brightness: Percentage): void;
modulate(brightness: Percentage, saturation: Percentage): void;
modulate(brightness: Percentage, saturation: Percentage, hue: Percentage): void;
motionBlur(radius: number, sigma: number, angle: number): void;
negate(): void;
negate(channels: Channels): void;
negateGrayScale(): void;
Expand Down Expand Up @@ -1149,6 +1150,13 @@ export class MagickImage extends NativeInstance implements IMagickImage {
});
}

motionBlur(radius: number, sigma: number, angle: number): void {
Exception.use(exception => {
const instance = ImageMagick._api._MagickImage_MotionBlur(this._instance, radius, sigma, angle, exception.ptr);
this._setInstance(instance, exception);
});
}

oilPaint(): void;
oilPaint(radius: number): void
oilPaint(radiusOrUndefined?: number): void {
Expand Down
14 changes: 14 additions & 0 deletions tests/magick-image/motion-blur.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm.
// Licensed under the Apache License, Version 2.0.

import { TestImages } from "../test-images";

describe('MagickImage#motionBlur', () => {
it('should change pixels of the image', () => {
TestImages.Builtin.logo.use((image) => {
image.motionBlur(100, 10, -90);

expect(image).toHavePixelWithColor(222, 60, '#ff0d0dff');
});
});
});