@imagemagick/magick-wasm 0.0.8 → 0.0.11

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.
Files changed (51) hide show
  1. package/NOTICE +1161 -59
  2. package/README.md +1 -1
  3. package/auto-threshold-method.d.ts +6 -0
  4. package/auto-threshold-method.js +10 -0
  5. package/drawables/drawable-color.d.ts +10 -0
  6. package/drawables/drawable-color.js +14 -0
  7. package/drawables/drawable-fill-color.d.ts +8 -0
  8. package/drawables/drawable-fill-color.js +12 -0
  9. package/drawables/drawable-fill-opacity.d.ts +8 -0
  10. package/drawables/drawable-fill-opacity.js +12 -0
  11. package/drawables/drawable-font-point-size.d.ts +7 -0
  12. package/drawables/drawable-font-point-size.js +12 -0
  13. package/drawables/drawable-font.d.ts +7 -0
  14. package/drawables/drawable-font.js +14 -0
  15. package/drawables/drawable-text.d.ts +9 -0
  16. package/drawables/drawable-text.js +14 -0
  17. package/drawables/drawable.d.ts +4 -0
  18. package/drawables/drawable.js +2 -0
  19. package/drawables/drawing-wand.d.ts +23 -0
  20. package/drawables/drawing-wand.js +66 -0
  21. package/gravity.js +35 -1
  22. package/image-magick.js +7 -3
  23. package/internal/exception/exception.js +29 -11
  24. package/magick-color.js +1 -1
  25. package/magick-error.d.ts +2 -0
  26. package/magick-error.js +5 -0
  27. package/magick-format-info.d.ts +1 -1
  28. package/magick-format-info.js +2 -2
  29. package/magick-format.d.ts +5 -0
  30. package/magick-format.js +5 -0
  31. package/magick-geometry.js +30 -1
  32. package/magick-image-collection.d.ts +11 -2
  33. package/magick-image-collection.js +53 -8
  34. package/magick-image.d.ts +73 -13
  35. package/magick-image.js +181 -49
  36. package/magick.d.ts +1 -1
  37. package/magick.js +12 -4
  38. package/package.json +1 -1
  39. package/paint-method.d.ts +8 -0
  40. package/paint-method.js +12 -0
  41. package/percentage.js +3 -0
  42. package/pixel-interpolate-method.d.ts +14 -0
  43. package/pixel-interpolate-method.js +18 -0
  44. package/pixels/pixel-collection.js +2 -2
  45. package/settings/drawing-settings.d.ts +9 -0
  46. package/settings/drawing-settings.js +25 -0
  47. package/settings/magick-read-settings.js +1 -1
  48. package/settings/native-drawing-settings.d.ts +1 -0
  49. package/settings/native-drawing-settings.js +35 -0
  50. package/settings/native-magick-settings.js +7 -10
  51. package/wasm/magick.js +2 -2
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.8).
17
+ The release notes can be found on [GitHub](https://github.com/dlemstra/magick-wasm/releases/tag/0.0.11).
@@ -0,0 +1,6 @@
1
+ export declare enum AutoThresholdMethod {
2
+ Undefined = 0,
3
+ Kapur = 1,
4
+ OTSU = 2,
5
+ Triangle = 3
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoThresholdMethod = void 0;
4
+ var AutoThresholdMethod;
5
+ (function (AutoThresholdMethod) {
6
+ AutoThresholdMethod[AutoThresholdMethod["Undefined"] = 0] = "Undefined";
7
+ AutoThresholdMethod[AutoThresholdMethod["Kapur"] = 1] = "Kapur";
8
+ AutoThresholdMethod[AutoThresholdMethod["OTSU"] = 2] = "OTSU";
9
+ AutoThresholdMethod[AutoThresholdMethod["Triangle"] = 3] = "Triangle";
10
+ })(AutoThresholdMethod = exports.AutoThresholdMethod || (exports.AutoThresholdMethod = {}));
@@ -0,0 +1,10 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ import { PaintMethod } from "../paint-method";
4
+ export declare class DrawableColor implements IDrawable {
5
+ private readonly _x;
6
+ private readonly _y;
7
+ private readonly _paintMethod;
8
+ constructor(x: number, y: number, paintMethod: PaintMethod);
9
+ draw(wand: IDrawingWand): void;
10
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableColor = void 0;
4
+ class DrawableColor {
5
+ constructor(x, y, paintMethod) {
6
+ this._x = x;
7
+ this._y = y;
8
+ this._paintMethod = paintMethod;
9
+ }
10
+ draw(wand) {
11
+ wand.color(this._x, this._y, this._paintMethod);
12
+ }
13
+ }
14
+ exports.DrawableColor = DrawableColor;
@@ -0,0 +1,8 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ import { MagickColor } from "../magick-color";
4
+ export declare class DrawableFillColor implements IDrawable {
5
+ private readonly _color;
6
+ constructor(color: MagickColor);
7
+ draw(wand: IDrawingWand): void;
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableFillColor = void 0;
4
+ class DrawableFillColor {
5
+ constructor(color) {
6
+ this._color = color;
7
+ }
8
+ draw(wand) {
9
+ wand.fillColor(this._color);
10
+ }
11
+ }
12
+ exports.DrawableFillColor = DrawableFillColor;
@@ -0,0 +1,8 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ import { Percentage } from "../percentage";
4
+ export declare class DrawableFillOpacity implements IDrawable {
5
+ private readonly _opacity;
6
+ constructor(opacity: Percentage);
7
+ draw(wand: IDrawingWand): void;
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableFillOpacity = void 0;
4
+ class DrawableFillOpacity {
5
+ constructor(opacity) {
6
+ this._opacity = opacity;
7
+ }
8
+ draw(wand) {
9
+ wand.fillOpacity(this._opacity.toDouble() / 100);
10
+ }
11
+ }
12
+ exports.DrawableFillOpacity = DrawableFillOpacity;
@@ -0,0 +1,7 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ export declare class DrawableFontPointSize implements IDrawable {
4
+ private readonly _pointSize;
5
+ constructor(pointSize: number);
6
+ draw(wand: IDrawingWand): void;
7
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableFontPointSize = void 0;
4
+ class DrawableFontPointSize {
5
+ constructor(pointSize) {
6
+ this._pointSize = pointSize;
7
+ }
8
+ draw(wand) {
9
+ wand.fontPointSize(this._pointSize);
10
+ }
11
+ }
12
+ exports.DrawableFontPointSize = DrawableFontPointSize;
@@ -0,0 +1,7 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ export declare class DrawableFont implements IDrawable {
4
+ private readonly _font;
5
+ constructor(font: string);
6
+ draw(wand: IDrawingWand): void;
7
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableFont = void 0;
4
+ const magick_1 = require("../magick");
5
+ class DrawableFont {
6
+ constructor(font) {
7
+ this._font = font;
8
+ }
9
+ draw(wand) {
10
+ const fileName = magick_1.Magick._getFontFileName(this._font);
11
+ wand.font(fileName);
12
+ }
13
+ }
14
+ exports.DrawableFont = DrawableFont;
@@ -0,0 +1,9 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { IDrawingWand } from "./drawing-wand";
3
+ export declare class DrawableText implements IDrawable {
4
+ private readonly _x;
5
+ private readonly _y;
6
+ private readonly _value;
7
+ constructor(x: number, y: number, value: string);
8
+ draw(wand: IDrawingWand): void;
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawableText = void 0;
4
+ class DrawableText {
5
+ constructor(x, y, value) {
6
+ this._x = x;
7
+ this._y = y;
8
+ this._value = value;
9
+ }
10
+ draw(wand) {
11
+ wand.text(this._x, this._y, this._value);
12
+ }
13
+ }
14
+ exports.DrawableText = DrawableText;
@@ -0,0 +1,4 @@
1
+ import { IDrawingWand } from "./drawing-wand";
2
+ export interface IDrawable {
3
+ draw(wand: IDrawingWand): void;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { IDrawable } from "./drawable";
2
+ import { MagickColor } from "../magick-color";
3
+ import { NativeInstance } from "../internal/native-instance";
4
+ import { PaintMethod } from "../paint-method";
5
+ export interface IDrawingWand extends NativeInstance {
6
+ color(x: number, y: number, paintMethod: number): void;
7
+ draw(drawables: IDrawable[]): void;
8
+ fillColor(value: MagickColor): void;
9
+ fillOpacity(value: number): void;
10
+ font(family: string): void;
11
+ fontPointSize(value: number): void;
12
+ text(x: number, y: number, value: string): void;
13
+ }
14
+ export declare class DrawingWand extends NativeInstance implements IDrawingWand {
15
+ private constructor();
16
+ color(x: number, y: number, paintMethod: PaintMethod): void;
17
+ draw(drawables: IDrawable[]): void;
18
+ fillColor(value: MagickColor): void;
19
+ fillOpacity(value: number): void;
20
+ font(fileName: string): void;
21
+ fontPointSize(value: number): void;
22
+ text(x: number, y: number, value: string): void;
23
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DrawingWand = void 0;
4
+ const drawing_settings_1 = require("../settings/drawing-settings");
5
+ const exception_1 = require("../internal/exception/exception");
6
+ const image_magick_1 = require("../image-magick");
7
+ const native_instance_1 = require("../internal/native-instance");
8
+ const string_1 = require("../internal/native/string");
9
+ class DrawingWand extends native_instance_1.NativeInstance {
10
+ constructor(image, magickSettings) {
11
+ const drawingSettings = drawing_settings_1.DrawingSettings._create(magickSettings);
12
+ const instance = drawingSettings._use(settings => {
13
+ return image_magick_1.ImageMagick._api._DrawingWand_Create(image._instance, settings._instance);
14
+ });
15
+ const disposeMethod = image_magick_1.ImageMagick._api._DrawingWand_Dispose;
16
+ super(instance, disposeMethod);
17
+ }
18
+ color(x, y, paintMethod) {
19
+ exception_1.Exception.usePointer(exception => {
20
+ image_magick_1.ImageMagick._api._DrawingWand_Color(this._instance, x, y, paintMethod, exception);
21
+ });
22
+ }
23
+ draw(drawables) {
24
+ drawables.forEach(drawable => {
25
+ drawable.draw(this);
26
+ });
27
+ exception_1.Exception.usePointer(exception => {
28
+ image_magick_1.ImageMagick._api._DrawingWand_Render(this._instance, exception);
29
+ });
30
+ }
31
+ fillColor(value) {
32
+ exception_1.Exception.usePointer(exception => {
33
+ value._use(valuePtr => {
34
+ image_magick_1.ImageMagick._api._DrawingWand_FillColor(this._instance, valuePtr, exception);
35
+ });
36
+ });
37
+ }
38
+ fillOpacity(value) {
39
+ exception_1.Exception.usePointer(exception => {
40
+ image_magick_1.ImageMagick._api._DrawingWand_FillOpacity(this._instance, value, exception);
41
+ });
42
+ }
43
+ font(fileName) {
44
+ exception_1.Exception.usePointer(exception => {
45
+ (0, string_1._withString)(fileName, ptr => {
46
+ image_magick_1.ImageMagick._api._DrawingWand_Font(this._instance, ptr, exception);
47
+ });
48
+ });
49
+ }
50
+ fontPointSize(value) {
51
+ exception_1.Exception.usePointer(exception => {
52
+ image_magick_1.ImageMagick._api._DrawingWand_FontPointSize(this._instance, value, exception);
53
+ });
54
+ }
55
+ text(x, y, value) {
56
+ exception_1.Exception.usePointer(exception => {
57
+ (0, string_1._withString)(value, valuePtr => {
58
+ image_magick_1.ImageMagick._api._DrawingWand_Text(this._instance, x, y, valuePtr, exception);
59
+ });
60
+ });
61
+ }
62
+ static _create(image, settings) {
63
+ return new DrawingWand(image, settings);
64
+ }
65
+ }
66
+ exports.DrawingWand = DrawingWand;
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
- magick_js_1.default().then(api => {
27
- string_1._withNativeString(api, 'MAGICK_CONFIGURE_PATH', name => {
28
- string_1._withNativeString(api, '/xml', value => {
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
  });
@@ -31,32 +31,50 @@ class Exception {
31
31
  static checkException(exception, result) {
32
32
  if (!Exception.isRaised(exception))
33
33
  return result;
34
- const severity = Exception.getErrorSeverity(exception);
34
+ const severity = Exception.getErrorSeverity(exception.value);
35
35
  if (severity >= magick_error_severity_1.MagickErrorSeverity.Error)
36
36
  Exception.throw(exception, severity);
37
37
  else
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() {
45
- const severity = Exception.getErrorSeverity(this.pointer);
46
- return Exception.isRaised(this.pointer) && severity >= magick_error_severity_1.MagickErrorSeverity.Error;
42
+ if (!Exception.isRaised(this.pointer))
43
+ return false;
44
+ const severity = Exception.getErrorSeverity(this.pointer.value);
45
+ return severity >= magick_error_severity_1.MagickErrorSeverity.Error;
46
+ }
47
+ static getErrorSeverity(exception) {
48
+ return image_magick_1.ImageMagick._api._MagickExceptionHelper_Severity(exception);
47
49
  }
48
50
  static isRaised(exception) {
49
51
  return exception.value !== 0;
50
52
  }
51
53
  static throw(exception, severity) {
52
- const errorMessage = Exception.getMessage(exception);
54
+ const error = Exception.createError(exception.value, severity);
53
55
  Exception.dispose(exception);
54
- throw new magick_error_1.MagickError(errorMessage, severity);
56
+ throw error;
57
+ }
58
+ static createError(exception, severity) {
59
+ const errorMessage = Exception.getMessage(exception);
60
+ const error = new magick_error_1.MagickError(errorMessage, severity);
61
+ const nestedCount = image_magick_1.ImageMagick._api._MagickExceptionHelper_RelatedCount(exception);
62
+ if (nestedCount === 0)
63
+ return error;
64
+ const relatedErrors = [];
65
+ for (let i = 0; i < nestedCount; i++) {
66
+ const related = image_magick_1.ImageMagick._api._MagickExceptionHelper_Related(exception, i);
67
+ const relatedSeverity = Exception.getErrorSeverity(related);
68
+ const relatedError = Exception.createError(related, relatedSeverity);
69
+ relatedErrors.push(relatedError);
70
+ }
71
+ error._setRelatedErrors(relatedErrors);
72
+ return error;
55
73
  }
56
74
  static getMessage(exception) {
57
- const message = image_magick_1.ImageMagick._api._MagickExceptionHelper_Message(exception.value);
58
- const description = image_magick_1.ImageMagick._api._MagickExceptionHelper_Description(exception.value);
59
- let errorMessage = string_1._createString(message, 'Unknown error');
75
+ const message = image_magick_1.ImageMagick._api._MagickExceptionHelper_Message(exception);
76
+ const description = image_magick_1.ImageMagick._api._MagickExceptionHelper_Description(exception);
77
+ let errorMessage = (0, string_1._createString)(message, 'Unknown error');
60
78
  if (description !== 0) {
61
79
  errorMessage += `(${image_magick_1.ImageMagick._api.UTF8ToString(description)})`;
62
80
  }
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-error.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { MagickErrorSeverity } from "./magick-error-severity";
2
2
  export declare class MagickError extends Error {
3
3
  private readonly _severity;
4
+ private _relatedErrors;
4
5
  constructor(message: string, severity?: MagickErrorSeverity);
6
+ get relatedErrors(): ReadonlyArray<MagickError>;
5
7
  get severity(): MagickErrorSeverity;
6
8
  }
package/magick-error.js CHANGED
@@ -5,8 +5,13 @@ const magick_error_severity_1 = require("./magick-error-severity");
5
5
  class MagickError extends Error {
6
6
  constructor(message, severity = magick_error_severity_1.MagickErrorSeverity.Error) {
7
7
  super(message);
8
+ this._relatedErrors = [];
8
9
  this._severity = severity;
9
10
  }
11
+ get relatedErrors() { return this._relatedErrors; }
10
12
  get severity() { return this._severity; }
13
+ _setRelatedErrors(relatedErrors) {
14
+ this._relatedErrors = relatedErrors;
15
+ }
11
16
  }
12
17
  exports.MagickError = MagickError;
@@ -9,6 +9,6 @@ export declare class MagickFormatInfo {
9
9
  get format(): MagickFormat;
10
10
  get isReadable(): boolean;
11
11
  get isWritable(): boolean;
12
- static get all(): MagickFormatInfo[];
12
+ static get all(): ReadonlyArray<MagickFormatInfo>;
13
13
  private static convertFormat;
14
14
  }
@@ -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);
@@ -59,6 +59,7 @@ export declare enum MagickFormat {
59
59
  Ept2 = "EPT2",
60
60
  Ept3 = "EPT3",
61
61
  Erf = "ERF",
62
+ Exr = "EXR",
62
63
  Farbfeld = "FARBFELD",
63
64
  Fax = "FAX",
64
65
  FF = "FF",
@@ -68,6 +69,7 @@ export declare enum MagickFormat {
68
69
  Flv = "FLV",
69
70
  Fractal = "FRACTAL",
70
71
  Ftp = "FTP",
72
+ Ftxt = "FTXT",
71
73
  Fts = "FTS",
72
74
  G = "G",
73
75
  G3 = "G3",
@@ -110,6 +112,7 @@ export declare enum MagickFormat {
110
112
  Jps = "JPS",
111
113
  Jpt = "JPT",
112
114
  Json = "JSON",
115
+ Jxl = "JXL",
113
116
  K = "K",
114
117
  K25 = "K25",
115
118
  Kdc = "KDC",
@@ -189,6 +192,7 @@ export declare enum MagickFormat {
189
192
  Psd = "PSD",
190
193
  Ptif = "PTIF",
191
194
  Pwp = "PWP",
195
+ Qoi = "QOI",
192
196
  R = "R",
193
197
  RadialGradient = "RADIAL-GRADIENT",
194
198
  Raf = "RAF",
@@ -215,6 +219,7 @@ export declare enum MagickFormat {
215
219
  Sr2 = "SR2",
216
220
  Srf = "SRF",
217
221
  Stegano = "STEGANO",
222
+ StrImg = "STRIMG",
218
223
  Sun = "SUN",
219
224
  Svg = "SVG",
220
225
  Svgz = "SVGZ",
package/magick-format.js CHANGED
@@ -63,6 +63,7 @@ var MagickFormat;
63
63
  MagickFormat["Ept2"] = "EPT2";
64
64
  MagickFormat["Ept3"] = "EPT3";
65
65
  MagickFormat["Erf"] = "ERF";
66
+ MagickFormat["Exr"] = "EXR";
66
67
  MagickFormat["Farbfeld"] = "FARBFELD";
67
68
  MagickFormat["Fax"] = "FAX";
68
69
  MagickFormat["FF"] = "FF";
@@ -72,6 +73,7 @@ var MagickFormat;
72
73
  MagickFormat["Flv"] = "FLV";
73
74
  MagickFormat["Fractal"] = "FRACTAL";
74
75
  MagickFormat["Ftp"] = "FTP";
76
+ MagickFormat["Ftxt"] = "FTXT";
75
77
  MagickFormat["Fts"] = "FTS";
76
78
  MagickFormat["G"] = "G";
77
79
  MagickFormat["G3"] = "G3";
@@ -114,6 +116,7 @@ var MagickFormat;
114
116
  MagickFormat["Jps"] = "JPS";
115
117
  MagickFormat["Jpt"] = "JPT";
116
118
  MagickFormat["Json"] = "JSON";
119
+ MagickFormat["Jxl"] = "JXL";
117
120
  MagickFormat["K"] = "K";
118
121
  MagickFormat["K25"] = "K25";
119
122
  MagickFormat["Kdc"] = "KDC";
@@ -193,6 +196,7 @@ var MagickFormat;
193
196
  MagickFormat["Psd"] = "PSD";
194
197
  MagickFormat["Ptif"] = "PTIF";
195
198
  MagickFormat["Pwp"] = "PWP";
199
+ MagickFormat["Qoi"] = "QOI";
196
200
  MagickFormat["R"] = "R";
197
201
  MagickFormat["RadialGradient"] = "RADIAL-GRADIENT";
198
202
  MagickFormat["Raf"] = "RAF";
@@ -219,6 +223,7 @@ var MagickFormat;
219
223
  MagickFormat["Sr2"] = "SR2";
220
224
  MagickFormat["Srf"] = "SRF";
221
225
  MagickFormat["Stegano"] = "STEGANO";
226
+ MagickFormat["StrImg"] = "STRIMG";
222
227
  MagickFormat["Sun"] = "SUN";
223
228
  MagickFormat["Svg"] = "SVG";
224
229
  MagickFormat["Svgz"] = "SVGZ";
@@ -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');
@@ -109,6 +109,35 @@ class MagickGeometry {
109
109
  result += '@';
110
110
  return result;
111
111
  }
112
+ static fromRectangle(rectangle) {
113
+ if (rectangle === 0)
114
+ throw new magick_error_1.MagickError('unable to allocate memory');
115
+ try {
116
+ const width = image_magick_1.ImageMagick._api._MagickRectangle_Width_Get(rectangle);
117
+ const height = image_magick_1.ImageMagick._api._MagickRectangle_Height_Get(rectangle);
118
+ const x = image_magick_1.ImageMagick._api._MagickRectangle_X_Get(rectangle);
119
+ const y = image_magick_1.ImageMagick._api._MagickRectangle_Y_Get(rectangle);
120
+ return new MagickGeometry(x, y, width, height);
121
+ }
122
+ finally {
123
+ image_magick_1.ImageMagick._api._MagickRectangle_Dispose(rectangle);
124
+ }
125
+ }
126
+ toRectangle(func) {
127
+ const rectangle = image_magick_1.ImageMagick._api._MagickRectangle_Create();
128
+ if (rectangle === 0)
129
+ throw new magick_error_1.MagickError('unable to allocate memory');
130
+ try {
131
+ image_magick_1.ImageMagick._api._MagickRectangle_Width_Set(rectangle, this._width);
132
+ image_magick_1.ImageMagick._api._MagickRectangle_Height_Set(rectangle, this._height);
133
+ image_magick_1.ImageMagick._api._MagickRectangle_X_Set(rectangle, this._x);
134
+ image_magick_1.ImageMagick._api._MagickRectangle_Y_Set(rectangle, this._y);
135
+ func(rectangle);
136
+ }
137
+ finally {
138
+ image_magick_1.ImageMagick._api._MagickRectangle_Dispose(rectangle);
139
+ }
140
+ }
112
141
  initialize(instance, flags) {
113
142
  this._width = image_magick_1.ImageMagick._api._MagickGeometry_Width_Get(instance);
114
143
  this._height = image_magick_1.ImageMagick._api._MagickGeometry_Height_Get(instance);
@@ -1,18 +1,27 @@
1
+ import { IMagickImage } from './magick-image';
2
+ import { MagickFormat } from './magick-format';
1
3
  import { MagickImage } from './magick-image';
2
4
  import { MagickReadSettings } from './settings/magick-read-settings';
3
- export interface IMagickImageCollection extends Array<MagickImage> {
5
+ export interface IMagickImageCollection extends Array<IMagickImage> {
4
6
  dispose(): void;
5
7
  read(fileName: string, settings?: MagickReadSettings): void;
6
8
  read(array: Uint8Array, settings?: MagickReadSettings): void;
9
+ write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
10
+ write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
7
11
  }
8
12
  export declare class MagickImageCollection extends Array<MagickImage> implements IMagickImageCollection {
9
13
  private constructor();
10
14
  dispose(): void;
11
15
  read(fileName: string, settings?: MagickReadSettings): void;
12
16
  read(array: Uint8Array, settings?: MagickReadSettings): void;
17
+ write(func: (data: Uint8Array) => void, format?: MagickFormat): void;
18
+ write(func: (data: Uint8Array) => Promise<void>, format?: MagickFormat): Promise<void>;
13
19
  static create(): IMagickImageCollection;
14
20
  _use(func: (images: IMagickImageCollection) => Promise<void>): Promise<void>;
21
+ private addImages;
22
+ private attachImages;
15
23
  private static createObject;
16
24
  private static createSettings;
17
- private addImages;
25
+ private detachImages;
26
+ private throwIfEmpty;
18
27
  }