@imagemagick/magick-wasm 0.0.5 → 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.
@@ -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;