@imagemagick/magick-wasm
Version:
The WASM library for ImageMagick
2,542 lines (2,541 loc) • 340 kB
JavaScript
function ti(M) {
return M instanceof Int8Array || M instanceof Uint8Array || M instanceof Uint8ClampedArray;
}
class Xr {
fileName;
data;
constructor(e, n) {
this.fileName = e, this.data = n;
}
}
const qr = {
XmlResourceFiles: {
log: `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE logmap [
<!ELEMENT logmap (log)+>
<!ELEMENT log (#PCDATA)>
<!ATTLIST log events CDATA #IMPLIED>
<!ATTLIST log output CDATA #IMPLIED>
<!ATTLIST log filename CDATA #IMPLIED>
<!ATTLIST log generations CDATA #IMPLIED>
<!ATTLIST log limit CDATA #IMPLIED>
<!ATTLIST log format CDATA #IMPLIED>
]>
<logmap>
<log events="None"/>
<log output="Debug"/>
<log filename="Magick-%g.log"/>
<log generations="3"/>
<log limit="2000"/>
<log format="%t %r %u %v %d %c[%p]: %m/%f/%l/%d
%e"/>
</logmap>
`,
policy: `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)*>
<!ATTLIST policymap xmlns CDATA #FIXED "">
<!ELEMENT policy EMPTY>
<!ATTLIST policy xmlns CDATA #FIXED "">
<!ATTLIST policy domain NMTOKEN #REQUIRED>
<!ATTLIST policy name NMTOKEN #IMPLIED>
<!ATTLIST policy pattern CDATA #IMPLIED>
<!ATTLIST policy rights NMTOKEN #IMPLIED>
<!ATTLIST policy stealth NMTOKEN #IMPLIED>
<!ATTLIST policy value CDATA #IMPLIED>
]>
<policymap>
<policy domain="cache" name="shared-secret" value="passphrase"/>
<policy domain="coder" rights="none" pattern="EPHEMERAL" />
<policy domain="coder" rights="none" pattern="MVG" />
<policy domain="coder" rights="none" pattern="MSL" />
<policy domain="path" rights="none" pattern="@*" />
<policy domain="path" rights="none" pattern="|*" />
</policymap>
`
}
};
class ir {
constructor() {
this.log = new Xr("log.xml", qr.XmlResourceFiles.log), this.policy = new Xr("policy.xml", qr.XmlResourceFiles.policy);
}
/**
* Gets the default configuration.
*/
static default = new ir();
/**
* Gets all the configuration files.
*/
*all() {
yield this.log, yield this.policy;
}
/// <summary>
/// Gets the log configuration.
/// </summary>
log;
/// <summary>
/// Gets the policy configuration.
/// </summary>
policy;
}
class Ot {
/**
* Initializes a new instance of the {@link MagickDefine} class.
* @param format
* @param name The name of the define.
* @param value The value of the define.
*/
constructor(e, n, r) {
this.format = e, this.name = n, this.value = r;
}
/**
* Gets the format to set the define for.
*/
format;
/**
* Gets the name of the define.
*/
name;
/**
* Gets the value of the define.
*/
value;
}
class Xs {
format;
constructor(e) {
this.format = e;
}
createDefine(e, n) {
return typeof n == "boolean" ? new Ot(this.format, e, n ? "true" : "false") : typeof n == "string" ? new Ot(this.format, e, n) : new Ot(this.format, e, n.toString());
}
hasValue(e) {
return e != null;
}
}
class zo {
_x;
_y;
_paintMethod;
/**
* Initializes a new instance of the {@link DrawableColor} class.
* @param x The X coordinate.
* @param y The Y coordinate.
* @param paintMethod The paint method to use.
*/
constructor(e, n, r) {
this._x = e, this._y = n, this._paintMethod = r;
}
draw(e) {
e.color(this._x, this._y, this._paintMethod);
}
}
class qs {
_color;
/**
* Initializes a new instance of the {@link DrawableFillColor} class.
* @param color The color to use.
*/
constructor(e) {
this._color = e;
}
draw(e) {
e.fillColor(this._color);
}
}
class Ks {
_opacity;
/**
* Initializes a new instance of the {@link DrawableFillOpacity} class.
* @param opacity The opacity.
*/
constructor(e) {
this._opacity = e;
}
draw(e) {
e.fillOpacity(this._opacity.toDouble() / 100);
}
}
class Qs {
_pointSize;
/**
* Initializes a new instance of the {@link DrawableFontPointSize} class.
* @param pointSize The point size.
*/
constructor(e) {
this._pointSize = e;
}
draw(e) {
e.fontPointSize(this._pointSize);
}
}
class Js {
/**
* Initializes a new instance of the {@link LogEvent} class.
* @param eventType - The type of the log message.
* @param message - The log message.
*/
constructor(e, n) {
this.eventType = e, this.message = n ?? "";
}
/**
* Gets the type of the log message.
*/
eventType;
/**
* Gets the log message.
*/
message;
}
const Os = {
/**
* Undefined.
*/
Undefined: 0,
/**
* Enable the image's transparency channel. Note that normally Set should be used instead of
* this, unless you specifically need to preserve the existing (but specifically turned Off)
* transparency channel.
*/
Activate: 1,
/**
* Associate the alpha channel with the image.
*/
Associate: 2,
/**
* Set any fully-transparent pixel to the background color, while leaving it fully-transparent.
* This can make some image file formats, such as PNG, smaller as the RGB values of transparent
* pixels are more uniform, and thus can compress better.
*/
Background: 3,
/**
* Turns 'On' the alpha/matte channel, then copies the grayscale intensity of the image, into
* the alpha channel, converting a grayscale mask into a transparent shaped mask ready to be
* colored appropriately. The color channels are not modified.
*/
Copy: 4,
/**
* Disables the image's transparency channel. This does not delete or change the existing data,
* it just turns off the use of that data.
*/
Deactivate: 5,
/**
* Discrete.
*/
Discrete: 6,
/**
* Disassociate the alpha channel from the image.
*/
Disassociate: 7,
/**
* Copies the alpha channel values into all the color channels and turns 'Off' the image's
* transparency, so as to generate a grayscale mask of the image's shape. The alpha channel
* data is left intact just deactivated. This is the inverse of 'Copy'.
*/
Extract: 8,
/**
* Off.
*/
Off: 9,
/**
* On.
*/
On: 10,
/**
* Enables the alpha/matte channel and forces it to be fully opaque.
*/
Opaque: 11,
/**
* Composite the image over the background color.
*/
Remove: 12,
/**
* Activates the alpha/matte channel. If it was previously turned off then it also
* resets the channel to opaque. If the image already had the alpha channel turned on,
* it will have no effect.
*/
Set: 13,
/**
* As per 'Copy' but also colors the resulting shape mask with the current background color.
* That is the RGB color channels is replaced, with appropriate alpha shape.
*/
Shape: 14,
/**
* Activates the alpha/matte channel and forces it to be fully transparent. This effectively
* creates a fully transparent image the same size as the original and with all its original
* RGB data still intact, but fully transparent.
*/
Transparent: 15,
/**
* Removes the alpha channel when the alpha value is opaque for all pixels.
*/
OffIfOpaque: 16
}, F = {
/**
* Red.
*/
Red: 0,
/**
* Cyan.
*/
Cyan: 0,
/**
* Gray.
*/
Gray: 0,
/**
* Green.
*/
Green: 1,
/**
* Magenta.
*/
Magenta: 1,
/**
* Blue.
*/
Blue: 2,
/**
* Yellow.
*/
Yellow: 2,
/**
* Black.
*/
Black: 3,
/**
* Alpha.
*/
Alpha: 4,
/**
* Index.
*/
Index: 5,
/**
* Meta 0.
*/
Meta0: 10,
/**
* Meta 1.
*/
Meta1: 11,
/**
* Meta 2.
*/
Meta2: 12,
/**
* Meta 3.
*/
Meta3: 13,
/**
* Meta 4.
*/
Meta4: 14,
/**
* Meta 5.
*/
Meta5: 15,
/**
* Meta 6.
*/
Meta6: 16,
/**
* Meta 7.
*/
Meta7: 17,
/**
* Meta 8.
*/
Meta8: 18,
/**
* Meta 9.
*/
Meta9: 19,
/**
* Meta 10.
*/
Meta10: 20,
/**
* Meta 11.
*/
Meta11: 21,
/**
* Meta 12.
*/
Meta12: 22,
/**
* Meta 13.
*/
Meta13: 23,
/**
* Meta 14.
*/
Meta14: 24,
/**
* Meta 15.
*/
Meta15: 25,
/**
* Meta 16.
*/
Meta16: 26,
/**
* Meta 17.
*/
Meta17: 27,
/**
* Meta 18.
*/
Meta18: 28,
/**
* Meta 19.
*/
Meta19: 29,
/**
* Meta 20.
*/
Meta20: 30,
/**
* Meta 21.
*/
Meta21: 31,
/**
* Meta 22.
*/
Meta22: 32,
/**
* Meta 23.
*/
Meta23: 33,
/**
* Meta 24.
*/
Meta24: 34,
/**
* Meta 25.
*/
Meta25: 35,
/**
* Meta 26.
*/
Meta26: 36,
/**
* Meta 27.
*/
Meta27: 37,
/**
* Meta 28.
*/
Meta28: 38,
/**
* Meta 29.
*/
Meta29: 39,
/**
* Meta 30.
*/
Meta30: 40,
/**
* Meta 31.
*/
Meta31: 41,
/**
* Meta 32.
*/
Meta32: 42,
/**
* Meta 33.
*/
Meta33: 43,
/**
* Meta 34.
*/
Meta34: 44,
/**
* Meta 35.
*/
Meta35: 45,
/**
* Meta 36.
*/
Meta36: 46,
/**
* Meta 37.
*/
Meta37: 47,
/**
* Meta 38.
*/
Meta38: 48,
/**
* Meta 39.
*/
Meta39: 49,
/**
* Meta 40.
*/
Meta40: 50,
/**
* Meta 41.
*/
Meta41: 51,
/**
* Meta 42.
*/
Meta42: 52,
/**
* Meta 43.
*/
Meta43: 53,
/**
* Meta 44.
*/
Meta44: 54,
/**
* Meta 45.
*/
Meta45: 55,
/**
* Meta 46.
*/
Meta46: 56,
/**
* Meta 47.
*/
Meta47: 57,
/**
* Meta 48.
*/
Meta48: 58,
/**
* Meta 49.
*/
Meta49: 59,
/**
* Meta 50.
*/
Meta50: 60,
/**
* Meta 51.
*/
Meta51: 61,
/**
* Meta 52.
*/
Meta52: 62,
/**
* Composite.
*/
Composite: 64
}, X = {
/**
* Undefined.
*/
Undefined: 0,
/**
* Red.
*/
Red: 1,
/**
* Gray.
*/
Gray: 1,
/**
* Cyan.
*/
Cyan: 1,
/**
* Green.
*/
Green: 2,
/**
* Magenta.
*/
Magenta: 2,
/**
* Blue.
*/
Blue: 4,
/**
* Yellow.
*/
Yellow: 4,
/**
* Black.
*/
Black: 8,
/**
* Alpha.
*/
Alpha: 16,
/**
* Opacity.
*/
Opacity: 16,
/**
* Index.
*/
Index: 32,
/**
* Composite.
*/
Composite: 31,
/**
* TrueAlpha.
*/
TrueAlpha: 256,
/**
* RGB.
*/
get RGB() {
return this.Red | this.Green | this.Blue;
},
/**
* CMYK.
*/
get CMYK() {
return this.Cyan | this.Magenta | this.Yellow | this.Black;
},
/**
* CMYKA.
*/
get CMYKA() {
return this.Cyan | this.Magenta | this.Yellow | this.Black | this.Alpha;
},
/**
* Meta 0
*/
Meta0: 1 << F.Meta0,
/**
* Meta 1
*/
Meta1: 1 << F.Meta1,
/**
* Meta 2
*/
Meta2: 1 << F.Meta2,
/**
* Meta 3
*/
Meta3: 1 << F.Meta3,
/**
* Meta 4
*/
Meta4: 1 << F.Meta4,
/**
* Meta 5
*/
Meta5: 1 << F.Meta5,
/**
* Meta 6
*/
Meta6: 1 << F.Meta6,
/**
* Meta 7
*/
Meta7: 1 << F.Meta7,
/**
* Meta 8
*/
Meta8: 1 << F.Meta8,
/**
* Meta 9
*/
Meta9: 1 << F.Meta9,
/**
* Meta 10
*/
Meta10: 1 << F.Meta10,
/**
* Meta 11
*/
Meta11: 1 << F.Meta11,
/**
* Meta 12
*/
Meta12: 1 << F.Meta12,
/**
* Meta 13
*/
Meta13: 1 << F.Meta13,
/**
* Meta 14
*/
Meta14: 1 << F.Meta14,
/**
* Meta 15
*/
Meta15: 1 << F.Meta15,
/**
* Meta 16
*/
Meta16: 1 << F.Meta16,
/**
* Meta 17
*/
Meta17: 1 << F.Meta17,
/**
* Meta 18
*/
Meta18: 1 << F.Meta18,
/**
* Meta 19
*/
Meta19: 1 << F.Meta19,
/**
* Meta 20
*/
Meta20: 1 << F.Meta20,
/**
* Meta 21
*/
Meta21: 1 << F.Meta21,
/**
* All.
*/
All: 134217727
};
class Zs {
constructor(e, n, r, l) {
this.red = e, this.green = n, this.blue = r, this.white = l;
}
/**
* Gets the chromaticity red primary point.
*/
red;
/**
* Gets the chromaticity green primary point.
*/
green;
/**
* Gets the chromaticity blue primary point.
*/
blue;
/**
* Gets the chromaticity white primary point.
*/
white;
}
const D = {
/**
* Undefined.
*/
Undefined: 0,
/**
* CMY.
*/
CMY: 1,
/**
* CMYK.
*/
CMYK: 2,
/**
* Gray.
*/
Gray: 3,
/**
* HCL.
*/
HCL: 4,
/**
* HCLp.
*/
HCLp: 5,
/**
* HSB.
*/
HSB: 6,
/**
* HSI.
*/
HSI: 7,
/**
* HSL.
*/
HSL: 8,
/**
* HSV.
*/
HSV: 9,
/**
* HWB.
*/
HWB: 10,
/**
* Lab
*/
Lab: 11,
/**
* LCH.
*/
LCH: 12,
/**
* LCHab.
*/
LCHab: 13,
/**
* LCHuv.
*/
LCHuv: 14,
/**
* Log.
*/
Log: 15,
/**
* LMS.
*/
LMS: 16,
/**
* Luv.
*/
Luv: 17,
/**
* OHTA.
*/
OHTA: 18,
/**
* Rec601YCbCr.
*/
Rec601YCbCr: 19,
/**
* Rec709YCbCr.
*/
Rec709YCbCr: 20,
/**
* RGB.
*/
RGB: 21,
/**
* scRGB.
*/
scRGB: 22,
/**
* sRGB.
*/
sRGB: 23,
/**
* Transparent.
*/
Transparent: 24,
/**
* XyY.
*/
XyY: 25,
/**
* XYZ.
*/
XYZ: 26,
/**
* YCbCr.
*/
YCbCr: 27,
/**
* YCC.
*/
YCC: 28,
/**
* YDbDr.
*/
YDbDr: 29,
/**
* YIQ.
*/
YIQ: 30,
/**
* YPbPr.
*/
YPbPr: 31,
/**
* YUV.
*/
YUV: 32,
/**
* LinearGray.
*/
LinearGray: 33,
/**
* Jzazbz.
*/
Jzazbz: 34,
/**
* DisplayP3.
*/
DisplayP3: 35,
/**
* Adobe98.
*/
Adobe98: 36,
/**
* ProPhoto.
*/
ProPhoto: 37,
/**
* Oklab.
*/
Oklab: 38,
/**
* Oklch.
*/
Oklch: 39,
/**
* CAT02LMS.
*/
CAT02LMSC: 40
}, Kr = {
[D.Undefined]: "Undefined",
[D.CMY]: "CMY",
[D.CMYK]: "CMYK",
[D.Gray]: "Gray",
[D.HCL]: "HCL",
[D.HCLp]: "HCLp",
[D.HSB]: "HSB",
[D.HSI]: "HSI",
[D.HSL]: "HSL",
[D.HSV]: "HSV",
[D.HWB]: "HWB",
[D.Lab]: "Lab",
[D.LCH]: "LCH",
[D.LCHab]: "LCHab",
[D.LCHuv]: "LCHuv",
[D.Log]: "Log",
[D.LMS]: "LMS",
[D.Luv]: "Luv",
[D.OHTA]: "OHTA",
[D.Rec601YCbCr]: "Rec601YCbCr",
[D.Rec709YCbCr]: "Rec709YCbCr",
[D.RGB]: "RGB",
[D.scRGB]: "scRGB",
[D.sRGB]: "sRGB",
[D.Transparent]: "Transparent",
[D.XyY]: "XyY",
[D.XYZ]: "XYZ",
[D.YCbCr]: "YCbCr",
[D.YCC]: "YCC",
[D.YDbDr]: "YDbDr",
[D.YIQ]: "YIQ",
[D.YPbPr]: "YPbPr",
[D.YUV]: "YUV",
[D.LinearGray]: "LinearGray",
[D.Jzazbz]: "Jzazbz",
[D.DisplayP3]: "DisplayP3",
[D.Adobe98]: "Adobe98",
[D.ProPhoto]: "ProPhoto",
[D.Oklab]: "Oklab",
[D.Oklch]: "Oklch",
[D.CAT02LMSC]: "CAT02LMS"
};
class eo {
colorSpace = D.Undefined;
copyright = null;
description = null;
manufacturer = null;
model = null;
}
class to {
_data;
_index;
constructor(e) {
this._data = e, this._index = 0, this.isLittleEndian = !1;
}
get index() {
return this._index;
}
isLittleEndian;
readLong() {
return this.canRead(4) ? this.isLittleEndian ? this.readLongLSB() : this.readLongMSB() : null;
}
readString(e) {
if (e == 0)
return "";
if (!this.canRead(e))
return null;
let r = new TextDecoder("utf-8").decode(this._data.subarray(this._index, this._index + e));
const l = r.indexOf("\0");
return l != -1 && (r = r.substring(0, l)), this._index += e, r;
}
seek(e) {
return e >= this._data.length ? !1 : (this._index = e, !0);
}
skip(e) {
return this._index + e >= this._data.length ? !1 : (this._index += e, !0);
}
canRead(e) {
return e > this._data.length ? !1 : this._index + e <= this._data.length;
}
readLongLSB() {
let e = this._data[this._index];
return e |= this._data[this._index + 1] << 8, e |= this._data[this._index + 2] << 16, e |= this._data[this._index + 3] << 24, this._index += 4, e;
}
readLongMSB() {
let e = this._data[this._index] << 24;
return e |= this._data[this._index + 1] << 16, e |= this._data[this._index + 2] << 8, e |= this._data[this._index + 3], this._index += 4, e;
}
}
class nr {
_data = new eo();
_reader;
constructor(e) {
this._reader = new to(e);
}
static read(e) {
const n = new nr(e);
return n.readColorSpace(), n.readTagTable(), n._data;
}
readColorSpace() {
this._reader.seek(16);
const e = this._reader.readString(4);
e != null && (this._data.colorSpace = this.determineColorSpace(e.trimEnd()));
}
determineColorSpace(e) {
switch (e) {
case "CMY":
return D.CMY;
case "CMYK":
return D.CMYK;
case "GRAY":
return D.Gray;
case "HSL":
return D.HSL;
case "HSV":
return D.HSV;
case "Lab":
return D.Lab;
case "Luv":
return D.Luv;
case "RGB":
return D.sRGB;
case "XYZ":
return D.XYZ;
case "YCbr":
return D.YCbCr;
default:
return D.Undefined;
}
}
readTagTable() {
if (!this._reader.seek(128))
return;
const e = this._reader.readLong();
if (e != null)
for (let n = 0; n < e; n++)
switch (this._reader.readLong()) {
case 1668313716:
this._data.copyright = this.readTag();
break;
case 1684370275:
this._data.description = this.readTag();
break;
case 1684893284:
this._data.manufacturer = this.readTag();
break;
case 1684890724:
this._data.model = this.readTag();
break;
default:
this._reader.skip(8);
break;
}
}
readTag() {
const e = this._reader.readLong(), n = this._reader.readLong();
if (e === null || n === null)
return null;
const r = this._reader.index;
if (!this._reader.seek(e))
return null;
const l = this.readTagValue(n);
return this._reader.seek(r), l;
}
readTagValue(e) {
switch (this._reader.readString(4)) {
case "desc":
return this.readTextDescriptionTypeValue();
case "text":
return this.readTextTypeValue(e);
default:
return null;
}
}
readTextDescriptionTypeValue() {
if (!this._reader.skip(4))
return null;
const e = this._reader.readLong();
return e == null ? null : this._reader.readString(e);
}
readTextTypeValue(e) {
return this._reader.skip(4) ? this._reader.readString(e) : null;
}
}
class ri {
constructor(e, n) {
this.name = e, this.data = n;
}
name;
data;
}
class ro extends ri {
_data;
constructor(e) {
super("icc", e);
}
/**
* Gets the color space of the profile.
*/
get colorSpace() {
return this.initialize(), this._data.colorSpace;
}
/**
* Gets the copyright of the profile.
*/
get copyright() {
return this.initialize(), this._data.copyright;
}
/**
* Gets the description of the profile.
*/
get description() {
return this.initialize(), this._data.description;
}
/**
* Gets the manufacturer of the profile.
*/
get manufacturer() {
return this.initialize(), this._data.manufacturer;
}
/**
* Gets the model of the profile.
*/
get model() {
return this.initialize(), this._data.model;
}
initialize() {
this._data || (this._data = nr.read(this.data));
}
}
const Qr = {
/**
* High resolution (double).
*/
HighRes: 0,
/**
* Quantum.
*/
Quantum: 1
};
class ar {
constructor(e, n) {
this.distortion = e, this.difference = n;
}
/**
* Gets the difference image.
*/
difference;
/**
* Gets the distortion.
*/
distortion;
/** @internal */
static _create(e, n) {
return new ar(e, n);
}
}
class io {
constructor(e) {
this.metric = e;
}
/**
* Gets the distortion method to use.
*/
metric;
/**
* Gets or sets the color that emphasize pixel differences.
*/
highlightColor;
/**
* Gets or sets the color that de-emphasize pixel differences.
*/
lowlightColor;
/**
* Gets or sets the color of pixels that are inside the read mask.
*/
masklightColor;
/** @internal */
_setArtifacts(e) {
this.highlightColor !== void 0 && e.setArtifact("compare:highlight-color", this.highlightColor), this.lowlightColor !== void 0 && e.setArtifact("compare:lowlight-color", this.lowlightColor), this.masklightColor !== void 0 && e.setArtifact("compare:masklight-color", this.masklightColor);
}
}
const Zt = {
/**
* Undefined.
*/
Undefined: 0,
/**
* Alpha.
*/
Alpha: 1,
/**
* Atop.
*/
Atop: 2,
/**
* Blend.
*/
Blend: 3,
/**
* Blur.
*/
Blur: 4,
/**
* Bumpmap.
*/
Bumpmap: 5,
/**
* Change mask.
*/
ChangeMask: 6,
/**
* Clear.
*/
Clear: 7,
/**
* Color burn.
*/
ColorBurn: 8,
/**
* Color dodge.
*/
ColorDodge: 9,
/**
* Colorize.
*/
Colorize: 10,
/**
* Copy black.
*/
CopyBlack: 11,
/**
* Copy blue.
*/
CopyBlue: 12,
/**
* Copy.
*/
Copy: 13,
/**
* Copy cyan.
*/
CopyCyan: 14,
/**
* Copy green.
*/
CopyGreen: 15,
/**
* Copy magenta.
*/
CopyMagenta: 16,
/**
* Copy alpha.
*/
CopyAlpha: 17,
/**
* Copy red.
*/
CopyRed: 18,
/**
* Copy yellow.
*/
CopyYellow: 19,
/**
* Darken.
*/
Darken: 20,
/**
* Darken intensity.
*/
DarkenIntensity: 21,
/**
* Difference.
*/
Difference: 22,
/**
* Displace.
*/
Displace: 23,
/**
* Dissolve.
*/
Dissolve: 24,
/**
* Distort.
*/
Distort: 25,
/**
* Divide dst.
*/
DivideDst: 26,
/**
* Divide src.
*/
DivideSrc: 27,
/**
* Dst atop.
*/
DstAtop: 28,
/**
* Dst.
*/
Dst: 29,
/**
* Dst in.
*/
DstIn: 30,
/**
* Dst out.
*/
DstOut: 31,
/**
* Dst over.
*/
DstOver: 32,
/**
* Exclusion.
*/
Exclusion: 33,
/**
* Hard light.
*/
HardLight: 34,
/**
* Hard mix.
*/
HardMix: 35,
/**
* Hue.
*/
Hue: 36,
/**
* In.
*/
In: 37,
/**
* Intensity.
*/
Intensity: 38,
/**
* Lighten.
*/
Lighten: 39,
/**
* Lighten intensity.
*/
LightenIntensity: 40,
/**
* Linear burn.
*/
LinearBurn: 41,
/**
* Linear dodge.
*/
LinearDodge: 42,
/**
* Linear light.
*/
LinearLight: 43,
/**
* Luminize.
*/
Luminize: 44,
/**
* Mathematics.
*/
Mathematics: 45,
/**
* Minus dst.
*/
MinusDst: 46,
/**
* Minus src.
*/
MinusSrc: 47,
/**
* Modulate.
*/
Modulate: 48,
/**
* Modulus add.
*/
ModulusAdd: 49,
/**
* Modulus subtract.
*/
ModulusSubtract: 50,
/**
* Multiply.
*/
Multiply: 51,
/**
* No.
*/
No: 52,
/**
* Out.
*/
Out: 53,
/**
* Over.
*/
Over: 54,
/**
* Overlay.
*/
Overlay: 55,
/**
* Pegtop light.
*/
PegtopLight: 56,
/**
* Pin light.
*/
PinLight: 57,
/**
* Plus.
*/
Plus: 58,
/**
* Replace.
*/
Replace: 59,
/**
* Saturate.
*/
Saturate: 60,
/**
* Screen.
*/
Screen: 61,
/**
* Soft light.
*/
SoftLight: 62,
/**
* Src atop.
*/
SrcAtop: 63,
/**
* Src.
*/
Src: 64,
/**
* Src in.
*/
SrcIn: 65,
/**
* Src out.
*/
SrcOut: 66,
/**
* Src over.
*/
SrcOver: 67,
/**
* Threshold.
*/
Threshold: 68,
/**
* Vivid light.
*/
VividLight: 69,
/**
* Xor.
*/
Xor: 70,
/**
* Stereo.
*/
Stereo: 71,
/**
* Freeze.
*/
Freeze: 72,
/**
* Interpolate.
*/
Interpolate: 73,
/**
* Negate.
*/
Negate: 74,
/**
* Reflect.
*/
Reflect: 75,
/**
* Soft burn.
*/
SoftBurn: 76,
/**
* Soft dodge.
*/
SoftDodge: 77,
/**
* Stamp.
*/
Stamp: 78,
/**
* Root-mean-square error.
*/
RMSE: 79,
/**
* Saliency blend.
*/
SaliencyBlend: 80,
/**
* Seamless blend.
*/
SeamlessBlend: 81
}, er = {
/**
* Warning.
*/
Warning: 300,
/**
* Resource limit warning.
*/
ResourceLimitWarning: 300,
/**
* Type warning.
*/
TypeWarning: 305,
/**
* Option warning.
*/
OptionWarning: 310,
/**
* Delegate warning.
*/
DelegateWarning: 315,
/**
* Missing delegate warning.
*/
MissingDelegateWarning: 320,
/**
* Corrupt image warning.
*/
CorruptImageWarning: 325,
/**
* File open warning.
*/
FileOpenWarning: 330,
/**
* Blob warning.
*/
BlobWarning: 335,
/**
* Stream warning.
*/
StreamWarning: 340,
/**
* Cache warning.
*/
CacheWarning: 345,
/**
* Coder warning.
*/
CoderWarning: 350,
/**
* Filter warning.
*/
FilterWarning: 352,
/**
* Module warning.
*/
ModuleWarning: 355,
/**
* Draw warning.
*/
DrawWarning: 360,
/**
* Image warning.
*/
ImageWarning: 365,
/**
* Wand warning.
*/
WandWarning: 370,
/**
* Random warning.
*/
RandomWarning: 375,
/**
* X server warning.
*/
XServerWarning: 380,
/**
* Monitor warning.
*/
MonitorWarning: 385,
/**
* Registry warning.
*/
RegistryWarning: 390,
/**
* Configure warning.
*/
ConfigureWarning: 395,
/**
* Policy warning.
*/
PolicyWarning: 399,
/**
* Error.
*/
Error: 400,
/**
* Resource limit error.
*/
ResourceLimitError: 400,
/**
* Type error.
*/
TypeError: 405,
/**
* Option error.
*/
OptionError: 410,
/**
* Delegate error.
*/
DelegateError: 415,
/**
* Missing delegate error.
*/
MissingDelegateError: 420,
/**
* Corrupt image error.
*/
CorruptImageError: 425,
/**
* File open error.
*/
FileOpenError: 430,
/**
* Blob error.
*/
BlobError: 435,
/**
* Stream error.
*/
StreamError: 440,
/**
* Cache error.
*/
CacheError: 445,
/**
* Coder error.
*/
CoderError: 450,
/**
* Filter error.
*/
FilterError: 452,
/**
* Module error.
*/
ModuleError: 455,
/**
* Draw error.
*/
DrawError: 460,
/**
* Image error.
*/
ImageError: 465,
/**
* Wand error.
*/
WandError: 470,
/**
* Random error.
*/
RandomError: 475,
/**
* X server error.
*/
XServerError: 480,
/**
* Monitor error.
*/
MonitorError: 485,
/**
* Registry error.
*/
RegistryError: 490,
/**
* Configure error.
*/
ConfigureError: 495,
/**
* Policy error.
*/
PolicyError: 499
};
class U extends Error {
_relatedErrors = [];
/** @internal */
constructor(e, n = er.Error) {
super(e), this.severity = n;
}
/**
* Gets the severity of an exception.
*/
severity;
/**
* Gets the exceptions that are related to this exception.
*/
get relatedErrors() {
return this._relatedErrors;
}
/** @internal */
_setRelatedErrors(e) {
this._relatedErrors = e;
}
}
class je {
/**
* Gets the quantum depth.
*/
static get depth() {
return _._api._Quantum_Depth_Get();
}
/**
* Gets the maximum value of the quantum.
*/
static get max() {
return _._api._Quantum_Max_Get();
}
}
function ge(M, e) {
return M === 0 ? e ?? null : _._api.UTF8ToString(M);
}
function no(M, e) {
const n = ge(e);
return M._MagickMemory_Relinquish(e), n;
}
function tr(M, e, n) {
const r = M.lengthBytesUTF8(e) + 1, l = M._malloc(r);
try {
return M.stringToUTF8(e, l, r), n(l);
} finally {
M._free(l);
}
}
function A(M, e) {
return M === null ? e(0) : tr(_._api, M, e);
}
class k {
constructor(e, n, r, l, d) {
if (e !== void 0)
if (typeof e == "string") {
let p = 0;
try {
p = _._api._MagickColor_Create(), A(e, (v) => {
if (_._api._MagickColor_Initialize(p, v) === 0)
throw new U("invalid color specified");
this.initialize(p);
});
} finally {
_._api._free(p);
}
} else
this.r = e, this.g = n ?? 0, this.b = r ?? 0, d === void 0 ? this.a = l ?? je.max : (this.k = l ?? 0, this.a = d, this.isCmyk = !0);
}
r = 0;
g = 0;
b = 0;
a = 0;
k = 0;
isCmyk = !1;
/** @internal */
static _create(e) {
const n = new k();
return n.initialize(e), n;
}
toShortString() {
return this.a !== je.max ? this.toString() : this.isCmyk ? `cmyka(${this.r},${this.g},${this.b},${this.k})` : `#${this.toHex(this.r)}${this.toHex(this.g)}${this.toHex(this.b)}`;
}
toString() {
return this.isCmyk ? `cmyka(${this.r},${this.g},${this.b},${this.k},${(this.a / je.max).toFixed(4)})` : `#${this.toHex(this.r)}${this.toHex(this.g)}${this.toHex(this.b)}${this.toHex(this.a)}`;
}
/** @internal */
_use(e) {
let n = 0;
try {
n = _._api._MagickColor_Create(), _._api._MagickColor_Red_Set(n, this.r), _._api._MagickColor_Green_Set(n, this.g), _._api._MagickColor_Blue_Set(n, this.b), _._api._MagickColor_Alpha_Set(n, this.a), _._api._MagickColor_IsCMYK_Set(n, this.isCmyk ? 1 : 0), e(n);
} finally {
_._api._free(n);
}
}
initialize(e) {
this.r = _._api._MagickColor_Red_Get(e), this.g = _._api._MagickColor_Green_Get(e), this.b = _._api._MagickColor_Blue_Get(e), this.a = _._api._MagickColor_Alpha_Get(e), this.isCmyk = _._api._MagickColor_IsCMYK_Get(e) === 1;
}
toHex(e) {
return e.toString(16).padStart(2, "0");
}
}
var Ie = /* @__PURE__ */ ((M) => (M[M.NoValue = 0] = "NoValue", M[M.PercentValue = 4096] = "PercentValue", M[M.IgnoreAspectRatio = 8192] = "IgnoreAspectRatio", M[M.Less = 16384] = "Less", M[M.Greater = 32768] = "Greater", M[M.FillArea = 65536] = "FillArea", M[M.LimitPixels = 131072] = "LimitPixels", M[M.AspectRatio = 1048576] = "AspectRatio", M))(Ie || {});
class ne {
_includeXyInToString;
_width = 0;
_height = 0;
_x = 0;
_y = 0;
_aspectRatio = !1;
_fillArea = !1;
_greater = !1;
_isPercentage = !1;
_ignoreAspectRatio = !1;
_less = !1;
_limitPixels = !1;
constructor(e, n, r, l) {
if (typeof e == "number") {
if (r !== void 0 && l !== void 0 ? (this._width = r, this._height = l, this._x = e, this._y = n ?? 0, this._includeXyInToString = !0) : (this._width = e, this._height = n ?? this._width, this._x = 0, this._y = 0, this._includeXyInToString = !1), this._width < 0)
throw new U("negative width is not allowed");
if (this._height < 0)
throw new U("negative height is not allowed");
} else {
this._includeXyInToString = e.indexOf("+") >= 0 || e.indexOf("-") >= 0;
const d = _._api._MagickGeometry_Create();
try {
A(e, (p) => {
const v = _._api._MagickGeometry_Initialize(d, p);
if (v === Ie.NoValue)
throw new U("invalid geometry specified");
this.hasFlag(v, Ie.AspectRatio) ? this.initializeFromAspectRation(d, e) : this.initialize(d, v);
});
} finally {
_._api._MagickGeometry_Dispose(d);
}
}
}
get aspectRatio() {
return this._aspectRatio;
}
get fillArea() {
return this._fillArea;
}
set fillArea(e) {
this._fillArea = e;
}
get greater() {
return this._greater;
}
set greater(e) {
this._greater = e;
}
get height() {
return this._height;
}
set height(e) {
this._height = e;
}
get ignoreAspectRatio() {
return this._ignoreAspectRatio;
}
set ignoreAspectRatio(e) {
this._ignoreAspectRatio = e;
}
get isPercentage() {
return this._isPercentage;
}
set isPercentage(e) {
this._isPercentage = e;
}
get less() {
return this._less;
}
set less(e) {
this._less = e;
}
get limitPixels() {
return this._limitPixels;
}
set limitPixels(e) {
this._limitPixels = e;
}
get width() {
return this._width;
}
set width(e) {
this._width = e;
}
get x() {
return this._x;
}
set x(e) {
this._x = e;
}
get y() {
return this._y;
}
set y(e) {
this._y = e;
}
toString() {
if (this._aspectRatio)
return this._width + ":" + this._height;
let e = "";
return this._width == 0 && this._height == 0 ? e += "0x0" : (this._width > 0 && (e += this._width.toString()), this._height > 0 ? e += "x" + this._height.toString() : e += "x"), (this._x != 0 || this._y != 0 || this._includeXyInToString) && (this._x >= 0 && (e += "+"), e += this._x, this.y >= 0 && (e += "+"), e += this.y), this._fillArea && (e += "^"), this._greater && (e += ">"), this._isPercentage && (e += "%"), this._ignoreAspectRatio && (e += "!"), this._less && (e += "<"), this._limitPixels && (e += "@"), e;
}
/** @internal */
static _fromRectangle(e) {
if (e === 0)
throw new U("unable to allocate memory");
try {
const n = _._api._MagickRectangle_Width_Get(e), r = _._api._MagickRectangle_Height_Get(e), l = _._api._MagickRectangle_X_Get(e), d = _._api._MagickRectangle_Y_Get(e);
return new ne(l, d, n, r);
} finally {
_._api._MagickRectangle_Dispose(e);
}
}
/** @internal */
_toRectangle(e) {
const n = _._api._MagickRectangle_Create();
if (n === 0)
throw new U("unable to allocate memory");
try {
return _._api._MagickRectangle_Width_Set(n, this._width), _._api._MagickRectangle_Height_Set(n, this._height), _._api._MagickRectangle_X_Set(n, this._x), _._api._MagickRectangle_Y_Set(n, this._y), e(n);
} finally {
_._api._MagickRectangle_Dispose(n);
}
}
initialize(e, n) {
this._width = _._api._MagickGeometry_Width_Get(e), this._height = _._api._MagickGeometry_Height_Get(e), this._x = _._api._MagickGeometry_X_Get(e), this._y = _._api._MagickGeometry_Y_Get(e), this._ignoreAspectRatio = this.hasFlag(n, Ie.IgnoreAspectRatio), this._isPercentage = this.hasFlag(n, Ie.PercentValue), this._fillArea = this.hasFlag(n, Ie.FillArea), this._greater = this.hasFlag(n, Ie.Greater), this._less = this.hasFlag(n, Ie.Less), this._limitPixels = this.hasFlag(n, Ie.LimitPixels);
}
initializeFromAspectRation(e, n) {
this._aspectRatio = !0;
const r = n.split(":");
this._width = this.parseNumber(r[0]), this._height = this.parseNumber(r[1]), this._x = _._api._MagickGeometry_X_Get(e), this._y = _._api._MagickGeometry_Y_Get(e);
}
parseNumber(e) {
let n = 0;
for (; n < e.length && !this.isNumber(e[n]); )
n++;
const r = n;
for (; n < e.length && this.isNumber(e[n]); )
n++;
return parseInt(e.substr(r, n - r));
}
isNumber(e) {
return e >= "0" && e <= "9";
}
hasFlag(e, n) {
return (e & n) === n;
}
}
class Pe {
constructor(e, n) {
this.x = e, this.y = n ?? e;
}
/**
* Gets the x-coordinate of this point.
*/
x;
/**
* Gets the y-coordinate of this point.
*/
y;
/** @internal */
static _create(e) {
return e === 0 ? new Pe(0, 0) : new Pe(_._api._PointInfo_X_Get(e), _._api._PointInfo_Y_Get(e));
}
}
class sr {
constructor(e) {
this.area = _._api._ConnectedComponent_GetArea(e), this.centroid = Pe._create(_._api._ConnectedComponent_GetCentroid(e)), this.color = k._create(_._api._ConnectedComponent_GetColor(e)), this.height = _._api._ConnectedComponent_GetHeight(e), this.id = _._api._ConnectedComponent_GetId(e), this.width = _._api._ConnectedComponent_GetWidth(e), this.x = _._api._ConnectedComponent_GetX(e), this.y = _._api._ConnectedComponent_GetY(e);
}
/**
* The pixel count of the area.
*/
area;
/**
* The centroid of the area.
*/
centroid;
/**
* The color of the area.
*/
color;
/**
* The height of the area.
*/
height;
/**
* The id of the area.
*/
id;
/**
* The width of the area.
*/
width;
/**
* The X offset from origin.
*/
x;
/**
* The Y offset from origin.
*/
y;
/** @internal */
static _create(e, n) {
const r = [];
if (e === 0)
return r;
for (let l = 0; l < n; l++) {
const d = _._api._ConnectedComponent_GetInstance(e, l);
d === 0 || _._api._ConnectedComponent_GetArea(d) < Number.EPSILON || r.push(new sr(d));
}
return r;
}
/**
* Returns the geometry of the area of the connected component.
*/
toGeometry() {
return new ne(this.x, this.y, this.width, this.height);
}
}
class ao {
/**
* The threshold that merges any object not within the min and max angle
* threshold.
**/
angleThreshold;
/**
* The threshold that eliminates small objects by merging them with their
* larger neighbors.
*/
areaThreshold;
/**
* The threshold that merges any object not within the min and max
* circularity threshold.
*/
circularityThreshold;
/**
* The number of neighbors to visit (4 or 8).
*/
connectivity;
/**
* The threshold that merges any object not within the min and max diameter
* threshold.
*/
diameterThreshold;
/**
* The threshold that merges any object not within the min and max
* eccentricity threshold.
*/
eccentricityThreshold;
/**
* The threshold that merges any object not within the min and max ellipse
* major threshold.
*/
majorAxisThreshold;
/**
* Whether the object color in the component labeled image will be replaced
* with the mean color from the source image (defaults to grayscale).
*/
meanColor;
/**
* The threshold that merges any object not within the min and max ellipse
* minor threshold.
*/
minorAxisThreshold;
/**
* The threshold that merges any object not within the min and max perimeter
* threshold.
*/
perimeterThreshold;
constructor(e) {
this.connectivity = e;
}
/** @internal */
_setArtifacts(e) {
this.angleThreshold !== void 0 && e.setArtifact("connected-components:angle-threshold", this.angleThreshold.toString()), this.areaThreshold !== void 0 && e.setArtifact("connected-components:area-threshold", this.areaThreshold.toString()), this.circularityThreshold !== void 0 && e.setArtifact("connected-components:circularity-threshold", this.circularityThreshold.toString()), this.diameterThreshold !== void 0 && e.setArtifact("connected-components:diameter-threshold", this.diameterThreshold.toString()), this.eccentricityThreshold !== void 0 && e.setArtifact("connected-components:eccentricity-threshold", this.eccentricityThreshold.toString()), this.majorAxisThreshold !== void 0 && e.setArtifact("connected-components:major-axis-threshold", this.majorAxisThreshold.toString()), this.meanColor !== void 0 && e.setArtifact("connected-components:mean-color", this.meanColor.toString()), this.minorAxisThreshold !== void 0 && e.setArtifact("connected-components:minor-axis-threshold", this.minorAxisThreshold.toString()), this.perimeterThreshold !== void 0 && e.setArtifact("connected-components:perimeter-threshold", this.perimeterThreshold.toString());
}
}
const He = {
/**
* Undefined.
*/
Undefined: 0,
/**
* Pixels per inch.
*/
PixelsPerInch: 1,
/**
* Pixels per centimeter.
*/
PixelsPerCentimeter: 2
};
class et {
constructor(e, n, r) {
n === void 0 ? (this.x = e, this.y = e, this.units = He.PixelsPerInch) : r !== void 0 ? (this.x = e, this.y = n, this.units = r) : (this.x = e, this.y = e, this.units = n);
}
/**
* Gets the x resolution.
*/
x;
/**
* Gets the y resolution.
*/
y;
/**
* Gets the units.
*/
units;
/**
* Returns a string that represents the current {@link Density} object.
*/
toString(e) {
return e == this.units || e === He.Undefined || e === void 0 ? et.toString(this.x, this.y, e ?? He.Undefined) : this.units == He.PixelsPerCentimeter && e == He.PixelsPerInch ? et.toString(this.x * 2.54, this.y * 2.54, e) : et.toString(this.x / 2.54, this.y / 2.54, e);
}
static toString(e, n, r) {
let l = `${e}x${n}`;
switch (r) {
case He.PixelsPerCentimeter:
l += "cm";
break;
case He.PixelsPerInch:
l += "inch";
break;
}
return l;
}
}
class ce {
static _disposeAfterExecution(e, n) {
try {
const r = n(e);
return r instanceof Promise ? Promise.resolve(r).then((l) => (e.dispose(), ce.checkResult(e, l), l)) : (e.dispose(), ce.checkResult(e, r), r);
} catch (r) {
throw e.dispose(), r;
}
}
static checkResult(e, n) {
if (n === e)
throw new U("The result of the function cannot be the instance that has been disposed.");
return n;
}
}
class ii {
_pointer;
_bytes;
_func;
constructor(e, n, r) {
this._pointer = e, this._func = r, this._bytes = _._api.HEAPU8.subarray(e, e + n);
}
func(e) {
return e._bytes === void 0 ? e._func(new Uint8Array()) : e._func(e._bytes);
}
dispose() {
this._pointer = _._api._MagickMemory_Relinquish(this._pointer);
}
}
class Ye {
disposeMethod;
instance;
/** @internal */
constructor(e, n) {
this.instance = e, this.disposeMethod = n;
}
/** @internal */
get _instance() {
if (this.instance > 0)
return this.instance;
throw this.instance === -1 && this._instanceNotInitialized(), new U("instance is disposed");
}
/** @internal */
set _instance(e) {
this.disposeInstance(this.instance), this.instance = e;
}
dispose() {
this.instance = this.disposeInstance(this.instance);
}
/** @internal */
_instanceNotInitialized() {
throw new U("instance is not initialized");
}
/** @internal */
_setInstance(e, n) {
return n.check(() => this.instance === 0 ? !1 : (this.dispose(), this.instance = e, !0), () => (this.disposeInstance(e), !0));
}
disposeInstance(e) {
return e > 0 && (this.onDispose !== void 0 && this.onDispose(), this.disposeMethod(e)), 0;
}
}
class so extends Ye {
constructor(e) {
const n = _._api._DrawingSettings_Create(), r = _._api._DrawingSettings_Dispose;
if (super(n, r), e.fillColor !== void 0 && e.fillColor._use((l) => {
_._api._DrawingSettings_FillColor_Set(this._instance, l);
}), e.font !== void 0) {
const l = be._getFontFileName(e.font);
A(l, (d) => {
_._api._DrawingSettings_Font_Set(this._instance, d);
});
}
e.fontPointsize !== void 0 && _._api._DrawingSettings_FontPointsize_Set(this._instance, e.fontPointsize), e.strokeColor !== void 0 && e.strokeColor._use((l) => {
_._api._DrawingSettings_StrokeColor_Set(this._instance, l);
}), e.strokeWidth !== void 0 && _._api._DrawingSettings_StrokeWidth_Set(this._instance, e.strokeWidth);
}
}
class Et {
backgroundColor;
fillColor;
font;
fontPointsize;
strokeColor;
strokeWidth;
static _create(e) {
const n = new Et();
return n.fillColor = e.fillColor, n.font = e.font, n.fontPointsize = e.fontPointsize, n.strokeColor = e.strokeColor, n.strokeWidth = e.strokeWidth, n;
}
_use(e) {
const n = new so(this);
return ce._disposeAfterExecution(n, e);
}
}
class ni {
instance;
type;
constructor(e, n) {
this.instance = _._api._malloc(e), this.type = n, _._api.setValue(this.instance, 0, this.type);
}
get ptr() {
return this.instance;
}
get value() {
return _._api.getValue(this.instance, this.type);
}
}
class Te extends ni {
constructor() {
super(4, "i32");
}
static use(e) {
const n = new Te();
try {
return e(n);
} finally {
_._api._free(n.ptr);
}
}
}
class T {
pointer;
constructor(e) {
this.pointer = e;
}
get ptr() {
return this.pointer.ptr;
}
check(e, n) {
return this.isError() ? n() : e();
}
static usePointer(e, n) {
return Te.use((r) => {
const l = e(r.ptr);
return T.checkException(r, l, n);
});
}
static use(e, n) {
return Te.use((r) => {
const l = e(new T(r));
return T.checkException(r, l, n);
});
}
static checkException(e, n, r) {
if (!T.isRaised(e))
return n;
const l = T.getErrorSeverity(e.value);
if (l >= er.Error)
T.throw(e, l);
else if (r !== void 0) {
const d = T.createError(e.value, l);
r(d);
} else
T.dispose(e);
return n;
}
isError() {
return T.isRaised(this.pointer) ? T.getErrorSeverity(this.pointer.value) >= er.Error : !1;
}
static getErrorSeverity(e) {
return _._api._MagickExceptionHelper_Severity(e);
}
static isRaised(e) {
return e.value !== 0;
}
static throw(e, n) {
const r = T.createError(e.value, n);
throw T.dispose(e), r;
}
static createError(e, n) {
const r = T.getMessage(e), l = new U(r, n), d = _._api._MagickExceptionHelper_RelatedCount(e);
if (d === 0)
return l;
const p = [];
for (let v = 0; v < d; v++) {
const S = _._api._MagickExceptionHelper_Related(e, v), R = T.getErrorSeverity(S), B = T.createError(S, R);
p.push(B);
}
return l._setRelatedErrors(p), l;
}
static getMessage(e) {
const n = _._api._MagickExceptionHelper_Message(e), r = _._api._MagickExceptionHelper_Description(e);
let l = ge(n, "Unknown error");
return r !== 0 && (l += `(${_._api.UTF8ToString(r)})`), l;
}
static dispose(e) {
_._api._MagickExceptionHelper_Dispose(e.value);
}
}
class or {
constructor(e, n, r, l, d, p, v) {
this.ascent = e, this.descent = n, this.maxHorizontalAdvance = r, this.textHeight = l, this.textWidth = d, this.underlinePosition = p, this.underlineThickness = v;
}
/**
* Gets the ascent, the distance in pixels from the text baseline to the highest/upper grid coordinate
* used to place an outline point.
*/
ascent;
/**
* Gets the descent, the distance in pixels from the baseline to the lowest grid coordinate used to
* place an outline point. Always a negative value.
*/
descent;
/**
* Gets the maximum horizontal advance in pixels.
*/
maxHorizontalAdvance;
/**
* Gets the text height in pixels.
*/
textHeight;
/**
* Gets the text width in pixels.
*/
textWidth;
/**
* Gets the underline position.
*/
underlinePosition;
/**
* Gets the underline thickness.
*/
underlineThickness;
/** @internal */
static _create(e) {
if (e == 0)
return null;
try {
const n = _._api._TypeMetric_Ascent_Get(e), r = _._api._TypeMetric_Descent_Get(e), l = _._api._TypeMetric_MaxHorizontalAdvance_Get(e), d = _._api._TypeMetric_TextHeight_Get(e), p = _._api._TypeMetric_TextWidth_Get(e), v = _._api._TypeMetric_UnderlinePosition_Get(e), S = _._api._TypeMetric_UnderlineThickness_Get(e);
return new or(n, r, l, d, p, v, S);
} finally {
_._api._TypeMetric_Dispose(e);
}
}
}
class Dt extends Ye {
constructor(e, n) {
const l = Et._create(n)._use((p) => _._api._DrawingWand_Create(e._instance, p._instance)), d = _._api._DrawingWand_Dispose;
super(l, d);
}
color(e, n, r) {
T.usePointer((l) => {
_._api._DrawingWand_Color(this._instance, e, n, r, l);
});
}
draw(e) {
e.forEach((n) => {
n.draw(this);
}), T.usePointer((n) => {
_._api._DrawingWand_Render(this._instance, n);
});
}
fillColor(e) {
T.usePointer((n) => {
e._use((r) => {
_._api._DrawingWand_FillColor(this._instance, r, n);
});
});
}
fillOpacity(e) {
T.usePointer((n) => {
_._api._DrawingWand_FillOpacity(this._instance, e, n);
});
}
font(e) {
T.usePointer((n) => {
A(e, (r) => {
_._api._DrawingWand_Font(this._instance, r, n);
});
});
}
fontPointSize(e) {
T.usePointer((n) => {
_._api._DrawingWand_FontPointSize(this._instance, e, n);
});
}
/** @internal */
fontTypeMetrics(e, n) {
return T.usePointer((r) => A(e, (l) => {
const d = _._api._DrawingWand_FontTypeMetrics(this._instance, l, n ? 1 : 0, r);
return or._create(d);
}));
}
gravity(e) {
T.usePointer((n) => {
_._api._DrawingWand_Gravity(this._instance, e, n);
});
}
line(e, n, r, l) {
T.usePointer((d) => {
_._api._DrawingWand_Line(this._instance, e, n, r, l, d);
});
}
point(e, n) {
T.usePointer((r) => {
_._api._DrawingWand_Point(this._instance, e, n, r);
});
}
rectangle(e, n, r, l) {
T.usePointer((d) => {
_._api._DrawingWand_Rectangle(this._instance, e, n, r, l, d);
});
}
roundRectangle(e, n, r, l, d, p) {
T.usePointer((v) => {
_._api._DrawingWand_RoundRectangle(this._instance, e, n, r, l, d, p, v);
});
}
strokeColor(e) {
T.usePointer((n) => {
e._use((r) => {
_._api._DrawingWand_StrokeColor(this._instance, r, n);
});
});
}
strokeWidth(e) {
T.usePointer((n) => {
_._api._DrawingWand_StrokeWidth(this._instance, e, n);
});
}
text(e, n, r) {
T.usePointer((l) => {
A(r, (d) => {
_._api._DrawingWand_Text(this._instance, e, n, d, l);
});
});
}
textAlignment(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextAlignment(this._instance, e, n);
});
}
textAntialias(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextAntialias(this._instance, e ? 1 : 0, n);
});
}
textDecoration(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextDecoration(this._instance, e, n);
});
}
textInterlineSpacing(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextInterlineSpacing(this._instance, e, n);
});
}
textInterwordspacing(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextInterwordSpacing(this._instance, e, n);
});
}
textKerning(e) {
T.usePointer((n) => {
_._api._DrawingWand_TextKerning(this._instance, e, n);
});
}
textUnderColor(e) {
T.usePointer((n) => {
e._use((r) => {
_._api._DrawingWand_TextUnderColor(this._instance, r, n);
});
});
}
/** @internal */
static _use(e, n) {
const r = new Dt(e, e.settings);
return ce._disposeAfterExecution(r, n);
}
}
class cr extends ni {
constructor() {
super(8, "double");
}
static use(e) {
const n = new cr();
try {
return e(n);
} finally {
_._api._free(n.ptr);
}
}
}
const he = {
/**
* Undefined.
*/
Undefined: 0,
/**
* Forget.
*/
Forget: 0,
/**
* Northwest
*/
Northwest: 1,
/**
* North
*/
North: 2,
/**
* Northeast
*/
Northeast: 3,
/**
* West
*/
West: 4,
/**
* Center
*/
Center: 5,
/**
* East
*/
East: 6,
/**
* Southwest
*/
Southwest: 7,
/**
* South
*/
South: 8,
/**
* Southeast
*/
Southeast: 9
};
function* oo(M) {