@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
|
@@ -3,24 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MagickReadSettings = void 0;
|
|
4
4
|
const image_magick_1 = require("../image-magick");
|
|
5
5
|
const magick_settings_1 = require("./magick-settings");
|
|
6
|
-
const
|
|
6
|
+
const native_magick_settings_1 = require("./native-magick-settings");
|
|
7
7
|
const string_1 = require("../internal/native/string");
|
|
8
8
|
class MagickReadSettings extends magick_settings_1.MagickSettings {
|
|
9
9
|
constructor(partialSettings) {
|
|
10
10
|
super();
|
|
11
11
|
Object.assign(this, partialSettings);
|
|
12
12
|
}
|
|
13
|
-
static _createFrom(settings) {
|
|
14
|
-
const result = new MagickReadSettings();
|
|
15
|
-
result.format = settings.format;
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
13
|
_use(func) {
|
|
19
|
-
const settings = new
|
|
14
|
+
const settings = new native_magick_settings_1.NativeMagickSettings(this);
|
|
20
15
|
try {
|
|
21
16
|
const size = this.getSize();
|
|
22
17
|
if (size !== '') {
|
|
23
|
-
string_1._withString(size, sizePtr => {
|
|
18
|
+
(0, string_1._withString)(size, sizePtr => {
|
|
24
19
|
image_magick_1.ImageMagick._api._MagickSettings_SetSize(settings._instance, sizePtr);
|
|
25
20
|
});
|
|
26
21
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { IDefines } from '../defines/defines';
|
|
2
2
|
import { MagickFormat } from '../magick-format';
|
|
3
|
+
import { MagickColor } from '../magick-color';
|
|
3
4
|
export declare class MagickSettings {
|
|
5
|
+
backgroundColor?: MagickColor;
|
|
6
|
+
fillColor?: MagickColor;
|
|
7
|
+
font?: string;
|
|
8
|
+
fontPointsize?: number;
|
|
4
9
|
format?: MagickFormat;
|
|
10
|
+
strokeColor?: MagickColor;
|
|
11
|
+
strokeWidth?: number;
|
|
5
12
|
getDefine(name: string): string;
|
|
6
13
|
getDefine(format: MagickFormat, name: string): string;
|
|
7
14
|
setDefine(name: string, value: string): void;
|
|
@@ -1,38 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MagickSettings =
|
|
4
|
-
const image_magick_1 = require("../image-magick");
|
|
3
|
+
exports.MagickSettings = void 0;
|
|
5
4
|
const magick_format_1 = require("../magick-format");
|
|
6
|
-
const
|
|
7
|
-
const string_1 = require("../internal/native/string");
|
|
8
|
-
class NativeMagickSettings extends native_instance_1.NativeInstance {
|
|
9
|
-
constructor(settings) {
|
|
10
|
-
const instance = image_magick_1.ImageMagick._api._MagickSettings_Create();
|
|
11
|
-
const disposeMethod = image_magick_1.ImageMagick._api._MagickSettings_Dispose;
|
|
12
|
-
super(instance, disposeMethod);
|
|
13
|
-
if (settings._fileName !== undefined) {
|
|
14
|
-
string_1._withString(settings._fileName, filenamePtr => {
|
|
15
|
-
image_magick_1.ImageMagick._api._MagickSettings_SetFileName(this._instance, filenamePtr);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (settings._quality !== undefined) {
|
|
19
|
-
image_magick_1.ImageMagick._api._MagickSettings_SetQuality(this._instance, settings._quality);
|
|
20
|
-
}
|
|
21
|
-
if (settings.format !== undefined) {
|
|
22
|
-
string_1._withString(settings.format, formatPtr => {
|
|
23
|
-
image_magick_1.ImageMagick._api._MagickSettings_Format_Set(this._instance, formatPtr);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
for (const option in settings._options) {
|
|
27
|
-
string_1._withString(option, optionPtr => {
|
|
28
|
-
string_1._withString(settings._options[option], valuePtr => {
|
|
29
|
-
image_magick_1.ImageMagick._api._MagickSettings_SetOption(this._instance, optionPtr, valuePtr);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.NativeMagickSettings = NativeMagickSettings;
|
|
5
|
+
const native_magick_settings_1 = require("./native-magick-settings");
|
|
36
6
|
class MagickSettings {
|
|
37
7
|
constructor() {
|
|
38
8
|
this._options = {};
|
|
@@ -65,15 +35,11 @@ class MagickSettings {
|
|
|
65
35
|
}
|
|
66
36
|
_clone() {
|
|
67
37
|
const clone = new MagickSettings();
|
|
68
|
-
clone
|
|
69
|
-
clone._quality = this._quality;
|
|
70
|
-
clone.format = this.format;
|
|
71
|
-
for (const option in this._options)
|
|
72
|
-
clone._options[option] = this._options[option];
|
|
38
|
+
Object.assign(clone, this);
|
|
73
39
|
return clone;
|
|
74
40
|
}
|
|
75
41
|
_use(func) {
|
|
76
|
-
const settings = new NativeMagickSettings(this);
|
|
42
|
+
const settings = new native_magick_settings_1.NativeMagickSettings(this);
|
|
77
43
|
try {
|
|
78
44
|
return func(settings);
|
|
79
45
|
}
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeMagickSettings = void 0;
|
|
4
|
+
const image_magick_1 = require("../image-magick");
|
|
5
|
+
const native_instance_1 = require("../internal/native-instance");
|
|
6
|
+
const string_1 = require("../internal/native/string");
|
|
7
|
+
class NativeMagickSettings extends native_instance_1.NativeInstance {
|
|
8
|
+
constructor(settings) {
|
|
9
|
+
const instance = image_magick_1.ImageMagick._api._MagickSettings_Create();
|
|
10
|
+
const disposeMethod = image_magick_1.ImageMagick._api._MagickSettings_Dispose;
|
|
11
|
+
super(instance, disposeMethod);
|
|
12
|
+
if (settings._fileName !== undefined) {
|
|
13
|
+
(0, string_1._withString)(settings._fileName, ptr => {
|
|
14
|
+
image_magick_1.ImageMagick._api._MagickSettings_SetFileName(this._instance, ptr);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (settings._quality !== undefined)
|
|
18
|
+
image_magick_1.ImageMagick._api._MagickSettings_SetQuality(this._instance, settings._quality);
|
|
19
|
+
if (settings.backgroundColor !== undefined) {
|
|
20
|
+
settings.backgroundColor._use((ptr) => {
|
|
21
|
+
image_magick_1.ImageMagick._api._MagickSettings_BackgroundColor_Set(this._instance, ptr);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (settings.fillColor !== undefined)
|
|
25
|
+
this.setOption('fill', settings.fillColor.toString());
|
|
26
|
+
if (settings.font !== undefined) {
|
|
27
|
+
const fileName = `/fonts/${settings.font}`;
|
|
28
|
+
const stats = image_magick_1.ImageMagick._api.FS.analyzePath(fileName);
|
|
29
|
+
if (!stats.exists) {
|
|
30
|
+
throw `Unable to find a font with the name '${settings.font}', add it with Magick.addFont.`;
|
|
31
|
+
}
|
|
32
|
+
(0, string_1._withString)(fileName, ptr => {
|
|
33
|
+
image_magick_1.ImageMagick._api._MagickSettings_Font_Set(this._instance, ptr);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (settings.fontPointsize !== undefined)
|
|
37
|
+
image_magick_1.ImageMagick._api._MagickSettings_FontPointsize_Set(this._instance, settings.fontPointsize);
|
|
38
|
+
if (settings.format !== undefined) {
|
|
39
|
+
(0, string_1._withString)(settings.format, ptr => {
|
|
40
|
+
image_magick_1.ImageMagick._api._MagickSettings_Format_Set(this._instance, ptr);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (settings.strokeColor !== undefined)
|
|
44
|
+
this.setOption('stroke', settings.strokeColor.toString());
|
|
45
|
+
if (settings.strokeWidth !== undefined)
|
|
46
|
+
this.setOption('strokeWidth', settings.strokeWidth.toString());
|
|
47
|
+
for (const option in settings._options)
|
|
48
|
+
this.setOption(option, settings._options[option]);
|
|
49
|
+
}
|
|
50
|
+
setOption(option, value) {
|
|
51
|
+
(0, string_1._withString)(option, optionPtr => {
|
|
52
|
+
(0, string_1._withString)(value, valuePtr => {
|
|
53
|
+
image_magick_1.ImageMagick._api._MagickSettings_SetOption(this._instance, optionPtr, valuePtr);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.NativeMagickSettings = NativeMagickSettings;
|