@imagemagick/magick-wasm 0.0.6 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +3310 -0
- package/README.md +5 -5
- package/auto-threshold-method.d.ts +6 -0
- package/auto-threshold-method.js +10 -0
- package/filter-type.d.ts +34 -0
- package/filter-type.js +38 -0
- package/gravity.js +35 -1
- package/image-magick.js +9 -4
- package/internal/exception/exception.js +17 -10
- package/internal/native-instance.js +3 -2
- package/magick-color.js +3 -2
- package/magick-error-severity.d.ts +25 -0
- package/magick-error-severity.js +29 -0
- package/magick-error.d.ts +6 -0
- package/magick-error.js +12 -0
- package/magick-format-info.js +2 -2
- package/magick-format.d.ts +4 -0
- package/magick-format.js +4 -0
- package/magick-geometry.js +34 -4
- package/magick-image.d.ts +54 -0
- package/magick-image.js +151 -18
- package/magick.d.ts +1 -0
- package/magick.js +13 -3
- package/package.json +15 -15
- package/pixel-interpolate-method.d.ts +14 -0
- package/pixel-interpolate-method.js +18 -0
- package/pixels/pixel-collection.js +2 -2
- package/settings/magick-read-settings.js +3 -8
- package/settings/magick-settings.d.ts +7 -0
- package/settings/magick-settings.js +4 -38
- package/{internal/exception/exception-severity.d.ts → settings/native-magick-settings.d.ts} +0 -0
- package/settings/native-magick-settings.js +58 -0
- package/wasm/magick.js +7 -8
- package/internal/exception/exception-severity.js +0 -53
package/magick-image.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AlphaOption } from './alpha-option';
|
|
2
|
+
import { AutoThresholdMethod } from './auto-threshold-method';
|
|
2
3
|
import { Channels } from './channels';
|
|
3
4
|
import { ColorSpace } from './color-space';
|
|
4
5
|
import { CompositeOperator } from './composite-operator';
|
|
@@ -6,6 +7,7 @@ import { DistortMethod } from './distort-method';
|
|
|
6
7
|
import { DistortSettings } from './settings/distort-settings';
|
|
7
8
|
import { ErrorMetric } from './error-metric';
|
|
8
9
|
import { EvaluateOperator } from './evaluate-operator';
|
|
10
|
+
import { FilterType } from './filter-type';
|
|
9
11
|
import { Gravity } from './gravity';
|
|
10
12
|
import { IImageProfile } from './profiles/image-profile';
|
|
11
13
|
import { IMagickImageCollection } from './magick-image-collection';
|
|
@@ -18,6 +20,7 @@ import { OrientationType } from './orientation-type';
|
|
|
18
20
|
import { Percentage } from './percentage';
|
|
19
21
|
import { PixelChannel } from './pixel-channel';
|
|
20
22
|
import { IPixelCollection } from './pixels/pixel-collection';
|
|
23
|
+
import { PixelInterpolateMethod } from './pixel-interpolate-method';
|
|
21
24
|
import { Point } from './point';
|
|
22
25
|
import { VirtualPixelMethod } from './virtual-pixel-method';
|
|
23
26
|
export interface IMagickImage extends INativeInstance {
|
|
@@ -26,21 +29,27 @@ export interface IMagickImage extends INativeInstance {
|
|
|
26
29
|
readonly channelCount: number;
|
|
27
30
|
colorSpace: ColorSpace;
|
|
28
31
|
depth: number;
|
|
32
|
+
filterType: FilterType;
|
|
29
33
|
format: string;
|
|
30
34
|
hasAlpha: boolean;
|
|
35
|
+
interpolate: PixelInterpolateMethod;
|
|
31
36
|
readonly height: number;
|
|
32
37
|
orientation: OrientationType;
|
|
38
|
+
page: MagickGeometry;
|
|
33
39
|
quality: number;
|
|
34
40
|
readonly signature: string | null;
|
|
35
41
|
virtualPixelMethod: VirtualPixelMethod;
|
|
36
42
|
width: number;
|
|
37
43
|
alpha(value: AlphaOption): void;
|
|
38
44
|
autoOrient(): void;
|
|
45
|
+
autoThreshold(method: AutoThresholdMethod): void;
|
|
39
46
|
blur(): void;
|
|
40
47
|
blur(channels: Channels): void;
|
|
41
48
|
blur(radius: number, sigma: number): void;
|
|
42
49
|
blur(radius: number, sigma: number, channels: Channels): void;
|
|
43
50
|
channelOffset(pixelChannel: PixelChannel): number;
|
|
51
|
+
charcoal(): void;
|
|
52
|
+
charcoal(radius: number, sigma: number): void;
|
|
44
53
|
clahe(xTiles: number, yTiles: number, numberBins: number, clipLimit: number): void;
|
|
45
54
|
clahe(xTiles: Percentage, yTiles: Percentage, numberBins: number, clipLimit: number): void;
|
|
46
55
|
clone(func: (image: IMagickImage) => void): void;
|
|
@@ -70,6 +79,10 @@ export interface IMagickImage extends INativeInstance {
|
|
|
70
79
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, channels: Channels): void;
|
|
71
80
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string): void;
|
|
72
81
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string, channels: Channels): void;
|
|
82
|
+
crop(geometry: MagickGeometry): void;
|
|
83
|
+
crop(geometry: MagickGeometry, gravity: Gravity): void;
|
|
84
|
+
crop(width: number, height: number): void;
|
|
85
|
+
crop(width: number, height: number, gravity: Gravity): void;
|
|
73
86
|
deskew(threshold: Percentage): number;
|
|
74
87
|
distort(method: DistortMethod, params: number[]): void;
|
|
75
88
|
distort(method: DistortMethod, settings: DistortSettings, params: number[]): void;
|
|
@@ -89,21 +102,28 @@ export interface IMagickImage extends INativeInstance {
|
|
|
89
102
|
getWriteMask(func: (mask: IMagickImage | null) => void): void;
|
|
90
103
|
getWriteMask(func: (mask: IMagickImage | null) => Promise<void>): Promise<void>;
|
|
91
104
|
getPixels<TReturnType>(func: (pixels: IPixelCollection) => TReturnType): TReturnType;
|
|
105
|
+
histogram(): Map<string, number>;
|
|
92
106
|
level(blackPoint: Percentage, whitePoint: Percentage): void;
|
|
93
107
|
level(blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
94
108
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage): void;
|
|
95
109
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
110
|
+
liquidRescale(geometry: MagickGeometry): void;
|
|
111
|
+
liquidRescale(width: number, height: number): void;
|
|
96
112
|
modulate(brightness: Percentage): void;
|
|
97
113
|
modulate(brightness: Percentage, saturation: Percentage): void;
|
|
98
114
|
modulate(brightness: Percentage, saturation: Percentage, hue: Percentage): void;
|
|
115
|
+
oilPaint(): void;
|
|
116
|
+
oilPaint(radius: number): void;
|
|
99
117
|
read(color: MagickColor, width: number, height: number): void;
|
|
100
118
|
read(fileName: string, settings?: MagickReadSettings): void;
|
|
101
119
|
read(array: Uint8Array, settings?: MagickReadSettings): void;
|
|
102
120
|
readFromCanvas(canvas: HTMLCanvasElement): void;
|
|
103
121
|
removeArtifact(name: string): void;
|
|
104
122
|
removeWriteMask(): void;
|
|
123
|
+
repage(): void;
|
|
105
124
|
resize(geometry: MagickGeometry): void;
|
|
106
125
|
resize(width: number, height: number): void;
|
|
126
|
+
rotate(degrees: number): void;
|
|
107
127
|
sharpen(): void;
|
|
108
128
|
sharpen(radius: number, sigma: number): void;
|
|
109
129
|
sharpen(radius: number, sigma: number, channels: Channels): void;
|
|
@@ -121,6 +141,13 @@ export interface IMagickImage extends INativeInstance {
|
|
|
121
141
|
setArtifact(name: string, value: boolean): void;
|
|
122
142
|
setWriteMask(image: IMagickImage): void;
|
|
123
143
|
toString(): string;
|
|
144
|
+
trim(): void;
|
|
145
|
+
trim(...edges: Gravity[]): void;
|
|
146
|
+
trim(percentage: Percentage): void;
|
|
147
|
+
vignette(): void;
|
|
148
|
+
vignette(radius: number, sigma: number, x: number, y: number): void;
|
|
149
|
+
wave(): void;
|
|
150
|
+
wave(method: PixelInterpolateMethod, amplitude: number, length: number): void;
|
|
124
151
|
write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
|
|
125
152
|
write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
|
|
126
153
|
writeToCanvas(canvas: HTMLCanvasElement): void;
|
|
@@ -136,13 +163,19 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
136
163
|
set colorSpace(value: ColorSpace);
|
|
137
164
|
get depth(): number;
|
|
138
165
|
set depth(value: number);
|
|
166
|
+
get filterType(): number;
|
|
167
|
+
set filterType(value: number);
|
|
139
168
|
get format(): string;
|
|
140
169
|
set format(value: string);
|
|
141
170
|
get hasAlpha(): boolean;
|
|
142
171
|
set hasAlpha(value: boolean);
|
|
172
|
+
get interpolate(): PixelInterpolateMethod;
|
|
173
|
+
set interpolate(value: PixelInterpolateMethod);
|
|
143
174
|
get height(): number;
|
|
144
175
|
get orientation(): OrientationType;
|
|
145
176
|
set orientation(value: OrientationType);
|
|
177
|
+
get page(): MagickGeometry;
|
|
178
|
+
set page(value: MagickGeometry);
|
|
146
179
|
get quality(): number;
|
|
147
180
|
set quality(value: number);
|
|
148
181
|
get signature(): string | null;
|
|
@@ -151,11 +184,14 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
151
184
|
get width(): number;
|
|
152
185
|
alpha(value: AlphaOption): void;
|
|
153
186
|
autoOrient(): void;
|
|
187
|
+
autoThreshold(method: AutoThresholdMethod): void;
|
|
154
188
|
blur(): void;
|
|
155
189
|
blur(channels: Channels): void;
|
|
156
190
|
blur(radius: number, sigma: number): void;
|
|
157
191
|
blur(radius: number, sigma: number, channels: Channels): void;
|
|
158
192
|
channelOffset(pixelChannel: PixelChannel): number;
|
|
193
|
+
charcoal(): void;
|
|
194
|
+
charcoal(radius: number, sigma: number): void;
|
|
159
195
|
clahe(xTiles: number, yTiles: number, numberBins: number, clipLimit: number): void;
|
|
160
196
|
clahe(xTiles: Percentage, yTiles: Percentage, numberBins: number, clipLimit: number): void;
|
|
161
197
|
clone(func: (image: IMagickImage) => void): void;
|
|
@@ -185,6 +221,10 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
185
221
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, channels: Channels): void;
|
|
186
222
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string): void;
|
|
187
223
|
compositeGravity(image: IMagickImage, gravity: Gravity, compose: CompositeOperator, point: Point, args: string, channels: Channels): void;
|
|
224
|
+
crop(geometry: MagickGeometry): void;
|
|
225
|
+
crop(geometry: MagickGeometry, gravity: Gravity): void;
|
|
226
|
+
crop(width: number, height: number): void;
|
|
227
|
+
crop(width: number, height: number, gravity: Gravity): void;
|
|
188
228
|
static create(): IMagickImage;
|
|
189
229
|
deskew(threshold: Percentage): number;
|
|
190
230
|
distort(method: DistortMethod, params: number[]): void;
|
|
@@ -205,21 +245,28 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
205
245
|
getWriteMask(func: (mask: IMagickImage | null) => void): void;
|
|
206
246
|
getWriteMask(func: (mask: IMagickImage | null) => Promise<void>): Promise<void>;
|
|
207
247
|
getPixels<TReturnType>(func: (pixels: IPixelCollection) => TReturnType): TReturnType;
|
|
248
|
+
histogram(): Map<string, number>;
|
|
208
249
|
level(blackPoint: Percentage, whitePoint: Percentage): void;
|
|
209
250
|
level(blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
210
251
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage): void;
|
|
211
252
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
253
|
+
liquidRescale(geometry: MagickGeometry): void;
|
|
254
|
+
liquidRescale(width: number, height: number): void;
|
|
212
255
|
modulate(brightness: Percentage): void;
|
|
213
256
|
modulate(brightness: Percentage, saturation: Percentage): void;
|
|
214
257
|
modulate(brightness: Percentage, saturation: Percentage, hue: Percentage): void;
|
|
258
|
+
oilPaint(): void;
|
|
259
|
+
oilPaint(radius: number): void;
|
|
215
260
|
read(color: MagickColor, width: number, height: number): void;
|
|
216
261
|
read(fileName: string, settings?: MagickReadSettings): void;
|
|
217
262
|
read(array: Uint8Array, settings?: MagickReadSettings): void;
|
|
218
263
|
readFromCanvas(canvas: HTMLCanvasElement): void;
|
|
219
264
|
removeArtifact(name: string): void;
|
|
220
265
|
removeWriteMask(): void;
|
|
266
|
+
repage(): void;
|
|
221
267
|
resize(geometry: MagickGeometry): void;
|
|
222
268
|
resize(width: number, height: number): void;
|
|
269
|
+
rotate(degrees: number): void;
|
|
223
270
|
sharpen(): void;
|
|
224
271
|
sharpen(radius: number, sigma: number): void;
|
|
225
272
|
sharpen(radius: number, sigma: number, channels: Channels): void;
|
|
@@ -237,6 +284,13 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
237
284
|
setArtifact(name: string, value: boolean): void;
|
|
238
285
|
setWriteMask(image: IMagickImage): void;
|
|
239
286
|
toString: () => string;
|
|
287
|
+
trim(): void;
|
|
288
|
+
trim(...edges: Gravity[]): void;
|
|
289
|
+
trim(percentage: Percentage): void;
|
|
290
|
+
wave(): void;
|
|
291
|
+
wave(method: PixelInterpolateMethod, amplitude: number, length: number): void;
|
|
292
|
+
vignette(): void;
|
|
293
|
+
vignette(radius: number, sigma: number, x: number, y: number): void;
|
|
240
294
|
write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
|
|
241
295
|
write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
|
|
242
296
|
writeToCanvas(canvas: HTMLCanvasElement): void;
|
package/magick-image.js
CHANGED
|
@@ -12,6 +12,7 @@ const image_profile_1 = require("./profiles/image-profile");
|
|
|
12
12
|
const magick_image_collection_1 = require("./magick-image-collection");
|
|
13
13
|
const native_instance_1 = require("./internal/native-instance");
|
|
14
14
|
const magick_color_1 = require("./magick-color");
|
|
15
|
+
const magick_error_1 = require("./magick-error");
|
|
15
16
|
const magick_format_1 = require("./magick-format");
|
|
16
17
|
const magick_geometry_1 = require("./magick-geometry");
|
|
17
18
|
const magick_read_settings_1 = require("./settings/magick-read-settings");
|
|
@@ -24,6 +25,7 @@ const pointer_1 = require("./internal/pointer/pointer");
|
|
|
24
25
|
const quantum_1 = require("./quantum");
|
|
25
26
|
const string_info_1 = require("./internal/string-info");
|
|
26
27
|
const string_1 = require("./internal/native/string");
|
|
28
|
+
const gravity_2 = require("./gravity");
|
|
27
29
|
const array_1 = require("./internal/native/array");
|
|
28
30
|
class MagickImage extends native_instance_1.NativeInstance {
|
|
29
31
|
constructor(instance, settings) {
|
|
@@ -63,8 +65,10 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
63
65
|
}
|
|
64
66
|
get depth() { return image_magick_1.ImageMagick._api._MagickImage_Depth_Get(this._instance); }
|
|
65
67
|
set depth(value) { image_magick_1.ImageMagick._api._MagickImage_Depth_Set(this._instance, value); }
|
|
66
|
-
get
|
|
67
|
-
set
|
|
68
|
+
get filterType() { return image_magick_1.ImageMagick._api._MagickImage_FilterType_Get(this._instance); }
|
|
69
|
+
set filterType(value) { image_magick_1.ImageMagick._api._MagickImage_FilterType_Set(this._instance, value); }
|
|
70
|
+
get format() { return (0, string_1._createString)(image_magick_1.ImageMagick._api._MagickImage_Format_Get(this._instance), ''); }
|
|
71
|
+
set format(value) { (0, string_1._withString)(value, instance => image_magick_1.ImageMagick._api._MagickImage_Format_Set(this._instance, instance)); }
|
|
68
72
|
get hasAlpha() {
|
|
69
73
|
return exception_1.Exception.usePointer(exception => {
|
|
70
74
|
return this.toBool(image_magick_1.ImageMagick._api._MagickImage_HasAlpha_Get(this._instance, exception));
|
|
@@ -77,9 +81,24 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
77
81
|
image_magick_1.ImageMagick._api._MagickImage_HasAlpha_Set(this._instance, this.fromBool(value), exception);
|
|
78
82
|
});
|
|
79
83
|
}
|
|
84
|
+
get interpolate() {
|
|
85
|
+
return image_magick_1.ImageMagick._api._MagickImage_Interpolate_Get(this._instance);
|
|
86
|
+
}
|
|
87
|
+
set interpolate(value) {
|
|
88
|
+
image_magick_1.ImageMagick._api._MagickImage_Interpolate_Set(this._instance, value);
|
|
89
|
+
}
|
|
80
90
|
get height() { return image_magick_1.ImageMagick._api._MagickImage_Height_Get(this._instance); }
|
|
81
91
|
get orientation() { return image_magick_1.ImageMagick._api._MagickImage_Orientation_Get(this._instance); }
|
|
82
92
|
set orientation(value) { image_magick_1.ImageMagick._api._MagickImage_Orientation_Set(this._instance, value); }
|
|
93
|
+
get page() {
|
|
94
|
+
const rectangle = image_magick_1.ImageMagick._api._MagickImage_Page_Get(this._instance);
|
|
95
|
+
return magick_geometry_1.MagickGeometry.fromRectangle(rectangle);
|
|
96
|
+
}
|
|
97
|
+
set page(value) {
|
|
98
|
+
value.toRectangle(rectangle => {
|
|
99
|
+
image_magick_1.ImageMagick._api._MagickImage_Page_Set(this._instance, rectangle);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
83
102
|
get quality() { return image_magick_1.ImageMagick._api._MagickImage_Quality_Get(this._instance); }
|
|
84
103
|
set quality(value) {
|
|
85
104
|
let quality = value < 1 ? 1 : value;
|
|
@@ -89,7 +108,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
89
108
|
}
|
|
90
109
|
get signature() {
|
|
91
110
|
return exception_1.Exception.usePointer(exception => {
|
|
92
|
-
return string_1._createString(image_magick_1.ImageMagick._api._MagickImage_Signature_Get(this._instance, exception));
|
|
111
|
+
return (0, string_1._createString)(image_magick_1.ImageMagick._api._MagickImage_Signature_Get(this._instance, exception));
|
|
93
112
|
});
|
|
94
113
|
}
|
|
95
114
|
get virtualPixelMethod() {
|
|
@@ -114,6 +133,11 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
114
133
|
this._setInstance(instance, exception);
|
|
115
134
|
});
|
|
116
135
|
}
|
|
136
|
+
autoThreshold(method) {
|
|
137
|
+
exception_1.Exception.use(exception => {
|
|
138
|
+
image_magick_1.ImageMagick._api._MagickImage_AutoThreshold(this._instance, method, exception.ptr);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
117
141
|
blur(radiusOrChannel, sigma, channels) {
|
|
118
142
|
let radius = 0;
|
|
119
143
|
const sigmaValue = this.valueOrDefault(sigma, 1);
|
|
@@ -132,6 +156,14 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
132
156
|
return -1;
|
|
133
157
|
return image_magick_1.ImageMagick._api._MagickImage_ChannelOffset(this._instance, pixelChannel);
|
|
134
158
|
}
|
|
159
|
+
charcoal(radiusOrUndefined, sigmaOrUndefined) {
|
|
160
|
+
const radius = radiusOrUndefined === undefined ? 0 : radiusOrUndefined;
|
|
161
|
+
const sigma = sigmaOrUndefined === undefined ? 1 : sigmaOrUndefined;
|
|
162
|
+
exception_1.Exception.use(exception => {
|
|
163
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Charcoal(this._instance, radius, sigma, exception.ptr);
|
|
164
|
+
this._setInstance(instance, exception);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
135
167
|
clahe(xTiles, yTiles, numberBins, clipLimit) {
|
|
136
168
|
exception_1.Exception.usePointer(exception => {
|
|
137
169
|
const xTilesValue = xTiles instanceof percentage_1.Percentage ? xTiles.multiply(this.width) : xTiles;
|
|
@@ -238,6 +270,24 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
238
270
|
if (args !== null)
|
|
239
271
|
this.removeArtifact('compose:args');
|
|
240
272
|
}
|
|
273
|
+
crop(geometryOrWidth, heightOrGravity, gravity) {
|
|
274
|
+
let geometry;
|
|
275
|
+
let cropGravity;
|
|
276
|
+
if (geometryOrWidth instanceof magick_geometry_1.MagickGeometry) {
|
|
277
|
+
geometry = geometryOrWidth;
|
|
278
|
+
cropGravity = heightOrGravity !== undefined ? heightOrGravity : gravity_1.Gravity.Undefined;
|
|
279
|
+
}
|
|
280
|
+
else if (heightOrGravity !== undefined) {
|
|
281
|
+
geometry = new magick_geometry_1.MagickGeometry(geometryOrWidth, heightOrGravity);
|
|
282
|
+
cropGravity = gravity !== undefined ? gravity : gravity_1.Gravity.Undefined;
|
|
283
|
+
}
|
|
284
|
+
exception_1.Exception.use(exception => {
|
|
285
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
286
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Crop(this._instance, geometryPtr, cropGravity, exception.ptr);
|
|
287
|
+
this._setInstance(instance, exception);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
}
|
|
241
291
|
static create() {
|
|
242
292
|
return new MagickImage(MagickImage.createInstance(), new magick_settings_1.MagickSettings());
|
|
243
293
|
}
|
|
@@ -266,7 +316,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
266
316
|
distortArgs = [];
|
|
267
317
|
}
|
|
268
318
|
exception_1.Exception.use(exception => {
|
|
269
|
-
array_1._withDoubleArray(distortArgs, (distortArgsPtr) => {
|
|
319
|
+
(0, array_1._withDoubleArray)(distortArgs, (distortArgsPtr) => {
|
|
270
320
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Distort(this._instance, method, bestFit, distortArgsPtr, distortArgs.length, exception.ptr);
|
|
271
321
|
this._setInstance(instance, exception);
|
|
272
322
|
});
|
|
@@ -284,12 +334,12 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
284
334
|
}
|
|
285
335
|
else if (valueOrPercentage !== undefined) {
|
|
286
336
|
if (typeof valueOrPercentageOrOperator !== 'number')
|
|
287
|
-
throw new
|
|
337
|
+
throw new magick_error_1.MagickError('this should not happen');
|
|
288
338
|
const geometry = operatorOrGeometry;
|
|
289
339
|
const operator = valueOrPercentageOrOperator;
|
|
290
340
|
const value = typeof valueOrPercentage === 'number' ? valueOrPercentage : valueOrPercentage.toQuantum();
|
|
291
341
|
if (geometry.isPercentage)
|
|
292
|
-
throw new
|
|
342
|
+
throw new magick_error_1.MagickError('percentage is not supported');
|
|
293
343
|
exception_1.Exception.usePointer(exception => {
|
|
294
344
|
magick_rectangle_1.MagickRectangle.use(this, geometry, rectangle => {
|
|
295
345
|
image_magick_1.ImageMagick._api._MagickImage_EvaluateGeometry(this._instance, channels, rectangle, operator, value, exception);
|
|
@@ -313,20 +363,20 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
313
363
|
else if (backgroundColorOrGravity !== undefined)
|
|
314
364
|
gravity = backgroundColorOrGravity;
|
|
315
365
|
exception_1.Exception.use(exception => {
|
|
316
|
-
string_1._withString(geometry.toString(), geometryPtr => {
|
|
366
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
317
367
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Extent(this._instance, geometryPtr, gravity, exception.ptr);
|
|
318
368
|
this._setInstance(instance, exception);
|
|
319
369
|
});
|
|
320
370
|
});
|
|
321
371
|
}
|
|
322
372
|
getArtifact(name) {
|
|
323
|
-
return string_1._withString(name, namePtr => {
|
|
373
|
+
return (0, string_1._withString)(name, namePtr => {
|
|
324
374
|
const value = image_magick_1.ImageMagick._api._MagickImage_GetArtifact(this._instance, namePtr);
|
|
325
|
-
return string_1._createString(value);
|
|
375
|
+
return (0, string_1._createString)(value);
|
|
326
376
|
});
|
|
327
377
|
}
|
|
328
378
|
getProfile(name) {
|
|
329
|
-
return string_1._withString(name, namePtr => {
|
|
379
|
+
return (0, string_1._withString)(name, namePtr => {
|
|
330
380
|
const value = image_magick_1.ImageMagick._api._MagickImage_GetProfile(this._instance, namePtr);
|
|
331
381
|
const data = string_info_1.StringInfo.toArray(value);
|
|
332
382
|
if (data === null)
|
|
@@ -346,6 +396,25 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
346
396
|
return func(pixels);
|
|
347
397
|
});
|
|
348
398
|
}
|
|
399
|
+
histogram() {
|
|
400
|
+
const result = new Map();
|
|
401
|
+
exception_1.Exception.usePointer(exception => {
|
|
402
|
+
pointer_1.Pointer.use(lengthPointer => {
|
|
403
|
+
const histogram = image_magick_1.ImageMagick._api._MagickImage_Histogram(this._instance, lengthPointer.ptr, exception);
|
|
404
|
+
if (histogram !== 0) {
|
|
405
|
+
const length = lengthPointer.value;
|
|
406
|
+
for (let i = 0; i < length; i++) {
|
|
407
|
+
const colorPtr = image_magick_1.ImageMagick._api._MagickColorCollection_GetInstance(histogram, i);
|
|
408
|
+
const color = magick_color_1.MagickColor._create(colorPtr);
|
|
409
|
+
const count = image_magick_1.ImageMagick._api._MagickColor_Count_Get(colorPtr);
|
|
410
|
+
result.set(color.toString(), count);
|
|
411
|
+
}
|
|
412
|
+
image_magick_1.ImageMagick._api._MagickColorCollection_DisposeList(histogram);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
349
418
|
level(channelsOrBlackPoint, blackPointOrWhitePoint, whitePointPercentageOrGamma, gamma) {
|
|
350
419
|
let channels = channels_1.Channels.Composite;
|
|
351
420
|
let blackPoint;
|
|
@@ -367,24 +436,41 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
367
436
|
image_magick_1.ImageMagick._api._MagickImage_Level(this._instance, blackPoint.toDouble(), whitePoint.toQuantum(), gammaValue, channels, exception);
|
|
368
437
|
});
|
|
369
438
|
}
|
|
439
|
+
liquidRescale(widthOrGeometry, height) {
|
|
440
|
+
const geometry = typeof widthOrGeometry === 'number' ? new magick_geometry_1.MagickGeometry(widthOrGeometry, height) : widthOrGeometry;
|
|
441
|
+
exception_1.Exception.use(exception => {
|
|
442
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
443
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_LiquidRescale(this._instance, geometryPtr, geometry.x, geometry.y, exception.ptr);
|
|
444
|
+
this._setInstance(instance, exception);
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
}
|
|
370
448
|
modulate(brightness, saturation, hue) {
|
|
371
449
|
const saturationPercentage = saturation === undefined ? new percentage_1.Percentage(100) : saturation;
|
|
372
450
|
const huePercentage = hue === undefined ? new percentage_1.Percentage(100) : hue;
|
|
373
451
|
exception_1.Exception.usePointer(exception => {
|
|
374
452
|
const modulate = `${brightness.toDouble()}/${saturationPercentage.toDouble()}/${huePercentage.toDouble()}`;
|
|
375
|
-
string_1._withString(modulate, modulatePtr => {
|
|
453
|
+
(0, string_1._withString)(modulate, modulatePtr => {
|
|
376
454
|
image_magick_1.ImageMagick._api._MagickImage_Modulate(this._instance, modulatePtr, exception);
|
|
377
455
|
});
|
|
378
456
|
});
|
|
379
457
|
}
|
|
458
|
+
oilPaint(radiusOrUndefined) {
|
|
459
|
+
const radius = radiusOrUndefined === undefined ? 3 : radiusOrUndefined;
|
|
460
|
+
const sigma = 0.0;
|
|
461
|
+
exception_1.Exception.use(exception => {
|
|
462
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_OilPaint(this._instance, radius, sigma, exception.ptr);
|
|
463
|
+
this._setInstance(instance, exception);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
380
466
|
read(fileNameOrArrayOrColor, settingsOrWidth, height) {
|
|
381
467
|
exception_1.Exception.use(exception => {
|
|
382
468
|
if (fileNameOrArrayOrColor instanceof Uint8Array) {
|
|
383
|
-
const readSettings = settingsOrWidth instanceof magick_read_settings_1.MagickReadSettings ? settingsOrWidth : magick_read_settings_1.MagickReadSettings
|
|
469
|
+
const readSettings = settingsOrWidth instanceof magick_read_settings_1.MagickReadSettings ? settingsOrWidth : new magick_read_settings_1.MagickReadSettings(this._settings);
|
|
384
470
|
this.readFromArray(fileNameOrArrayOrColor, readSettings, exception);
|
|
385
471
|
}
|
|
386
472
|
else {
|
|
387
|
-
const readSettings = settingsOrWidth instanceof magick_read_settings_1.MagickReadSettings ? settingsOrWidth : magick_read_settings_1.MagickReadSettings
|
|
473
|
+
const readSettings = settingsOrWidth instanceof magick_read_settings_1.MagickReadSettings ? settingsOrWidth : new magick_read_settings_1.MagickReadSettings(this._settings);
|
|
388
474
|
if (typeof fileNameOrArrayOrColor === 'string') {
|
|
389
475
|
readSettings._fileName = fileNameOrArrayOrColor;
|
|
390
476
|
}
|
|
@@ -414,7 +500,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
414
500
|
});
|
|
415
501
|
}
|
|
416
502
|
removeArtifact(name) {
|
|
417
|
-
string_1._withString(name, namePtr => {
|
|
503
|
+
(0, string_1._withString)(name, namePtr => {
|
|
418
504
|
image_magick_1.ImageMagick._api._MagickImage_RemoveArtifact(this._instance, namePtr);
|
|
419
505
|
});
|
|
420
506
|
}
|
|
@@ -423,15 +509,24 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
423
509
|
image_magick_1.ImageMagick._api._MagickImage_SetWriteMask(this._instance, 0, exception);
|
|
424
510
|
});
|
|
425
511
|
}
|
|
512
|
+
repage() {
|
|
513
|
+
this.page = new magick_geometry_1.MagickGeometry(0, 0, 0, 0);
|
|
514
|
+
}
|
|
426
515
|
resize(widthOrGeometry, height) {
|
|
427
516
|
const geometry = typeof widthOrGeometry === 'number' ? new magick_geometry_1.MagickGeometry(widthOrGeometry, height) : widthOrGeometry;
|
|
428
517
|
exception_1.Exception.use(exception => {
|
|
429
|
-
string_1._withString(geometry.toString(), geometryPtr => {
|
|
518
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
430
519
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Resize(this._instance, geometryPtr, exception.ptr);
|
|
431
520
|
this._setInstance(instance, exception);
|
|
432
521
|
});
|
|
433
522
|
});
|
|
434
523
|
}
|
|
524
|
+
rotate(degrees) {
|
|
525
|
+
exception_1.Exception.use(exception => {
|
|
526
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Rotate(this._instance, degrees, exception.ptr);
|
|
527
|
+
this._setInstance(instance, exception);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
435
530
|
sharpen(radius, sigma, channels) {
|
|
436
531
|
const radiusValue = radius !== undefined ? radius : 0.0;
|
|
437
532
|
const sigmaValue = sigma !== undefined ? sigma : 1.0;
|
|
@@ -492,8 +587,8 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
492
587
|
else {
|
|
493
588
|
strValue = this.fromBool(value).toString();
|
|
494
589
|
}
|
|
495
|
-
string_1._withString(name, namePtr => {
|
|
496
|
-
string_1._withString(strValue, valuePtr => {
|
|
590
|
+
(0, string_1._withString)(name, namePtr => {
|
|
591
|
+
(0, string_1._withString)(strValue, valuePtr => {
|
|
497
592
|
image_magick_1.ImageMagick._api._MagickImage_SetArtifact(this._instance, namePtr, valuePtr);
|
|
498
593
|
});
|
|
499
594
|
});
|
|
@@ -503,6 +598,44 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
503
598
|
image_magick_1.ImageMagick._api._MagickImage_SetWriteMask(this._instance, image._instance, exception);
|
|
504
599
|
});
|
|
505
600
|
}
|
|
601
|
+
trim(...args) {
|
|
602
|
+
if (args.length > 0) {
|
|
603
|
+
if (args.length == 1 && args[0] instanceof percentage_1.Percentage) {
|
|
604
|
+
const percentage = args[0];
|
|
605
|
+
this.setArtifact('trim:percent-background', percentage.toDouble().toString());
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
const edges = args;
|
|
609
|
+
const value = [...new Set((0, gravity_2._getEdges)(edges))].join(',');
|
|
610
|
+
this.setArtifact('trim:edges', value);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
exception_1.Exception.use(exception => {
|
|
614
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Trim(this._instance, exception.ptr);
|
|
615
|
+
this._setInstance(instance, exception);
|
|
616
|
+
this.removeArtifact('trim:edges');
|
|
617
|
+
this.removeArtifact('trim:percent-background');
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
wave(methodOrUndefined, amplitudeOrUndefined, lengthOrUndefined) {
|
|
621
|
+
const method = methodOrUndefined == undefined ? this.interpolate : methodOrUndefined;
|
|
622
|
+
const amplitude = amplitudeOrUndefined == undefined ? 25 : amplitudeOrUndefined;
|
|
623
|
+
const length = lengthOrUndefined == undefined ? 150 : lengthOrUndefined;
|
|
624
|
+
exception_1.Exception.use(exception => {
|
|
625
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Wave(this._instance, method, amplitude, length, exception.ptr);
|
|
626
|
+
this._setInstance(instance, exception);
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
vignette(radiusOrUndefined, sigmaOrUndefined, xOrUndefined, yOrUndefined) {
|
|
630
|
+
const radius = radiusOrUndefined === undefined ? 0 : radiusOrUndefined;
|
|
631
|
+
const sigma = sigmaOrUndefined === undefined ? 1.0 : sigmaOrUndefined;
|
|
632
|
+
const x = xOrUndefined === undefined ? 0 : xOrUndefined;
|
|
633
|
+
const y = yOrUndefined === undefined ? 0 : yOrUndefined;
|
|
634
|
+
exception_1.Exception.use(exception => {
|
|
635
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Vignette(this._instance, radius, sigma, x, y, exception.ptr);
|
|
636
|
+
this._setInstance(instance, exception);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
506
639
|
write(func, format) {
|
|
507
640
|
let bytes = new Uint8Array();
|
|
508
641
|
exception_1.Exception.use(exception => {
|
|
@@ -548,7 +681,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
548
681
|
return new MagickImage(instance, settings);
|
|
549
682
|
}
|
|
550
683
|
_instanceNotInitialized() {
|
|
551
|
-
throw new
|
|
684
|
+
throw new magick_error_1.MagickError('no image has been read');
|
|
552
685
|
}
|
|
553
686
|
static _use(func) {
|
|
554
687
|
const image = MagickImage.create();
|
package/magick.d.ts
CHANGED
package/magick.js
CHANGED
|
@@ -5,10 +5,20 @@ const image_magick_1 = require("./image-magick");
|
|
|
5
5
|
const magick_format_info_1 = require("./magick-format-info");
|
|
6
6
|
const string_1 = require("./internal/native/string");
|
|
7
7
|
class Magick {
|
|
8
|
-
static get delegates() { return string_1._createString(image_magick_1.ImageMagick._api._Magick_Delegates_Get(), 'Unknown'); }
|
|
9
|
-
static get features() { return string_1._createString(image_magick_1.ImageMagick._api._Magick_Features_Get(), ' ').slice(0, -1); }
|
|
10
|
-
static get imageMagickVersion() { return string_1._createString(image_magick_1.ImageMagick._api._Magick_ImageMagickVersion_Get(), 'Unknown'); }
|
|
8
|
+
static get delegates() { return (0, string_1._createString)(image_magick_1.ImageMagick._api._Magick_Delegates_Get(), 'Unknown'); }
|
|
9
|
+
static get features() { return (0, string_1._createString)(image_magick_1.ImageMagick._api._Magick_Features_Get(), ' ').slice(0, -1); }
|
|
10
|
+
static get imageMagickVersion() { return (0, string_1._createString)(image_magick_1.ImageMagick._api._Magick_ImageMagickVersion_Get(), 'Unknown'); }
|
|
11
11
|
static get supportedFormats() { return magick_format_info_1.MagickFormatInfo.all; }
|
|
12
|
+
static addFont(name, data) {
|
|
13
|
+
const fileSystem = image_magick_1.ImageMagick._api.FS;
|
|
14
|
+
const stats = fileSystem.analyzePath('/fonts');
|
|
15
|
+
if (!stats.exists) {
|
|
16
|
+
fileSystem.mkdir('/fonts');
|
|
17
|
+
}
|
|
18
|
+
const stream = fileSystem.open(`/fonts/${name}`, 'w+');
|
|
19
|
+
fileSystem.write(stream, data, 0, data.length);
|
|
20
|
+
fileSystem.close(stream);
|
|
21
|
+
}
|
|
12
22
|
}
|
|
13
23
|
exports.Magick = Magick;
|
|
14
24
|
Magick.setRandomSeed = (seed) => image_magick_1.ImageMagick._api._Magick_SetRandomSeed(seed);
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "@imagemagick/magick-wasm",
|
|
3
|
+
"version": "0.0.10",
|
|
4
|
+
"main": "image-magick.js",
|
|
5
|
+
"description": "The WASM library for ImageMagick",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/dlemstra/magick-wasm.git"
|
|
9
|
+
},
|
|
10
|
+
"author": "Dirk Lemstra",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/dlemstra/magick-wasmissues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/dlemstra/magick-wasm",
|
|
16
|
+
"keywords": ["imagemagick", "magick", "wasm", "image", "convert", "resize"]
|
|
17
17
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PixelInterpolateMethod = void 0;
|
|
4
|
+
var PixelInterpolateMethod;
|
|
5
|
+
(function (PixelInterpolateMethod) {
|
|
6
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Undefined"] = 0] = "Undefined";
|
|
7
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Average"] = 1] = "Average";
|
|
8
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Average9"] = 2] = "Average9";
|
|
9
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Average16"] = 3] = "Average16";
|
|
10
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Background"] = 4] = "Background";
|
|
11
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Bilinear"] = 5] = "Bilinear";
|
|
12
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Blend"] = 6] = "Blend";
|
|
13
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Catrom"] = 7] = "Catrom";
|
|
14
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Integer"] = 8] = "Integer";
|
|
15
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Mesh"] = 9] = "Mesh";
|
|
16
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Nearest"] = 10] = "Nearest";
|
|
17
|
+
PixelInterpolateMethod[PixelInterpolateMethod["Spline"] = 11] = "Spline";
|
|
18
|
+
})(PixelInterpolateMethod = exports.PixelInterpolateMethod || (exports.PixelInterpolateMethod = {}));
|
|
@@ -51,7 +51,7 @@ class PixelCollection extends native_instance_1.NativeInstance {
|
|
|
51
51
|
setArea(x, y, width, height, quantumPixelsOrNumberPixels) {
|
|
52
52
|
exception_1.Exception.usePointer(exception => {
|
|
53
53
|
const pixels = (quantumPixelsOrNumberPixels instanceof Uint8Array) ? quantumPixelsOrNumberPixels : new Uint8Array(quantumPixelsOrNumberPixels);
|
|
54
|
-
array_1._withQuantumArray(pixels, pixelsPtr => {
|
|
54
|
+
(0, array_1._withQuantumArray)(pixels, pixelsPtr => {
|
|
55
55
|
image_magick_1.ImageMagick._api._PixelCollection_SetArea(this._instance, x, y, width, height, pixelsPtr, pixels.length, exception);
|
|
56
56
|
});
|
|
57
57
|
});
|
|
@@ -79,7 +79,7 @@ class PixelCollection extends native_instance_1.NativeInstance {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
use(x, y, width, height, mapping, func) {
|
|
82
|
-
return string_1._withString(mapping, mappingPtr => {
|
|
82
|
+
return (0, string_1._withString)(mapping, mappingPtr => {
|
|
83
83
|
return exception_1.Exception.use(exception => {
|
|
84
84
|
const instance = image_magick_1.ImageMagick._api._PixelCollection_ToByteArray(this._instance, x, y, width, height, mappingPtr, exception.ptr);
|
|
85
85
|
return exception.check(() => {
|