@imagemagick/magick-wasm 0.0.8 → 0.0.9
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 +864 -55
- package/README.md +1 -1
- package/gravity.js +35 -1
- package/image-magick.js +7 -3
- package/internal/exception/exception.js +7 -5
- package/magick-color.js +1 -1
- package/magick-format-info.js +2 -2
- package/magick-format.d.ts +1 -0
- package/magick-format.js +1 -0
- package/magick-geometry.js +1 -1
- package/magick-image.d.ts +22 -0
- package/magick-image.js +67 -13
- package/magick.js +3 -3
- package/package.json +1 -1
- 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 +1 -1
- package/settings/native-magick-settings.js +5 -5
- package/wasm/magick.js +1 -1
package/README.md
CHANGED
|
@@ -14,4 +14,4 @@ For more information about ImageMagick go to: [http://www.imagemagick.org/](http
|
|
|
14
14
|
|
|
15
15
|
## Release notes
|
|
16
16
|
|
|
17
|
-
The release notes can be found on [GitHub](https://github.com/dlemstra/magick-wasm/releases/tag/0.0.
|
|
17
|
+
The release notes can be found on [GitHub](https://github.com/dlemstra/magick-wasm/releases/tag/0.0.9).
|
package/gravity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Gravity = void 0;
|
|
3
|
+
exports._getEdges = exports.Gravity = void 0;
|
|
4
4
|
var Gravity;
|
|
5
5
|
(function (Gravity) {
|
|
6
6
|
Gravity[Gravity["Undefined"] = 0] = "Undefined";
|
|
@@ -15,3 +15,37 @@ var Gravity;
|
|
|
15
15
|
Gravity[Gravity["South"] = 8] = "South";
|
|
16
16
|
Gravity[Gravity["Southeast"] = 9] = "Southeast";
|
|
17
17
|
})(Gravity = exports.Gravity || (exports.Gravity = {}));
|
|
18
|
+
function* _getEdges(gravities) {
|
|
19
|
+
for (const gravity of gravities) {
|
|
20
|
+
switch (gravity) {
|
|
21
|
+
case Gravity.North:
|
|
22
|
+
yield 'north';
|
|
23
|
+
break;
|
|
24
|
+
case Gravity.Northeast:
|
|
25
|
+
yield 'north';
|
|
26
|
+
yield 'east';
|
|
27
|
+
break;
|
|
28
|
+
case Gravity.Northwest:
|
|
29
|
+
yield 'north';
|
|
30
|
+
yield 'west';
|
|
31
|
+
break;
|
|
32
|
+
case Gravity.East:
|
|
33
|
+
yield 'east';
|
|
34
|
+
break;
|
|
35
|
+
case Gravity.West:
|
|
36
|
+
yield 'west';
|
|
37
|
+
break;
|
|
38
|
+
case Gravity.South:
|
|
39
|
+
yield 'south';
|
|
40
|
+
break;
|
|
41
|
+
case Gravity.Southeast:
|
|
42
|
+
yield 'south';
|
|
43
|
+
yield 'east';
|
|
44
|
+
break;
|
|
45
|
+
case Gravity.Southwest:
|
|
46
|
+
yield 'south';
|
|
47
|
+
yield 'west';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports._getEdges = _getEdges;
|
package/image-magick.js
CHANGED
|
@@ -23,9 +23,13 @@ const string_1 = require("./internal/native/string");
|
|
|
23
23
|
class ImageMagick {
|
|
24
24
|
constructor() {
|
|
25
25
|
this.loader = new Promise(resolve => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (this.api !== undefined) {
|
|
27
|
+
resolve();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
(0, magick_js_1.default)().then(api => {
|
|
31
|
+
(0, string_1._withNativeString)(api, 'MAGICK_CONFIGURE_PATH', name => {
|
|
32
|
+
(0, string_1._withNativeString)(api, '/xml', value => {
|
|
29
33
|
api._Environment_SetEnv(name, value);
|
|
30
34
|
this.api = api;
|
|
31
35
|
});
|
|
@@ -38,12 +38,14 @@ class Exception {
|
|
|
38
38
|
Exception.dispose(exception);
|
|
39
39
|
return result;
|
|
40
40
|
}
|
|
41
|
-
static getErrorSeverity(exception) {
|
|
42
|
-
return image_magick_1.ImageMagick._api._MagickExceptionHelper_Severity(exception.value);
|
|
43
|
-
}
|
|
44
41
|
isError() {
|
|
42
|
+
if (!Exception.isRaised(this.pointer))
|
|
43
|
+
return false;
|
|
45
44
|
const severity = Exception.getErrorSeverity(this.pointer);
|
|
46
|
-
return
|
|
45
|
+
return severity >= magick_error_severity_1.MagickErrorSeverity.Error;
|
|
46
|
+
}
|
|
47
|
+
static getErrorSeverity(exception) {
|
|
48
|
+
return image_magick_1.ImageMagick._api._MagickExceptionHelper_Severity(exception.value);
|
|
47
49
|
}
|
|
48
50
|
static isRaised(exception) {
|
|
49
51
|
return exception.value !== 0;
|
|
@@ -56,7 +58,7 @@ class Exception {
|
|
|
56
58
|
static getMessage(exception) {
|
|
57
59
|
const message = image_magick_1.ImageMagick._api._MagickExceptionHelper_Message(exception.value);
|
|
58
60
|
const description = image_magick_1.ImageMagick._api._MagickExceptionHelper_Description(exception.value);
|
|
59
|
-
let errorMessage = string_1._createString(message, 'Unknown error');
|
|
61
|
+
let errorMessage = (0, string_1._createString)(message, 'Unknown error');
|
|
60
62
|
if (description !== 0) {
|
|
61
63
|
errorMessage += `(${image_magick_1.ImageMagick._api.UTF8ToString(description)})`;
|
|
62
64
|
}
|
package/magick-color.js
CHANGED
|
@@ -19,7 +19,7 @@ class MagickColor {
|
|
|
19
19
|
let instance = 0;
|
|
20
20
|
try {
|
|
21
21
|
instance = image_magick_1.ImageMagick._api._MagickColor_Create();
|
|
22
|
-
string_1._withString(colorOrRed, colorPtr => {
|
|
22
|
+
(0, string_1._withString)(colorOrRed, colorPtr => {
|
|
23
23
|
if (image_magick_1.ImageMagick._api._MagickColor_Initialize(instance, colorPtr) === 0)
|
|
24
24
|
throw new magick_error_1.MagickError('invalid color specified');
|
|
25
25
|
this.initialize(instance);
|
package/magick-format-info.js
CHANGED
|
@@ -27,9 +27,9 @@ class MagickFormatInfo {
|
|
|
27
27
|
const values = Object.values(magick_format_1.MagickFormat);
|
|
28
28
|
for (let i = 0; i < count; i++) {
|
|
29
29
|
const info = image_magick_1.ImageMagick._api._MagickFormatInfo_GetInfo(list, i, exception);
|
|
30
|
-
const formatName = string_1._createString(image_magick_1.ImageMagick._api._MagickFormatInfo_Format_Get(info));
|
|
30
|
+
const formatName = (0, string_1._createString)(image_magick_1.ImageMagick._api._MagickFormatInfo_Format_Get(info));
|
|
31
31
|
const format = MagickFormatInfo.convertFormat(formatName, values);
|
|
32
|
-
const description = string_1._createString(image_magick_1.ImageMagick._api._MagickFormatInfo_Description_Get(info), '');
|
|
32
|
+
const description = (0, string_1._createString)(image_magick_1.ImageMagick._api._MagickFormatInfo_Description_Get(info), '');
|
|
33
33
|
const isReadable = image_magick_1.ImageMagick._api._MagickFormatInfo_IsReadable_Get(info) == 1;
|
|
34
34
|
const isWritable = image_magick_1.ImageMagick._api._MagickFormatInfo_IsWritable_Get(info) == 1;
|
|
35
35
|
result[i] = new MagickFormatInfo(format, description, isReadable, isWritable);
|
package/magick-format.d.ts
CHANGED
package/magick-format.js
CHANGED
package/magick-geometry.js
CHANGED
|
@@ -39,7 +39,7 @@ class MagickGeometry {
|
|
|
39
39
|
else {
|
|
40
40
|
const instance = image_magick_1.ImageMagick._api._MagickGeometry_Create();
|
|
41
41
|
try {
|
|
42
|
-
string_1._withString(widthOrValueOrX, valuePtr => {
|
|
42
|
+
(0, string_1._withString)(widthOrValueOrX, valuePtr => {
|
|
43
43
|
const flags = image_magick_1.ImageMagick._api._MagickGeometry_Initialize(instance, valuePtr);
|
|
44
44
|
if (flags === geometry_flags_1.GeometryFlags.NoValue)
|
|
45
45
|
throw new magick_error_1.MagickError('invalid geometry specified');
|
package/magick-image.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { OrientationType } from './orientation-type';
|
|
|
19
19
|
import { Percentage } from './percentage';
|
|
20
20
|
import { PixelChannel } from './pixel-channel';
|
|
21
21
|
import { IPixelCollection } from './pixels/pixel-collection';
|
|
22
|
+
import { PixelInterpolateMethod } from './pixel-interpolate-method';
|
|
22
23
|
import { Point } from './point';
|
|
23
24
|
import { VirtualPixelMethod } from './virtual-pixel-method';
|
|
24
25
|
export interface IMagickImage extends INativeInstance {
|
|
@@ -30,6 +31,7 @@ export interface IMagickImage extends INativeInstance {
|
|
|
30
31
|
filterType: FilterType;
|
|
31
32
|
format: string;
|
|
32
33
|
hasAlpha: boolean;
|
|
34
|
+
interpolate: PixelInterpolateMethod;
|
|
33
35
|
readonly height: number;
|
|
34
36
|
orientation: OrientationType;
|
|
35
37
|
quality: number;
|
|
@@ -97,6 +99,8 @@ export interface IMagickImage extends INativeInstance {
|
|
|
97
99
|
level(blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
98
100
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage): void;
|
|
99
101
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
102
|
+
liquidRescale(geometry: MagickGeometry): void;
|
|
103
|
+
liquidRescale(width: number, height: number): void;
|
|
100
104
|
modulate(brightness: Percentage): void;
|
|
101
105
|
modulate(brightness: Percentage, saturation: Percentage): void;
|
|
102
106
|
modulate(brightness: Percentage, saturation: Percentage, hue: Percentage): void;
|
|
@@ -128,6 +132,13 @@ export interface IMagickImage extends INativeInstance {
|
|
|
128
132
|
setArtifact(name: string, value: boolean): void;
|
|
129
133
|
setWriteMask(image: IMagickImage): void;
|
|
130
134
|
toString(): string;
|
|
135
|
+
trim(): void;
|
|
136
|
+
trim(...edges: Gravity[]): void;
|
|
137
|
+
trim(percentage: Percentage): void;
|
|
138
|
+
vignette(): void;
|
|
139
|
+
vignette(radius: number, sigma: number, x: number, y: number): void;
|
|
140
|
+
wave(): void;
|
|
141
|
+
wave(method: PixelInterpolateMethod, amplitude: number, length: number): void;
|
|
131
142
|
write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
|
|
132
143
|
write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
|
|
133
144
|
writeToCanvas(canvas: HTMLCanvasElement): void;
|
|
@@ -149,6 +160,8 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
149
160
|
set format(value: string);
|
|
150
161
|
get hasAlpha(): boolean;
|
|
151
162
|
set hasAlpha(value: boolean);
|
|
163
|
+
get interpolate(): PixelInterpolateMethod;
|
|
164
|
+
set interpolate(value: PixelInterpolateMethod);
|
|
152
165
|
get height(): number;
|
|
153
166
|
get orientation(): OrientationType;
|
|
154
167
|
set orientation(value: OrientationType);
|
|
@@ -220,6 +233,8 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
220
233
|
level(blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
221
234
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage): void;
|
|
222
235
|
level(channels: Channels, blackPoint: Percentage, whitePoint: Percentage, gamma: number): void;
|
|
236
|
+
liquidRescale(geometry: MagickGeometry): void;
|
|
237
|
+
liquidRescale(width: number, height: number): void;
|
|
223
238
|
modulate(brightness: Percentage): void;
|
|
224
239
|
modulate(brightness: Percentage, saturation: Percentage): void;
|
|
225
240
|
modulate(brightness: Percentage, saturation: Percentage, hue: Percentage): void;
|
|
@@ -251,6 +266,13 @@ export declare class MagickImage extends NativeInstance implements IMagickImage
|
|
|
251
266
|
setArtifact(name: string, value: boolean): void;
|
|
252
267
|
setWriteMask(image: IMagickImage): void;
|
|
253
268
|
toString: () => string;
|
|
269
|
+
trim(): void;
|
|
270
|
+
trim(...edges: Gravity[]): void;
|
|
271
|
+
trim(percentage: Percentage): void;
|
|
272
|
+
wave(): void;
|
|
273
|
+
wave(method: PixelInterpolateMethod, amplitude: number, length: number): void;
|
|
274
|
+
vignette(): void;
|
|
275
|
+
vignette(radius: number, sigma: number, x: number, y: number): void;
|
|
254
276
|
write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
|
|
255
277
|
write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
|
|
256
278
|
writeToCanvas(canvas: HTMLCanvasElement): void;
|
package/magick-image.js
CHANGED
|
@@ -25,6 +25,7 @@ const pointer_1 = require("./internal/pointer/pointer");
|
|
|
25
25
|
const quantum_1 = require("./quantum");
|
|
26
26
|
const string_info_1 = require("./internal/string-info");
|
|
27
27
|
const string_1 = require("./internal/native/string");
|
|
28
|
+
const gravity_2 = require("./gravity");
|
|
28
29
|
const array_1 = require("./internal/native/array");
|
|
29
30
|
class MagickImage extends native_instance_1.NativeInstance {
|
|
30
31
|
constructor(instance, settings) {
|
|
@@ -66,8 +67,8 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
66
67
|
set depth(value) { image_magick_1.ImageMagick._api._MagickImage_Depth_Set(this._instance, value); }
|
|
67
68
|
get filterType() { return image_magick_1.ImageMagick._api._MagickImage_FilterType_Get(this._instance); }
|
|
68
69
|
set filterType(value) { image_magick_1.ImageMagick._api._MagickImage_FilterType_Set(this._instance, value); }
|
|
69
|
-
get format() { return string_1._createString(image_magick_1.ImageMagick._api._MagickImage_Format_Get(this._instance), ''); }
|
|
70
|
-
set format(value) { string_1._withString(value, instance => image_magick_1.ImageMagick._api._MagickImage_Format_Set(this._instance, instance)); }
|
|
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)); }
|
|
71
72
|
get hasAlpha() {
|
|
72
73
|
return exception_1.Exception.usePointer(exception => {
|
|
73
74
|
return this.toBool(image_magick_1.ImageMagick._api._MagickImage_HasAlpha_Get(this._instance, exception));
|
|
@@ -80,6 +81,12 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
80
81
|
image_magick_1.ImageMagick._api._MagickImage_HasAlpha_Set(this._instance, this.fromBool(value), exception);
|
|
81
82
|
});
|
|
82
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
|
+
}
|
|
83
90
|
get height() { return image_magick_1.ImageMagick._api._MagickImage_Height_Get(this._instance); }
|
|
84
91
|
get orientation() { return image_magick_1.ImageMagick._api._MagickImage_Orientation_Get(this._instance); }
|
|
85
92
|
set orientation(value) { image_magick_1.ImageMagick._api._MagickImage_Orientation_Set(this._instance, value); }
|
|
@@ -92,7 +99,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
92
99
|
}
|
|
93
100
|
get signature() {
|
|
94
101
|
return exception_1.Exception.usePointer(exception => {
|
|
95
|
-
return string_1._createString(image_magick_1.ImageMagick._api._MagickImage_Signature_Get(this._instance, exception));
|
|
102
|
+
return (0, string_1._createString)(image_magick_1.ImageMagick._api._MagickImage_Signature_Get(this._instance, exception));
|
|
96
103
|
});
|
|
97
104
|
}
|
|
98
105
|
get virtualPixelMethod() {
|
|
@@ -277,7 +284,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
277
284
|
distortArgs = [];
|
|
278
285
|
}
|
|
279
286
|
exception_1.Exception.use(exception => {
|
|
280
|
-
array_1._withDoubleArray(distortArgs, (distortArgsPtr) => {
|
|
287
|
+
(0, array_1._withDoubleArray)(distortArgs, (distortArgsPtr) => {
|
|
281
288
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Distort(this._instance, method, bestFit, distortArgsPtr, distortArgs.length, exception.ptr);
|
|
282
289
|
this._setInstance(instance, exception);
|
|
283
290
|
});
|
|
@@ -324,20 +331,20 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
324
331
|
else if (backgroundColorOrGravity !== undefined)
|
|
325
332
|
gravity = backgroundColorOrGravity;
|
|
326
333
|
exception_1.Exception.use(exception => {
|
|
327
|
-
string_1._withString(geometry.toString(), geometryPtr => {
|
|
334
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
328
335
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Extent(this._instance, geometryPtr, gravity, exception.ptr);
|
|
329
336
|
this._setInstance(instance, exception);
|
|
330
337
|
});
|
|
331
338
|
});
|
|
332
339
|
}
|
|
333
340
|
getArtifact(name) {
|
|
334
|
-
return string_1._withString(name, namePtr => {
|
|
341
|
+
return (0, string_1._withString)(name, namePtr => {
|
|
335
342
|
const value = image_magick_1.ImageMagick._api._MagickImage_GetArtifact(this._instance, namePtr);
|
|
336
|
-
return string_1._createString(value);
|
|
343
|
+
return (0, string_1._createString)(value);
|
|
337
344
|
});
|
|
338
345
|
}
|
|
339
346
|
getProfile(name) {
|
|
340
|
-
return string_1._withString(name, namePtr => {
|
|
347
|
+
return (0, string_1._withString)(name, namePtr => {
|
|
341
348
|
const value = image_magick_1.ImageMagick._api._MagickImage_GetProfile(this._instance, namePtr);
|
|
342
349
|
const data = string_info_1.StringInfo.toArray(value);
|
|
343
350
|
if (data === null)
|
|
@@ -378,12 +385,21 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
378
385
|
image_magick_1.ImageMagick._api._MagickImage_Level(this._instance, blackPoint.toDouble(), whitePoint.toQuantum(), gammaValue, channels, exception);
|
|
379
386
|
});
|
|
380
387
|
}
|
|
388
|
+
liquidRescale(widthOrGeometry, height) {
|
|
389
|
+
const geometry = typeof widthOrGeometry === 'number' ? new magick_geometry_1.MagickGeometry(widthOrGeometry, height) : widthOrGeometry;
|
|
390
|
+
exception_1.Exception.use(exception => {
|
|
391
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
392
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_LiquidRescale(this._instance, geometryPtr, geometry.x, geometry.y, exception.ptr);
|
|
393
|
+
this._setInstance(instance, exception);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
381
397
|
modulate(brightness, saturation, hue) {
|
|
382
398
|
const saturationPercentage = saturation === undefined ? new percentage_1.Percentage(100) : saturation;
|
|
383
399
|
const huePercentage = hue === undefined ? new percentage_1.Percentage(100) : hue;
|
|
384
400
|
exception_1.Exception.usePointer(exception => {
|
|
385
401
|
const modulate = `${brightness.toDouble()}/${saturationPercentage.toDouble()}/${huePercentage.toDouble()}`;
|
|
386
|
-
string_1._withString(modulate, modulatePtr => {
|
|
402
|
+
(0, string_1._withString)(modulate, modulatePtr => {
|
|
387
403
|
image_magick_1.ImageMagick._api._MagickImage_Modulate(this._instance, modulatePtr, exception);
|
|
388
404
|
});
|
|
389
405
|
});
|
|
@@ -433,7 +449,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
433
449
|
});
|
|
434
450
|
}
|
|
435
451
|
removeArtifact(name) {
|
|
436
|
-
string_1._withString(name, namePtr => {
|
|
452
|
+
(0, string_1._withString)(name, namePtr => {
|
|
437
453
|
image_magick_1.ImageMagick._api._MagickImage_RemoveArtifact(this._instance, namePtr);
|
|
438
454
|
});
|
|
439
455
|
}
|
|
@@ -445,7 +461,7 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
445
461
|
resize(widthOrGeometry, height) {
|
|
446
462
|
const geometry = typeof widthOrGeometry === 'number' ? new magick_geometry_1.MagickGeometry(widthOrGeometry, height) : widthOrGeometry;
|
|
447
463
|
exception_1.Exception.use(exception => {
|
|
448
|
-
string_1._withString(geometry.toString(), geometryPtr => {
|
|
464
|
+
(0, string_1._withString)(geometry.toString(), geometryPtr => {
|
|
449
465
|
const instance = image_magick_1.ImageMagick._api._MagickImage_Resize(this._instance, geometryPtr, exception.ptr);
|
|
450
466
|
this._setInstance(instance, exception);
|
|
451
467
|
});
|
|
@@ -517,8 +533,8 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
517
533
|
else {
|
|
518
534
|
strValue = this.fromBool(value).toString();
|
|
519
535
|
}
|
|
520
|
-
string_1._withString(name, namePtr => {
|
|
521
|
-
string_1._withString(strValue, valuePtr => {
|
|
536
|
+
(0, string_1._withString)(name, namePtr => {
|
|
537
|
+
(0, string_1._withString)(strValue, valuePtr => {
|
|
522
538
|
image_magick_1.ImageMagick._api._MagickImage_SetArtifact(this._instance, namePtr, valuePtr);
|
|
523
539
|
});
|
|
524
540
|
});
|
|
@@ -528,6 +544,44 @@ class MagickImage extends native_instance_1.NativeInstance {
|
|
|
528
544
|
image_magick_1.ImageMagick._api._MagickImage_SetWriteMask(this._instance, image._instance, exception);
|
|
529
545
|
});
|
|
530
546
|
}
|
|
547
|
+
trim(...args) {
|
|
548
|
+
if (args.length > 0) {
|
|
549
|
+
if (args.length == 1 && args[0] instanceof percentage_1.Percentage) {
|
|
550
|
+
const percentage = args[0];
|
|
551
|
+
this.setArtifact('trim:percent-background', percentage.toDouble().toString());
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
const edges = args;
|
|
555
|
+
const value = [...new Set((0, gravity_2._getEdges)(edges))].join(',');
|
|
556
|
+
this.setArtifact('trim:edges', value);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
exception_1.Exception.use(exception => {
|
|
560
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Trim(this._instance, exception.ptr);
|
|
561
|
+
this._setInstance(instance, exception);
|
|
562
|
+
this.removeArtifact('trim:edges');
|
|
563
|
+
this.removeArtifact('trim:percent-background');
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
wave(methodOrUndefined, amplitudeOrUndefined, lengthOrUndefined) {
|
|
567
|
+
const method = methodOrUndefined == undefined ? this.interpolate : methodOrUndefined;
|
|
568
|
+
const amplitude = amplitudeOrUndefined == undefined ? 25 : amplitudeOrUndefined;
|
|
569
|
+
const length = lengthOrUndefined == undefined ? 150 : lengthOrUndefined;
|
|
570
|
+
exception_1.Exception.use(exception => {
|
|
571
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Wave(this._instance, method, amplitude, length, exception.ptr);
|
|
572
|
+
this._setInstance(instance, exception);
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
vignette(radiusOrUndefined, sigmaOrUndefined, xOrUndefined, yOrUndefined) {
|
|
576
|
+
const radius = radiusOrUndefined === undefined ? 0 : radiusOrUndefined;
|
|
577
|
+
const sigma = sigmaOrUndefined === undefined ? 1.0 : sigmaOrUndefined;
|
|
578
|
+
const x = xOrUndefined === undefined ? 0 : xOrUndefined;
|
|
579
|
+
const y = yOrUndefined === undefined ? 0 : yOrUndefined;
|
|
580
|
+
exception_1.Exception.use(exception => {
|
|
581
|
+
const instance = image_magick_1.ImageMagick._api._MagickImage_Vignette(this._instance, radius, sigma, x, y, exception.ptr);
|
|
582
|
+
this._setInstance(instance, exception);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
531
585
|
write(func, format) {
|
|
532
586
|
let bytes = new Uint8Array();
|
|
533
587
|
exception_1.Exception.use(exception => {
|
package/magick.js
CHANGED
|
@@ -5,9 +5,9 @@ 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
12
|
static addFont(name, data) {
|
|
13
13
|
const fileSystem = image_magick_1.ImageMagick._api.FS;
|
package/package.json
CHANGED
|
@@ -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(() => {
|
|
@@ -15,7 +15,7 @@ class MagickReadSettings extends magick_settings_1.MagickSettings {
|
|
|
15
15
|
try {
|
|
16
16
|
const size = this.getSize();
|
|
17
17
|
if (size !== '') {
|
|
18
|
-
string_1._withString(size, sizePtr => {
|
|
18
|
+
(0, string_1._withString)(size, sizePtr => {
|
|
19
19
|
image_magick_1.ImageMagick._api._MagickSettings_SetSize(settings._instance, sizePtr);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -10,7 +10,7 @@ class NativeMagickSettings extends native_instance_1.NativeInstance {
|
|
|
10
10
|
const disposeMethod = image_magick_1.ImageMagick._api._MagickSettings_Dispose;
|
|
11
11
|
super(instance, disposeMethod);
|
|
12
12
|
if (settings._fileName !== undefined) {
|
|
13
|
-
string_1._withString(settings._fileName, ptr => {
|
|
13
|
+
(0, string_1._withString)(settings._fileName, ptr => {
|
|
14
14
|
image_magick_1.ImageMagick._api._MagickSettings_SetFileName(this._instance, ptr);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -29,14 +29,14 @@ class NativeMagickSettings extends native_instance_1.NativeInstance {
|
|
|
29
29
|
if (!stats.exists) {
|
|
30
30
|
throw `Unable to find a font with the name '${settings.font}', add it with Magick.addFont.`;
|
|
31
31
|
}
|
|
32
|
-
string_1._withString(fileName, ptr => {
|
|
32
|
+
(0, string_1._withString)(fileName, ptr => {
|
|
33
33
|
image_magick_1.ImageMagick._api._MagickSettings_Font_Set(this._instance, ptr);
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
if (settings.fontPointsize !== undefined)
|
|
37
37
|
image_magick_1.ImageMagick._api._MagickSettings_FontPointsize_Set(this._instance, settings.fontPointsize);
|
|
38
38
|
if (settings.format !== undefined) {
|
|
39
|
-
string_1._withString(settings.format, ptr => {
|
|
39
|
+
(0, string_1._withString)(settings.format, ptr => {
|
|
40
40
|
image_magick_1.ImageMagick._api._MagickSettings_Format_Set(this._instance, ptr);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -48,8 +48,8 @@ class NativeMagickSettings extends native_instance_1.NativeInstance {
|
|
|
48
48
|
this.setOption(option, settings._options[option]);
|
|
49
49
|
}
|
|
50
50
|
setOption(option, value) {
|
|
51
|
-
string_1._withString(option, optionPtr => {
|
|
52
|
-
string_1._withString(value, valuePtr => {
|
|
51
|
+
(0, string_1._withString)(option, optionPtr => {
|
|
52
|
+
(0, string_1._withString)(value, valuePtr => {
|
|
53
53
|
image_magick_1.ImageMagick._api._MagickSettings_SetOption(this._instance, optionPtr, valuePtr);
|
|
54
54
|
});
|
|
55
55
|
});
|