imagescript 3.20.3 → 4.0.0-rc.2
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/LICENSE +16 -12
- package/README.md +21 -12
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/animation-encoder.d.ts +1 -34
- package/dist/animation-encoder.js +35 -34
- package/dist/animation.d.ts +108 -122
- package/dist/animation.js +285 -121
- package/dist/codecs/av1/decode.js +1 -1
- package/dist/codecs/av1/encode.js +1 -1
- package/dist/codecs/gif.js +11 -9
- package/dist/codecs/hdr.d.ts +1 -1
- package/dist/codecs/jpeg.js +13 -13
- package/dist/codecs/jxl/headers.js +3 -3
- package/dist/codecs/jxl/patches-enc.js +1 -1
- package/dist/codecs/jxl.js +5 -5
- package/dist/codecs/netpbm.js +7 -7
- package/dist/codecs/png.js +15 -15
- package/dist/codecs/quantize.js +34 -8
- package/dist/codecs/tiff.js +1 -1
- package/dist/codecs/webp.js +3 -3
- package/dist/codecs/zlib.js +1 -1
- package/dist/colors.d.ts +8 -7
- package/dist/colors.js +23 -3
- package/dist/frame.d.ts +94 -100
- package/dist/frame.js +89 -65
- package/dist/gainmap.d.ts +88 -46
- package/dist/gainmap.js +75 -51
- package/dist/image-type.d.ts +6 -1
- package/dist/image-type.js +4 -1
- package/dist/image.d.ts +317 -738
- package/dist/image.js +308 -438
- package/dist/index.d.ts +19 -25
- package/dist/index.js +15 -14
- package/dist/metadata.d.ts +4 -3
- package/dist/metadata.js +9 -7
- package/dist/render/colr.js +1 -1
- package/dist/render/font.js +1 -1
- package/dist/render/layout.js +1 -1
- package/dist/render/segment.js +1 -1
- package/dist/render/shapers/hangul.js +1 -1
- package/dist/render/svg.js +68 -20
- package/dist/render/text.js +7 -9
- package/dist/text-layout.d.ts +5 -35
- package/dist/text-layout.js +11 -12
- package/dist/util/gain.js +12 -12
- package/dist/util/mem.d.ts +1 -1
- package/dist/util/optimize.js +3 -1
- package/dist/util/options.js +46 -7
- package/package.json +15 -10
- package/LICENSE.AGPL-3.0 +0 -619
- package/LICENSE.MIT +0 -19
- package/dist/gif.d.ts +0 -36
- package/dist/gif.js +0 -22
- package/dist/util/rotate.js +0 -43
- package/dist/version.js +0 -1
package/dist/image.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToneMapping } from './codecs/hdr.js';
|
|
2
2
|
import { BinaryData } from './util/mem.js';
|
|
3
|
-
import {
|
|
3
|
+
import { TextLayoutOptions } from './text-layout.js';
|
|
4
4
|
import { Metadata } from './metadata.js';
|
|
5
5
|
import { GainMap } from './gainmap.js';
|
|
6
6
|
/** A color as a 32-bit RGBA integer (`0xRRGGBBAA`) */
|
|
@@ -8,104 +8,72 @@ export type Color = number;
|
|
|
8
8
|
/** Called with a pixel's (0-based) coordinates, returns its color */
|
|
9
9
|
export type ColorFunction = (x: number, y: number) => Color;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The resampling filters of {@link Image.resize} and the other scaling functions (`image.resize({ width: 256, mode:
|
|
12
|
+
* 'bicubic' })`):
|
|
13
|
+
* - `'nearest-neighbor'`: each output pixel takes the nearest source pixel (hard pixels, for pixel art)
|
|
14
|
+
* - `'bilinear'` (the default): when shrinking, the filter widens with the scale factor, so every source pixel
|
|
15
|
+
* contributes
|
|
16
|
+
* - `'bicubic'`: Catmull-Rom, sharper than bilinear, especially when enlarging
|
|
17
|
+
* - `'area'`: area averaging (box filter), every output pixel is the average of the source pixels it covers. Meant for
|
|
18
|
+
* shrinking
|
|
14
19
|
*/
|
|
15
|
-
export type ResizeMode = 'nearest-neighbor' | 'bilinear' | 'bicubic' | 'area'
|
|
16
|
-
/**
|
|
17
|
-
* How {@link Image.renderSVG} scales, see {@link SVGScaleModes}. The numbers 1-3 (the values of the deprecated
|
|
18
|
-
* `Image.SVG_MODE_*`) still work, they are removed in 4.0
|
|
19
|
-
*/
|
|
20
|
-
export type SVGScaleMode = 'scale' | 'width' | 'height' | 1 | 2 | 3;
|
|
21
|
-
/**
|
|
22
|
-
* The resampling filters of {@link Image.resize} and the other scaling functions:
|
|
23
|
-
* `image.resize({ width: 256, mode: ResizeModes.BICUBIC })`
|
|
24
|
-
*/
|
|
25
|
-
export declare class ResizeModes {
|
|
26
|
-
/**
|
|
27
|
-
* Use {@link https://en.wikipedia.org/wiki/Image_scaling#Nearest-neighbor_interpolation Nearest-neighbor} resizing
|
|
28
|
-
*/
|
|
29
|
-
static readonly NEAREST_NEIGHBOR = "nearest-neighbor";
|
|
30
|
-
/**
|
|
31
|
-
* Bilinear resizing (the default). When shrinking, the filter widens with the scale factor, so every source pixel
|
|
32
|
-
* contributes
|
|
33
|
-
*/
|
|
34
|
-
static readonly BILINEAR = "bilinear";
|
|
35
|
-
/** Bicubic (Catmull-Rom) resizing, sharper than bilinear, especially when enlarging */
|
|
36
|
-
static readonly BICUBIC = "bicubic";
|
|
37
|
-
/**
|
|
38
|
-
* Area averaging (box filter): every output pixel is the average of the source pixels it covers. Meant for
|
|
39
|
-
* shrinking
|
|
40
|
-
*/
|
|
41
|
-
static readonly AREA = "area";
|
|
42
|
-
/**
|
|
43
|
-
* Not a filter: passed as the width or the height, that side follows from the other one, keeping the image's
|
|
44
|
-
* aspect ratio
|
|
45
|
-
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `AUTO` is removed in 4.0
|
|
46
|
-
* @group Deprecated
|
|
47
|
-
*/
|
|
48
|
-
static readonly AUTO = -1;
|
|
49
|
-
private constructor();
|
|
50
|
-
}
|
|
51
|
-
/** How {@link Image.renderSVG} scales the SVG to the given size */
|
|
52
|
-
export declare class SVGScaleModes {
|
|
53
|
-
/** The size is a factor of the SVG's own size */
|
|
54
|
-
static readonly SCALE = "scale";
|
|
55
|
-
/** The size is the width in pixels, the height follows the SVG's aspect ratio */
|
|
56
|
-
static readonly WIDTH = "width";
|
|
57
|
-
/** The size is the height in pixels, the width follows the SVG's aspect ratio */
|
|
58
|
-
static readonly HEIGHT = "height";
|
|
59
|
-
private constructor();
|
|
60
|
-
}
|
|
20
|
+
export type ResizeMode = 'nearest-neighbor' | 'bilinear' | 'bicubic' | 'area';
|
|
61
21
|
/** Blend modes of {@link Image.composite}, named like CSS' mix-blend-mode values */
|
|
62
22
|
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'add';
|
|
63
23
|
/** Options of {@link Image.composite} */
|
|
64
24
|
export interface CompositeOptions {
|
|
65
|
-
/** The x position to place the source at
|
|
25
|
+
/** The x position to place the source at. Default: `0` */
|
|
66
26
|
x?: number;
|
|
67
|
-
/** The y position to place the source at
|
|
27
|
+
/** The y position to place the source at. Default: `0` */
|
|
68
28
|
y?: number;
|
|
69
29
|
/** Opacity of the source (0..1). Default: `1` */
|
|
70
30
|
opacity?: number;
|
|
71
31
|
/** How the colors are mixed. Default: `'normal'` */
|
|
72
32
|
mode?: BlendMode;
|
|
73
33
|
}
|
|
34
|
+
/** How {@link Image.resize}, {@link Frame.resize} and {@link Animation.resize} fit an image into a box */
|
|
35
|
+
export type ResizeFit = 'fill' | 'inside' | 'contain' | 'cover';
|
|
74
36
|
/**
|
|
75
37
|
* The size for {@link Image.resize}, {@link Frame.resize} and {@link Animation.resize}, and how to resize: a side
|
|
76
38
|
* that is missing follows from the other one, keeping the aspect ratio
|
|
77
39
|
*/
|
|
78
|
-
export
|
|
40
|
+
export type ResizeToOptions = ResizeOptions & ({
|
|
79
41
|
/** The new width. Without it, it follows from the height */
|
|
80
42
|
width?: number;
|
|
81
43
|
/** The new height. Without it, it follows from the width */
|
|
82
44
|
height?: number;
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
/**
|
|
46
|
+
* `'fill'` stretches to the exact size; `'inside'` keeps the aspect ratio and makes the image as large as fits
|
|
47
|
+
* inside it, so one side can be smaller. Default: `'fill'`
|
|
48
|
+
*/
|
|
49
|
+
fit?: 'fill' | 'inside';
|
|
50
|
+
} | {
|
|
51
|
+
/** The exact width of the box */
|
|
52
|
+
width: number;
|
|
53
|
+
/** The exact height of the box */
|
|
54
|
+
height: number;
|
|
55
|
+
/** Keeps the aspect ratio and pads to the exact box */
|
|
56
|
+
fit: 'contain';
|
|
57
|
+
/** For `'contain'`, the color of the bars. Default: `0x00000000` (transparent) */
|
|
58
|
+
background?: Color;
|
|
59
|
+
} | {
|
|
60
|
+
/** The exact width of the box */
|
|
61
|
+
width: number;
|
|
62
|
+
/** The exact height of the box */
|
|
63
|
+
height: number;
|
|
64
|
+
/** Keeps the aspect ratio and crops to the exact box */
|
|
65
|
+
fit: 'cover';
|
|
66
|
+
});
|
|
67
|
+
/** Options of {@link Image.scale} and {@link Image.resize} */
|
|
85
68
|
export interface ResizeOptions {
|
|
86
|
-
/** The resizing mode. Default:
|
|
69
|
+
/** The resizing mode. Default: `'bilinear'` */
|
|
87
70
|
mode?: ResizeMode;
|
|
88
71
|
/**
|
|
89
|
-
* Whether to
|
|
90
|
-
*
|
|
91
|
-
* about 1%, never more than 1). Transparent images are premultiplied to 8 bits like browsers do, which makes them
|
|
92
|
-
* about twice as fast: what shows once they're composited differs by up to about 2 steps, pixels that are almost
|
|
93
|
-
* transparent keep less of their color. Only affects {@link ResizeModes.BILINEAR} and {@link ResizeModes.AREA},
|
|
94
|
-
* down to about a third of the size. Default: `true`
|
|
72
|
+
* Whether to use faster, lower-precision arithmetic. It can cause small color differences, especially around
|
|
73
|
+
* transparent edges. Only affects `'bilinear'` and `'area'` resizing. Default: `true`
|
|
95
74
|
*/
|
|
96
75
|
fast?: boolean;
|
|
97
76
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Options of {@link Image.opacity}, {@link Image.red}, {@link Image.green}, {@link Image.blue}, {@link Image.lightness}
|
|
100
|
-
* and {@link Image.saturation}
|
|
101
|
-
*/
|
|
102
|
-
export interface AdjustOptions {
|
|
103
|
-
/**
|
|
104
|
-
* Whether to set the value (true) or scale the current one (false). Default: `false`
|
|
105
|
-
* @deprecated Removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
106
|
-
*/
|
|
107
|
-
absolute?: boolean;
|
|
108
|
-
}
|
|
109
77
|
/** Options of {@link Image.sharpen} */
|
|
110
78
|
export interface SharpenOptions {
|
|
111
79
|
/** How strongly to sharpen (0 does nothing). Default: `1` */
|
|
@@ -113,36 +81,41 @@ export interface SharpenOptions {
|
|
|
113
81
|
/** The radius of the blur the image is compared with (larger values sharpen coarser details). Default: `1` */
|
|
114
82
|
radius?: number;
|
|
115
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* How to reduce visible banding when an image is limited to a smaller set of colors ({@link Image.quantize},
|
|
86
|
+
* {@link Image.encodeGIF}): `'none'` uses the nearest color; `'floyd-steinberg'` and `'atkinson'` spread small color
|
|
87
|
+
* errors to nearby pixels; `'ordered'` uses a repeating pattern. Atkinson tends to give a higher-contrast result.
|
|
88
|
+
*/
|
|
89
|
+
export type DitherMethod = 'none' | 'floyd-steinberg' | 'atkinson' | 'ordered';
|
|
116
90
|
/** Options of {@link Image.quantize}: either `colors` or `palette`, and the dithering */
|
|
117
91
|
export interface QuantizeOptions {
|
|
118
92
|
/**
|
|
119
|
-
* The number of colors to
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* quantity: give `palette` for exact colors. Default: `256`. Give `colors` or `palette`, not both
|
|
93
|
+
* The maximum number of colors to keep (2-256). Images with fewer distinct colors keep them exactly; otherwise
|
|
94
|
+
* ImageScript chooses a smaller set of representative colors. Give `palette` instead to choose exact colors.
|
|
95
|
+
* Default: `256`. Give `colors` or `palette`, not both
|
|
123
96
|
*/
|
|
124
97
|
colors?: number;
|
|
125
98
|
/**
|
|
126
|
-
* A fixed palette (1
|
|
127
|
-
* by its
|
|
99
|
+
* A fixed palette (1-256 colors, e.g. a Game Boy's four greens). Every pixel is changed to the nearest palette
|
|
100
|
+
* color by its red, green and blue values; transparency in palette colors is ignored. Give `palette` or `colors`,
|
|
101
|
+
* not both
|
|
128
102
|
*/
|
|
129
103
|
palette?: Color[];
|
|
130
104
|
/**
|
|
131
|
-
* How
|
|
132
|
-
*
|
|
133
|
-
* 5/16 and 1/16), `'atkinson'` (the error goes to six neighbours, 1/8 each: lighter, more contrast), `'ordered'` (a
|
|
134
|
-
* regular 4x4 pattern of thresholds, no error spreading). Rows alternate direction for the error diffusions.
|
|
135
|
-
* Default: `'none'`
|
|
105
|
+
* How to spread small color changes across nearby pixels to make gradients look smoother with few colors, see
|
|
106
|
+
* {@link DitherMethod}. Default: `'floyd-steinberg'`, like {@link GIFEncodeOptions.dither}
|
|
136
107
|
*/
|
|
137
|
-
dither?:
|
|
108
|
+
dither?: DitherMethod;
|
|
138
109
|
/**
|
|
139
|
-
* How strongly to
|
|
140
|
-
*
|
|
110
|
+
* How strongly to apply dithering: `0` disables it; `1` applies it fully. Default: `0.85`, like
|
|
111
|
+
* {@link GIFEncodeOptions.ditherStrength}
|
|
141
112
|
*/
|
|
142
113
|
ditherStrength?: number;
|
|
143
114
|
}
|
|
144
|
-
/** How {@link Image.transform}
|
|
115
|
+
/** How {@link Image.transform} and {@link Image.rotate} sample the pixels between the source's */
|
|
145
116
|
export type TransformMode = 'nearest-neighbor' | 'bilinear' | 'bicubic';
|
|
117
|
+
/** The six values `[a, b, c, d, e, f]` of an affine transform */
|
|
118
|
+
export type AffineTransform = readonly [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
146
119
|
/** Options of {@link Image.transform} */
|
|
147
120
|
export interface TransformOptions {
|
|
148
121
|
/**
|
|
@@ -158,8 +131,8 @@ export interface TransformOptions {
|
|
|
158
131
|
};
|
|
159
132
|
/**
|
|
160
133
|
* Whether to make the image as large as the transformed one, which then fills it (a rotated image grows to fit its
|
|
161
|
-
* corners, a skewed one gets wider). Without it, the image keeps its size and the parts outside are lost.
|
|
162
|
-
*
|
|
134
|
+
* corners, a skewed one gets wider). Without it, the image keeps its size and the parts outside are lost.
|
|
135
|
+
* Default: `true`
|
|
163
136
|
*/
|
|
164
137
|
expand?: boolean;
|
|
165
138
|
/**
|
|
@@ -201,9 +174,8 @@ export interface OutlineOptions {
|
|
|
201
174
|
/** The colors of a gradient, see {@link Image.linearGradient} */
|
|
202
175
|
export interface GradientOptions {
|
|
203
176
|
/**
|
|
204
|
-
* The colors along the gradient: their positions (0..1) and colors
|
|
205
|
-
*
|
|
206
|
-
* (`[0xff0000ff, 0x00ff00ff]`)
|
|
177
|
+
* The colors along the gradient: their positions (0..1) and colors (`{ 0: 0xff0000ff, 0.5: 0xffff00ff, 1: 0x00ff00ff }`),
|
|
178
|
+
* or just the colors, evenly spaced (`[0xff0000ff, 0x00ff00ff]`), like {@link Colors.gradient} takes them
|
|
207
179
|
*/
|
|
208
180
|
stops: Record<number, Color> | Color[];
|
|
209
181
|
}
|
|
@@ -225,73 +197,90 @@ export interface RadialGradientOptions extends GradientOptions {
|
|
|
225
197
|
/** The radius of the last stop in pixels. Default: the distance to the farthest corner */
|
|
226
198
|
radius?: number;
|
|
227
199
|
}
|
|
228
|
-
/**
|
|
229
|
-
export interface
|
|
230
|
-
/** The compression level (0-9), higher is smaller but slower. Default: `4` */
|
|
231
|
-
compression?: number;
|
|
200
|
+
/** The options every encoder that writes metadata has */
|
|
201
|
+
export interface EncodeOptions {
|
|
232
202
|
/** Metadata to include, see {@link Metadata} */
|
|
233
203
|
metadata?: Metadata;
|
|
234
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* How the encoders that can carry a gain map (JPEG, AVIF, JPEG XL) write {@link Image.gainMap}, see their `gainMap`
|
|
207
|
+
* option
|
|
208
|
+
*/
|
|
209
|
+
export interface GainMapEmbedOptions {
|
|
210
|
+
/**
|
|
211
|
+
* The map's quality (1-100, like the format's `quality`; for JPEG XL 100 is lossless). Default: `90`
|
|
212
|
+
*/
|
|
213
|
+
quality?: number;
|
|
214
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
215
|
+
scale?: number;
|
|
216
|
+
}
|
|
217
|
+
/** Options of {@link Image.encodePNG} */
|
|
218
|
+
export interface PNGEncodeOptions extends EncodeOptions {
|
|
219
|
+
/** The compression level (0-9), higher is smaller but slower. Default: `4` */
|
|
220
|
+
compression?: number;
|
|
221
|
+
}
|
|
222
|
+
/** Options of {@link Image.encodeTGA} */
|
|
223
|
+
export type TGAEncodeOptions = EncodeOptions;
|
|
224
|
+
/** Options of {@link Image.encodeGIF}, and of {@link Animation.encodeGIF} with {@link GIFAnimationEncodeOptions} */
|
|
225
|
+
export interface GIFEncodeOptions extends EncodeOptions {
|
|
226
|
+
/**
|
|
227
|
+
* The maximum colors in each frame's palette (2-256, including transparency). Frames with fewer colors keep them
|
|
228
|
+
* exactly; otherwise ImageScript chooses representative colors. Default: `256`
|
|
229
|
+
*/
|
|
230
|
+
colors?: number;
|
|
231
|
+
/** How the rounding error is spread when the colors don't fit the palette, see {@link DitherMethod}. Default: `'floyd-steinberg'` */
|
|
232
|
+
dither?: DitherMethod;
|
|
233
|
+
/** How strongly to dither, from `0` (like `'none'`) to `1` (the full error). Default: `0.85` */
|
|
234
|
+
ditherStrength?: number;
|
|
235
|
+
}
|
|
235
236
|
/** Options of {@link Image.encodeJPEG} */
|
|
236
|
-
export interface JPEGEncodeOptions {
|
|
237
|
-
/** The JPEG quality (1-100)
|
|
237
|
+
export interface JPEGEncodeOptions extends EncodeOptions {
|
|
238
|
+
/** The JPEG quality (1-100). Default: `90` */
|
|
238
239
|
quality?: number;
|
|
239
|
-
/**
|
|
240
|
-
|
|
240
|
+
/**
|
|
241
|
+
* How much color detail to keep: `'4:4:4'` keeps it all; `'4:2:0'` stores less color detail to make a smaller
|
|
242
|
+
* file (often hard to notice in photos, but more visible around colored edges). Default: `'4:2:0'` up to quality
|
|
243
|
+
* 90, `'4:4:4'` above
|
|
244
|
+
*/
|
|
245
|
+
subsampling?: '4:4:4' | '4:2:0';
|
|
246
|
+
/**
|
|
247
|
+
* The background color to combine with transparent pixels, since JPEG doesn't support transparency. Opaque images
|
|
248
|
+
* are encoded as they are. Default: `0x000000ff` (black)
|
|
249
|
+
*/
|
|
250
|
+
background?: Color;
|
|
241
251
|
/**
|
|
242
252
|
* Whether to write the image's {@link Image.gainMap} (an Ultra HDR JPEG, brighter on HDR displays), or how.
|
|
243
253
|
* Default: `true` (written if there is one)
|
|
244
254
|
*/
|
|
245
|
-
gainMap?: boolean |
|
|
246
|
-
/** The map's JPEG quality (1-100). Default: `90` */
|
|
247
|
-
quality?: number;
|
|
248
|
-
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
249
|
-
scale?: number;
|
|
250
|
-
};
|
|
255
|
+
gainMap?: boolean | GainMapEmbedOptions;
|
|
251
256
|
}
|
|
252
257
|
/** Options of {@link Image.encodeWebP} */
|
|
253
|
-
export interface WebPEncodeOptions {
|
|
258
|
+
export interface WebPEncodeOptions extends EncodeOptions {
|
|
254
259
|
/**
|
|
255
|
-
* Lossy compression (0-100
|
|
256
|
-
*
|
|
260
|
+
* Lossy compression (0-100): higher values usually preserve more detail but make larger files. Without it the image
|
|
261
|
+
* is encoded losslessly, keeping every pixel exact
|
|
257
262
|
*/
|
|
258
263
|
quality?: number;
|
|
259
264
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
* quantized values; the default `2` takes about a quarter of the time of 4 (cwebp's default) for files about 5%
|
|
263
|
-
* larger. Lossless: 0 is a fast mode (photos in about a fifth of the time, graphics in about a third, files about
|
|
264
|
-
* 6-8% larger), 1 takes about two thirds of the time for files up to 2% larger, 2 and up compress the most.
|
|
265
|
-
* Default: `2`
|
|
265
|
+
* Compression effort (0-6): higher values usually take longer but may make smaller files. For lossless images,
|
|
266
|
+
* `0` prioritizes speed; `2` and above spend more time reducing file size. Default: `2`
|
|
266
267
|
*/
|
|
267
268
|
effort?: number;
|
|
268
269
|
/**
|
|
269
|
-
* For lossy compression:
|
|
270
|
-
*
|
|
271
|
-
* bleeding. It takes about twice the time at the default effort; photos get about as large, images with many
|
|
272
|
-
* hard color edges a lot larger (1200x800 red and blue squares: 2.7 times). Default: `false`
|
|
270
|
+
* For lossy compression: improve color detail around sharp edges (for example, red text on a blue background).
|
|
271
|
+
* This can take longer and make graphics larger. Default: `false`
|
|
273
272
|
*/
|
|
274
273
|
sharpYuv?: boolean;
|
|
275
274
|
/**
|
|
276
|
-
* For lossy compression, the alpha
|
|
277
|
-
*
|
|
278
|
-
* Default: `100`
|
|
275
|
+
* For lossy compression, the transparency (alpha) channel's quality (0-100). Lower values may make the image
|
|
276
|
+
* smaller but can make transparency look less smooth. Default: `100` (full quality)
|
|
279
277
|
*/
|
|
280
278
|
alphaQuality?: number;
|
|
281
279
|
/**
|
|
282
|
-
* For lossless compression,
|
|
283
|
-
*
|
|
284
|
-
* memory (browsers without cross-origin isolation), encode without them. Default: the processors available, at
|
|
285
|
-
* most 8
|
|
280
|
+
* For lossless compression, the maximum worker threads to use. Small images or runtimes that cannot share memory
|
|
281
|
+
* between workers use one thread. Default: the available processors, up to 8
|
|
286
282
|
*/
|
|
287
283
|
threads?: number;
|
|
288
|
-
/** Metadata to include, see {@link Metadata} */
|
|
289
|
-
metadata?: Metadata;
|
|
290
|
-
}
|
|
291
|
-
/** Options of {@link Image.encodeTGA} */
|
|
292
|
-
export interface EncodeOptions {
|
|
293
|
-
/** Metadata to include, see {@link Metadata} */
|
|
294
|
-
metadata?: Metadata;
|
|
295
284
|
}
|
|
296
285
|
/** Options of {@link Image.roundCorners} */
|
|
297
286
|
export interface RoundCornersOptions {
|
|
@@ -304,162 +293,177 @@ export interface FisheyeOptions {
|
|
|
304
293
|
strength?: number;
|
|
305
294
|
}
|
|
306
295
|
/** Options of {@link Image.renderSVG} */
|
|
307
|
-
export interface
|
|
308
|
-
/**
|
|
309
|
-
|
|
296
|
+
export interface RenderSVGOptions {
|
|
297
|
+
/**
|
|
298
|
+
* The width in pixels, the height follows the SVG's aspect ratio. Give one of `width`, `height` and `scale`.
|
|
299
|
+
* Default: the SVG's own width
|
|
300
|
+
*/
|
|
301
|
+
width?: number;
|
|
302
|
+
/** The height in pixels, the width follows the SVG's aspect ratio. Give one of `width`, `height` and `scale` */
|
|
303
|
+
height?: number;
|
|
304
|
+
/**
|
|
305
|
+
* A factor of the SVG's own size (`2` renders it twice as large). Give one of `width`, `height` and `scale`.
|
|
306
|
+
* Default: `1`
|
|
307
|
+
*/
|
|
308
|
+
scale?: number;
|
|
309
|
+
/**
|
|
310
|
+
* Maximum total pixels in the rendered output. Output over the limit throws a RangeError before anything is
|
|
311
|
+
* rendered. It's also the default of {@link RenderSVGOptions.maxLayerPixels} and
|
|
312
|
+
* {@link RenderSVGOptions.maxImagePixels}. Default: `268402689` (16383²); `Infinity` disables the limit
|
|
313
|
+
*/
|
|
314
|
+
maxPixels?: number;
|
|
310
315
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
316
|
+
* Maximum pixels of the layers rendering uses at once, the output's included. Groups with opacity, masks, clip
|
|
317
|
+
* paths of nested viewports, filters and blend modes are each rendered into a layer of their own (up to the
|
|
318
|
+
* output's size, 16 bytes per pixel) while their content is drawn, so deeply nested ones multiply the memory a
|
|
319
|
+
* small SVG takes. Exceeding it throws a RangeError. With the defaults, rendering can take about 90 bytes per pixel
|
|
320
|
+
* of `maxPixels` (64 for the layers, up to 20 for the images, 4 for the output): lower `maxPixels` to bound it for
|
|
321
|
+
* untrusted SVGs. Default: `4 * maxPixels`; `Infinity` disables the limit
|
|
313
322
|
*/
|
|
314
|
-
|
|
323
|
+
maxLayerPixels?: number;
|
|
315
324
|
/**
|
|
316
|
-
*
|
|
325
|
+
* Maximum total pixels of the raster images the SVG references (data URIs and {@link RenderSVGOptions.images}),
|
|
326
|
+
* decoded together; already-decoded {@link Image} values are used as supplied and don't count. Drawing an image
|
|
327
|
+
* beyond the limit throws a RangeError. Default: `maxPixels`; `Infinity` disables the limit
|
|
328
|
+
*/
|
|
329
|
+
maxImagePixels?: number;
|
|
330
|
+
/**
|
|
331
|
+
* Fonts for `<text>` (TrueType, OpenType or WOFF; not WOFF2 or some newer OpenType outline formats such as CFF2):
|
|
332
|
+
* each text gets the face its `font-family`, `font-weight`, `font-style`
|
|
317
333
|
* and `font-stretch` match best among them, by the names, weights and styles in the fonts (like browsers match
|
|
318
334
|
* installed fonts). Generic families (`serif`, `sans-serif`, `monospace`, ...) are the first font that fits them,
|
|
319
335
|
* other families and text without one get the first font's family; characters a face doesn't have come from the
|
|
320
336
|
* other fonts (TrueType, OpenType or WOFF). Fonts the SVG embeds with `@font-face` (in data: URIs) are used too,
|
|
321
|
-
* before these for their family names. Without any fonts text isn't rendered.
|
|
337
|
+
* before these for their family names. Without any fonts text isn't rendered. One font can be given without an
|
|
338
|
+
* array. Default: `[]`
|
|
322
339
|
*/
|
|
323
|
-
fonts?: BinaryData[];
|
|
340
|
+
fonts?: BinaryData | BinaryData[];
|
|
324
341
|
/**
|
|
325
342
|
* Images for the `<image>` elements (and `feImage`) by their `href`, the same string the SVG uses: with
|
|
326
343
|
* `images: { 'logo.png': bytes }`, `<image href="logo.png" .../>` draws the image. Values are encoded images (PNG,
|
|
327
344
|
* JPEG, WebP, GIF's first frame, ...) or {@link Image}s, decoded like data URI images are, and only for the hrefs
|
|
328
|
-
* the SVG references. Nothing else is read: no files and no URLs, so an href
|
|
329
|
-
*
|
|
345
|
+
* the SVG references. Nothing else is read: no files and no URLs, so drawing an image whose href isn't given (and
|
|
346
|
+
* isn't a data URI) throws, as does drawing one that can't be decoded. SVG documents can't be given this way, use a
|
|
347
|
+
* data URI for them. Default: `{}`
|
|
330
348
|
*/
|
|
331
349
|
images?: Record<string, BinaryData | Image>;
|
|
332
350
|
}
|
|
333
|
-
/**
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
layout?: TextLayout;
|
|
339
|
-
}
|
|
340
|
-
/** Options of {@link Image.renderText}: the font and size, the text color and layout, and its style (see {@link TextStyle}) */
|
|
341
|
-
export interface RenderTextOptions extends TextStyle {
|
|
351
|
+
/**
|
|
352
|
+
* Options of {@link Image.renderText}: the font and size, the text color, the layout (wrapping, cutting off and alignment,
|
|
353
|
+
* see {@link TextLayoutOptions}) and the style (see {@link TextStyleOptions})
|
|
354
|
+
*/
|
|
355
|
+
export interface RenderTextOptions extends TextStyleOptions, TextLayoutOptions {
|
|
342
356
|
/**
|
|
343
|
-
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use
|
|
357
|
+
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use (not WOFF2 or some newer OpenType outline formats
|
|
358
|
+
* such as CFF2), or several by priority: every character comes
|
|
344
359
|
* from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height. Color glyphs (COLR
|
|
345
|
-
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors.
|
|
346
|
-
*
|
|
360
|
+
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Shaping includes bidirectional
|
|
361
|
+
* layout, Arabic joining, and script-specific OpenType shapers for Indic scripts, Hebrew, Thai/Lao, Hangul, Khmer,
|
|
362
|
+
* Myanmar and other Universal Shaping Engine scripts; other scripts use default OpenType shaping.
|
|
347
363
|
*/
|
|
348
364
|
font: BinaryData | BinaryData[];
|
|
349
365
|
/** Font size in pixels (per em) */
|
|
350
366
|
size: number;
|
|
351
367
|
/** The text color. Default: `0xffffffff` */
|
|
352
368
|
color?: Color;
|
|
353
|
-
/**
|
|
354
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Maximum total pixels of the rendered image (the outline included): larger text throws a RangeError before its
|
|
371
|
+
* pixels are allocated. Default: `268402689` (16383²); `Infinity` disables the limit
|
|
372
|
+
*/
|
|
373
|
+
maxPixels?: number;
|
|
355
374
|
}
|
|
356
|
-
/** Options of {@link Image.decode} */
|
|
375
|
+
/** Options of {@link Image.decode}, {@link Animation.decode} and {@link decode} */
|
|
357
376
|
export interface DecodeOptions {
|
|
358
|
-
/**
|
|
377
|
+
/**
|
|
378
|
+
* Whether to rotate or mirror the image according to its saved orientation information, so photos taken with a
|
|
379
|
+
* rotated camera display upright. This applies to every animation frame too. Default: `true`
|
|
380
|
+
*/
|
|
359
381
|
applyOrientation?: boolean;
|
|
360
382
|
/**
|
|
361
|
-
* Whether to
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
383
|
+
* Whether to use the image's embedded color profile (color information describing its pixels) to convert its
|
|
384
|
+
* colors to sRGB, the standard used by most screens and browsers. Common RGB and gray profiles described by a
|
|
385
|
+
* color matrix and tone curves are converted, as are AVIFs using other color ranges (such as Display P3 or BT.2020).
|
|
386
|
+
* Colors outside sRGB are clipped. Profiles that rely on lookup tables, CMYK profiles and profiles already in
|
|
387
|
+
* sRGB are left unchanged. Default: `true`
|
|
366
388
|
*/
|
|
367
389
|
applyColorProfile?: boolean;
|
|
368
390
|
/**
|
|
369
|
-
* The
|
|
370
|
-
*
|
|
371
|
-
*
|
|
391
|
+
* The maximum total pixels to decode. An image declaring more pixels throws a RangeError before its pixel buffer
|
|
392
|
+
* is allocated, helping prevent a small or untrusted file from requesting an enormous amount of memory.
|
|
393
|
+
* {@link Animation.decode} counts all frames together because each frame uses a full canvas. The decoded image
|
|
394
|
+
* takes 4 bytes per pixel (about 1 GiB at the default), and decoding needs more while it runs: for 8-bit images,
|
|
395
|
+
* about 4-7 bytes per pixel for PNG, JPEG, WebP, GIF and the simpler formats, about 14 for AVIF and about 30 for
|
|
396
|
+
* JPEG XL (more with high bit depths). Lower it to bound the memory of servers decoding untrusted files. Default:
|
|
397
|
+
* `268402689` (16383²); `Infinity` disables the limit
|
|
372
398
|
*/
|
|
373
399
|
maxPixels?: number;
|
|
374
400
|
/**
|
|
375
|
-
* How
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* brighter than white. Default: `'reinhard'`
|
|
401
|
+
* How high-dynamic-range images (which can be brighter than a standard screen's white) become 8-bit sRGB.
|
|
402
|
+
* `'reinhard'` gently compresses bright highlights so the brightest pixel becomes white; images that are not HDR
|
|
403
|
+
* stay unchanged. `'clamp'` clips anything brighter than white. Default: `'reinhard'`
|
|
379
404
|
*/
|
|
380
405
|
toneMapping?: ToneMapping;
|
|
381
406
|
/**
|
|
382
|
-
* Whether to read
|
|
383
|
-
*
|
|
407
|
+
* Whether to read extra HDR brightness data (a gain map) from supported JPEG, AVIF and JPEG XL images into
|
|
408
|
+
* {@link Image.gainMap}. For animations, this also reads maps from supported JPEG XL frames. Default: `true`
|
|
384
409
|
*/
|
|
385
410
|
gainMap?: boolean;
|
|
386
411
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* one
|
|
390
|
-
* workers can't share memory)
|
|
412
|
+
* Maximum worker threads for formats and image sizes that can be decoded in parallel. Small images may use one
|
|
413
|
+
* thread because starting workers can take longer than decoding them. Default: the available processors, up to 8
|
|
414
|
+
* (one in runtimes that cannot share memory between workers)
|
|
391
415
|
*/
|
|
392
416
|
threads?: number;
|
|
393
417
|
}
|
|
394
418
|
/** Options of {@link Image.encodeJXL} */
|
|
395
|
-
export interface JXLEncodeOptions {
|
|
419
|
+
export interface JXLEncodeOptions extends EncodeOptions {
|
|
396
420
|
/**
|
|
397
|
-
* Lossy compression (0-100
|
|
398
|
-
* Without
|
|
421
|
+
* Lossy compression (0-100): higher values usually preserve more detail but make larger files; `100` is
|
|
422
|
+
* lossless. Without this option, the image is encoded losslessly
|
|
399
423
|
*/
|
|
400
424
|
quality?: number;
|
|
401
425
|
/**
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* repeat (the glyphs of screenshots) once, as patches like `cjxl -e 7`. Lossless: 0 is `cjxl -e 1`'s fast mode
|
|
405
|
-
* (byte for byte), 1 and 2 like `cjxl -e 3` (about 15% smaller for photos, 13% for graphics; a few times slower).
|
|
406
|
-
* Default: `1`
|
|
426
|
+
* Compression effort (0-2): higher values usually take longer but may make smaller files. `0` prioritizes speed;
|
|
427
|
+
* `2` spends the most time compressing. Default: `1`
|
|
407
428
|
*/
|
|
408
429
|
effort?: number;
|
|
409
430
|
/**
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
* (lossy under about 1.5 megapixels at effort 0, 512x512 pixels at 1, 384x384 at 2; lossless under 724x724 and
|
|
413
|
-
* always at effort 0), and runtimes whose workers can't share memory (browsers without cross-origin isolation)
|
|
414
|
-
* encode without them.
|
|
415
|
-
* Default: the processors available, at most 8
|
|
431
|
+
* Maximum worker threads for compression. Small images or runtimes that cannot share memory between workers use
|
|
432
|
+
* one thread. Default: the available processors, up to 8
|
|
416
433
|
*/
|
|
417
434
|
threads?: number;
|
|
418
|
-
/** Metadata to include, see {@link Metadata} */
|
|
419
|
-
metadata?: Metadata;
|
|
420
435
|
/**
|
|
421
|
-
* Whether to write the image's {@link Image.gainMap}
|
|
422
|
-
* Default: `true` (written if there is one)
|
|
436
|
+
* Whether to write the image's {@link Image.gainMap}, the extra data used to show brighter highlights on HDR
|
|
437
|
+
* displays. Default: `true` (written if there is one)
|
|
423
438
|
*/
|
|
424
|
-
gainMap?: boolean |
|
|
425
|
-
/** The map's quality (1-100 like `quality`, 100 lossless). Default: `90` */
|
|
426
|
-
quality?: number;
|
|
427
|
-
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
428
|
-
scale?: number;
|
|
429
|
-
};
|
|
439
|
+
gainMap?: boolean | GainMapEmbedOptions;
|
|
430
440
|
}
|
|
431
441
|
/** Options of {@link Image.encodeAVIF} */
|
|
432
|
-
export interface AVIFEncodeOptions {
|
|
442
|
+
export interface AVIFEncodeOptions extends EncodeOptions {
|
|
433
443
|
/** 0-100, like avifenc's: higher is better and larger, 100 is lossless. Default: `60` */
|
|
434
444
|
quality?: number;
|
|
435
|
-
/** The quality of the
|
|
445
|
+
/** The quality of the transparency channel, if the image has transparency. Default: `100` (lossless) */
|
|
436
446
|
alphaQuality?: number;
|
|
437
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* How much color detail to keep: `'4:4:4'` keeps it all; `'4:2:0'` stores less color detail to make a smaller
|
|
449
|
+
* file. Default: `'4:4:4'`
|
|
450
|
+
*/
|
|
438
451
|
subsampling?: '4:4:4' | '4:2:0';
|
|
439
452
|
/** How hard the encoder searches for the best modes: 0-2, faster to smaller. Default: `1` */
|
|
440
453
|
effort?: number;
|
|
441
454
|
/**
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
* at 2), and runtimes whose workers can't share memory (browsers without cross-origin isolation), encode without
|
|
445
|
-
* them. Default: the processors available, at most 8
|
|
455
|
+
* Maximum worker threads for compression. Small images or runtimes that cannot share memory between workers use
|
|
456
|
+
* one thread. Default: the available processors, up to 8
|
|
446
457
|
*/
|
|
447
458
|
threads?: number;
|
|
448
|
-
/** Metadata to include, see {@link Metadata} */
|
|
449
|
-
metadata?: Metadata;
|
|
450
459
|
/**
|
|
451
|
-
* Whether to write the image's {@link Image.gainMap}
|
|
452
|
-
*
|
|
460
|
+
* Whether to write the image's {@link Image.gainMap}, the extra data used to show brighter highlights on HDR
|
|
461
|
+
* displays. Default: `true` (written if there is one)
|
|
453
462
|
*/
|
|
454
|
-
gainMap?: boolean |
|
|
455
|
-
/** The map's quality (1-100). Default: `90` */
|
|
456
|
-
quality?: number;
|
|
457
|
-
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
458
|
-
scale?: number;
|
|
459
|
-
};
|
|
463
|
+
gainMap?: boolean | GainMapEmbedOptions;
|
|
460
464
|
}
|
|
461
465
|
/** Text style options of {@link Image.renderText} */
|
|
462
|
-
export interface
|
|
466
|
+
export interface TextStyleOptions {
|
|
463
467
|
/** Width of an outline around the glyphs in pixels. Default: `0` */
|
|
464
468
|
strokeWidth?: number;
|
|
465
469
|
/** Color of the outline. Default: `0x000000ff` */
|
|
@@ -494,11 +498,6 @@ export interface CropCircleOptions {
|
|
|
494
498
|
* transparent on the shorter side). Default: `'contain'`
|
|
495
499
|
*/
|
|
496
500
|
size?: 'contain' | 'cover';
|
|
497
|
-
/**
|
|
498
|
-
* Whether to use the larger dimension for the size. Default: `false`
|
|
499
|
-
* @deprecated Use `size: 'cover'` (`true`) or `size: 'contain'` (`false`), `max` will be removed in 4.0
|
|
500
|
-
*/
|
|
501
|
-
max?: boolean;
|
|
502
501
|
/** Share of the radius (0..1) over which the edge fades out. Default: `0` */
|
|
503
502
|
feathering?: number;
|
|
504
503
|
}
|
|
@@ -513,15 +512,17 @@ export interface DominantColorOptions {
|
|
|
513
512
|
}
|
|
514
513
|
/** Options of {@link Image.rotate} */
|
|
515
514
|
export interface RotateOptions {
|
|
516
|
-
/** Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true` */
|
|
517
|
-
resize?: boolean;
|
|
518
515
|
/**
|
|
519
|
-
* Whether to
|
|
520
|
-
*
|
|
521
|
-
* faded edges) within about 2.5 steps (pixels that are almost transparent keep less of their color). Only affects
|
|
522
|
-
* angles that aren't multiples of 90°. Default: `true`
|
|
516
|
+
* Whether to make the image larger so the rotated corners aren't cut off. Without it, the image keeps its size and
|
|
517
|
+
* the parts outside are lost. Default: `true`
|
|
523
518
|
*/
|
|
524
|
-
|
|
519
|
+
expand?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* How the pixels between the source's are sampled for angles that aren't multiples of 90° (those move whole
|
|
522
|
+
* pixels): `'nearest-neighbor'` (hard pixels, for pixel art), `'bilinear'` (smooth) or `'bicubic'` (sharper, can
|
|
523
|
+
* overshoot a little at hard edges), like {@link TransformOptions.mode}. Default: `'bilinear'`
|
|
524
|
+
*/
|
|
525
|
+
mode?: TransformMode;
|
|
525
526
|
}
|
|
526
527
|
/** Options of {@link Image.trim} */
|
|
527
528
|
export interface TrimOptions {
|
|
@@ -545,12 +546,6 @@ export interface ColorToAlphaOptions {
|
|
|
545
546
|
/** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
|
|
546
547
|
opacityThreshold?: number;
|
|
547
548
|
}
|
|
548
|
-
/**
|
|
549
|
-
* Text metadata written into PNGs
|
|
550
|
-
* @deprecated Use {@link Metadata}, which all encoders take
|
|
551
|
-
* @group Deprecated
|
|
552
|
-
*/
|
|
553
|
-
export type PNGMetadata = Metadata;
|
|
554
549
|
/**
|
|
555
550
|
* An RGBA image; provides the codecs and the manipulation functions. Methods that change the image modify it in place
|
|
556
551
|
* and return it, so calls can be chained
|
|
@@ -563,8 +558,9 @@ export declare class Image {
|
|
|
563
558
|
*/
|
|
564
559
|
constructor(width: number, height: number);
|
|
565
560
|
/**
|
|
566
|
-
*
|
|
567
|
-
*
|
|
561
|
+
* Extra image data that lets high-dynamic-range (HDR) screens show brighter highlights. Standard screens show the
|
|
562
|
+
* image without the extra brightness. {@link Image.encodeJPEG}, {@link Image.encodeAVIF} and
|
|
563
|
+
* {@link Image.encodeJXL} can write it. `null` means there is no gain map
|
|
568
564
|
*/
|
|
569
565
|
get gainMap(): GainMap | null;
|
|
570
566
|
/**
|
|
@@ -573,30 +569,30 @@ export declare class Image {
|
|
|
573
569
|
*/
|
|
574
570
|
set gainMap(gainMap: GainMap | null);
|
|
575
571
|
/**
|
|
576
|
-
* The image's RGBA pixel data
|
|
577
|
-
* (it is used as is, without
|
|
572
|
+
* The image's RGBA pixel data (red, green, blue and transparency, four bytes per pixel). It can be replaced by any
|
|
573
|
+
* 8-bit array with width * height * 4 bytes starting at a byte offset divisible by 4 (it is used as is, without
|
|
574
|
+
* copying). Direct changes to this array or {@link Image.setPixelAt} don't update the image's gain map.
|
|
578
575
|
*/
|
|
579
576
|
get bitmap(): Uint8ClampedArray;
|
|
580
577
|
/**
|
|
581
578
|
* Replaces the pixel data
|
|
582
|
-
* @param bitmap The new RGBA data, width * height * 4 bytes (used as is, without copying
|
|
579
|
+
* @param bitmap The new RGBA data, width * height * 4 bytes (used as is, without copying, so its byte offset has to be
|
|
580
|
+
* divisible by 4: the image reads it as 32-bit pixels too)
|
|
583
581
|
*/
|
|
584
582
|
set bitmap(bitmap: Uint8ClampedArray | Uint8Array);
|
|
585
583
|
/** A short description for debugging, e.g. `Image<64x64>` */
|
|
586
584
|
toString(): string;
|
|
587
585
|
/**
|
|
588
|
-
* The
|
|
586
|
+
* The image's width
|
|
589
587
|
*/
|
|
590
588
|
get width(): number;
|
|
591
589
|
/**
|
|
592
|
-
* The
|
|
590
|
+
* The image's height
|
|
593
591
|
*/
|
|
594
592
|
get height(): number;
|
|
595
593
|
/**
|
|
596
594
|
* Yields an [x, y] array for every pixel in the image (0-based), row by row
|
|
597
595
|
* @yields The coordinates of the pixel ([x, y])
|
|
598
|
-
* @deprecated Use {@link Image.pixels}, which yields `[x, y, color]`: `coordinates()` will be removed in 4.0
|
|
599
|
-
* @group Deprecated
|
|
600
596
|
*/
|
|
601
597
|
coordinates(): Generator<[x: number, y: number], void, undefined>;
|
|
602
598
|
/**
|
|
@@ -604,82 +600,6 @@ export declare class Image {
|
|
|
604
600
|
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
605
601
|
*/
|
|
606
602
|
pixels(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
607
|
-
/**
|
|
608
|
-
* Yields an [x, y] array for every pixel in the image (0-based)
|
|
609
|
-
* @yields The coordinates of the pixel ([x, y])
|
|
610
|
-
* @deprecated Use {@link Image.pixels}, which yields `[x, y, color]`: iterating over the image will be removed in 4.0
|
|
611
|
-
* @group Deprecated
|
|
612
|
-
*/
|
|
613
|
-
[Symbol.iterator](): Generator<[x: number, y: number], void, undefined>;
|
|
614
|
-
/**
|
|
615
|
-
* Yields an [x, y, color] array for every pixel in the image (0-based)
|
|
616
|
-
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
617
|
-
* @deprecated Use {@link Image.pixels}, `iterateWithColors()` will be removed in 4.0
|
|
618
|
-
* @group Deprecated
|
|
619
|
-
*/
|
|
620
|
-
iterateWithColors(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
621
|
-
/**
|
|
622
|
-
* Converts RGBA components to an RGBA value, values are rounded and clamped to 0..255
|
|
623
|
-
* @param r red (0..255)
|
|
624
|
-
* @param g green (0..255)
|
|
625
|
-
* @param b blue (0..255)
|
|
626
|
-
* @param a alpha (0..255)
|
|
627
|
-
* @deprecated Use {@link Colors.fromRGBA}, `Image.rgbaToColor` will be removed in 4.0
|
|
628
|
-
* @group Deprecated
|
|
629
|
-
*/
|
|
630
|
-
static rgbaToColor(r: number, g: number, b: number, a: number): Color;
|
|
631
|
-
/**
|
|
632
|
-
* Converts RGB components to an RGBA value (assuming alpha = 255)
|
|
633
|
-
* @param r red (0..255)
|
|
634
|
-
* @param g green (0..255)
|
|
635
|
-
* @param b blue (0..255)
|
|
636
|
-
* @deprecated Use {@link Colors.fromRGB}, `Image.rgbToColor` will be removed in 4.0
|
|
637
|
-
* @group Deprecated
|
|
638
|
-
*/
|
|
639
|
-
static rgbToColor(r: number, g: number, b: number): Color;
|
|
640
|
-
/**
|
|
641
|
-
* Converts HSLA colors to RGBA colors
|
|
642
|
-
* @param h hue (0..1)
|
|
643
|
-
* @param s saturation (0..1)
|
|
644
|
-
* @param l lightness (0..1)
|
|
645
|
-
* @param a opacity (0..1)
|
|
646
|
-
* @deprecated Use {@link Colors.fromHSLA}, `Image.hslaToColor` will be removed in 4.0
|
|
647
|
-
* @group Deprecated
|
|
648
|
-
*/
|
|
649
|
-
static hslaToColor(h: number, s: number, l: number, a: number): Color;
|
|
650
|
-
/**
|
|
651
|
-
* Converts HSL colors to RGBA colors (assuming an opacity of 255)
|
|
652
|
-
* @param h hue (0..1)
|
|
653
|
-
* @param s saturation (0..1)
|
|
654
|
-
* @param l lightness (0..1)
|
|
655
|
-
* @deprecated Use {@link Colors.fromHSL}, `Image.hslToColor` will be removed in 4.0
|
|
656
|
-
* @group Deprecated
|
|
657
|
-
*/
|
|
658
|
-
static hslToColor(h: number, s: number, l: number): Color;
|
|
659
|
-
/**
|
|
660
|
-
* Converts an RGBA value to an array of HSLA values
|
|
661
|
-
* @param r red (0..255)
|
|
662
|
-
* @param g green (0..255)
|
|
663
|
-
* @param b blue (0..255)
|
|
664
|
-
* @param a alpha (0..255)
|
|
665
|
-
* @deprecated Use {@link Colors.toHSLA}, `Image.rgbaToHSLA` will be removed in 4.0
|
|
666
|
-
* @group Deprecated
|
|
667
|
-
*/
|
|
668
|
-
static rgbaToHSLA(r: number, g: number, b: number, a: number): [h: number, s: number, l: number, a: number];
|
|
669
|
-
/**
|
|
670
|
-
* Converts a color value to an array of RGBA values
|
|
671
|
-
* @param color The color value to convert
|
|
672
|
-
* @deprecated Use {@link Colors.toRGBA}, `Image.colorToRGBA` will be removed in 4.0
|
|
673
|
-
* @group Deprecated
|
|
674
|
-
*/
|
|
675
|
-
static colorToRGBA(color: Color): [r: number, g: number, b: number, a: number];
|
|
676
|
-
/**
|
|
677
|
-
* Converts a color value to an array of RGB values (ignoring the colors alpha)
|
|
678
|
-
* @param color The color value to convert
|
|
679
|
-
* @deprecated Use {@link Colors.toRGB}, `Image.colorToRGB` will be removed in 4.0
|
|
680
|
-
* @group Deprecated
|
|
681
|
-
*/
|
|
682
|
-
static colorToRGB(color: Color): [r: number, g: number, b: number];
|
|
683
603
|
/**
|
|
684
604
|
* Creates an image with a linear gradient, like CSS' `linear-gradient()`
|
|
685
605
|
* @param width The image's width
|
|
@@ -697,81 +617,35 @@ export declare class Image {
|
|
|
697
617
|
*/
|
|
698
618
|
static radialGradient(width: number, height: number, options: RadialGradientOptions): Image;
|
|
699
619
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
702
|
-
* @deprecated Use {@link Colors.gradient}, `Image.gradient` will be removed in 4.0
|
|
703
|
-
* @group Deprecated
|
|
704
|
-
*/
|
|
705
|
-
static gradient(colors: Record<number, Color>): (position: number) => Color;
|
|
706
|
-
/**
|
|
707
|
-
* Gets the pixel color at the specified position (0-based)
|
|
620
|
+
* Gets the pixel color at the specified position (0-based). {@link Colors.toRGBA} splits it into its channels
|
|
708
621
|
* @param x The x coordinate
|
|
709
622
|
* @param y The y coordinate
|
|
710
623
|
* @returns The color value (`0xRRGGBBAA`)
|
|
711
624
|
*/
|
|
712
625
|
getPixelAt(x: number, y: number): Color;
|
|
713
|
-
/**
|
|
714
|
-
* Gets a view of the RGBA components of the pixel at the specified position (0-based)
|
|
715
|
-
* @param x The x coordinate
|
|
716
|
-
* @param y The y coordinate
|
|
717
|
-
* @returns The pixel's 4 bytes in {@link Image.bitmap}: writing to them changes the pixel
|
|
718
|
-
*/
|
|
719
|
-
getRGBAAt(x: number, y: number): Uint8ClampedArray;
|
|
720
626
|
/**
|
|
721
627
|
* Sets the pixel color for the specified position (0-based)
|
|
722
628
|
* @param x The x coordinate
|
|
723
629
|
* @param y The y coordinate
|
|
724
|
-
* @param
|
|
630
|
+
* @param color The new color (`0xRRGGBBAA`)
|
|
725
631
|
*/
|
|
726
|
-
setPixelAt(x: number, y: number,
|
|
632
|
+
setPixelAt(x: number, y: number, color: Color): this;
|
|
727
633
|
/**
|
|
728
634
|
* Fills the image data with the supplied color
|
|
729
|
-
* @param color The color, or a function returning the color of each pixel
|
|
635
|
+
* @param color The color, or a function returning the color of each pixel (checked like any color: a result that
|
|
636
|
+
* isn't one throws a RangeError)
|
|
730
637
|
*/
|
|
731
638
|
fill(color: Color | ColorFunction): this;
|
|
732
639
|
/**
|
|
733
640
|
* Clones the current image
|
|
734
641
|
*/
|
|
735
642
|
clone(): Image;
|
|
736
|
-
/**
|
|
737
|
-
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
738
|
-
* @group Deprecated
|
|
739
|
-
*/
|
|
740
|
-
static readonly RESIZE_NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
741
|
-
/**
|
|
742
|
-
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
743
|
-
* @group Deprecated
|
|
744
|
-
*/
|
|
745
|
-
static readonly RESIZE_BILINEAR = "RESIZE_BILINEAR";
|
|
746
|
-
/**
|
|
747
|
-
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
748
|
-
* @group Deprecated
|
|
749
|
-
*/
|
|
750
|
-
static readonly RESIZE_BICUBIC = "RESIZE_BICUBIC";
|
|
751
|
-
/**
|
|
752
|
-
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
753
|
-
* @group Deprecated
|
|
754
|
-
*/
|
|
755
|
-
static readonly RESIZE_AREA = "RESIZE_AREA";
|
|
756
|
-
/**
|
|
757
|
-
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `Image.RESIZE_*` will
|
|
758
|
-
* be removed in 4.0
|
|
759
|
-
* @group Deprecated
|
|
760
|
-
*/
|
|
761
|
-
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
762
643
|
/**
|
|
763
644
|
* Resizes the image by the given factor
|
|
764
645
|
* @param factor The factor to resize the image with
|
|
765
646
|
* @param options See {@link ResizeOptions}
|
|
766
647
|
*/
|
|
767
648
|
scale(factor: number, options?: ResizeOptions): this;
|
|
768
|
-
/**
|
|
769
|
-
* Resizes the image by the given factor
|
|
770
|
-
* @param factor The factor to resize the image with
|
|
771
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
772
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
773
|
-
*/
|
|
774
|
-
scale(factor: number, mode?: ResizeMode): this;
|
|
775
649
|
/**
|
|
776
650
|
* Resizes the image to the given dimensions.
|
|
777
651
|
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
@@ -781,90 +655,23 @@ export declare class Image {
|
|
|
781
655
|
* @returns The resized image
|
|
782
656
|
*/
|
|
783
657
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
784
|
-
/**
|
|
785
|
-
* Resizes the image to the given dimensions.
|
|
786
|
-
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
787
|
-
* @param width The new width
|
|
788
|
-
* @param height The new height
|
|
789
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
790
|
-
* @returns The resized image
|
|
791
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
792
|
-
*/
|
|
793
|
-
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
794
658
|
/**
|
|
795
659
|
* Resizes the image: to the given width or height (the other side keeps the aspect ratio), or to both
|
|
796
660
|
* @param options The size and how to resize, see {@link ResizeToOptions}
|
|
797
661
|
* @returns The resized image
|
|
798
662
|
*/
|
|
799
663
|
resize(options: ResizeToOptions): this;
|
|
800
|
-
/**
|
|
801
|
-
* Resizes the image so it is contained in the given bounding box.
|
|
802
|
-
* Can return an image with one axis smaller than the given bounding box.
|
|
803
|
-
* @param width The width of the bounding box
|
|
804
|
-
* @param height The height of the bounding box
|
|
805
|
-
* @param options See {@link ResizeOptions}
|
|
806
|
-
* @returns The resized image
|
|
807
|
-
*/
|
|
808
|
-
contain(width: number, height: number, options?: ResizeOptions): this;
|
|
809
|
-
/**
|
|
810
|
-
* Resizes the image so it is contained in the given bounding box.
|
|
811
|
-
* Can return an image with one axis smaller than the given bounding box.
|
|
812
|
-
* @param width The width of the bounding box
|
|
813
|
-
* @param height The height of the bounding box
|
|
814
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
815
|
-
* @returns The resized image
|
|
816
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
817
|
-
*/
|
|
818
|
-
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
819
|
-
/**
|
|
820
|
-
* Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
|
|
821
|
-
* Always returns the exact dimensions of the bounding box.
|
|
822
|
-
* @param width The width of the bounding box
|
|
823
|
-
* @param height The height of the bounding box
|
|
824
|
-
* @param options See {@link ResizeOptions}
|
|
825
|
-
* @returns The resized image
|
|
826
|
-
*/
|
|
827
|
-
fit(width: number, height: number, options?: ResizeOptions): this;
|
|
828
|
-
/**
|
|
829
|
-
* Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
|
|
830
|
-
* Always returns the exact dimensions of the bounding box.
|
|
831
|
-
* @param width The width of the bounding box
|
|
832
|
-
* @param height The height of the bounding box
|
|
833
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
834
|
-
* @returns The resized image
|
|
835
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
836
|
-
*/
|
|
837
|
-
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
838
|
-
/**
|
|
839
|
-
* Resizes the image so it covers the given bounding box, cropping the overflowing edges.
|
|
840
|
-
* Always returns the exact dimensions of the bounding box.
|
|
841
|
-
* @param width The width of the bounding box
|
|
842
|
-
* @param height The height of the bounding box
|
|
843
|
-
* @param options See {@link ResizeOptions}
|
|
844
|
-
* @returns The resized image
|
|
845
|
-
*/
|
|
846
|
-
cover(width: number, height: number, options?: ResizeOptions): this;
|
|
847
|
-
/**
|
|
848
|
-
* Resizes the image so it covers the given bounding box, cropping the overflowing edges.
|
|
849
|
-
* Always returns the exact dimensions of the bounding box.
|
|
850
|
-
* @param width The width of the bounding box
|
|
851
|
-
* @param height The height of the bounding box
|
|
852
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
853
|
-
* @returns The resized image
|
|
854
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
855
|
-
*/
|
|
856
|
-
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
857
664
|
/**
|
|
858
665
|
* Crops an image to the specified dimensions.
|
|
859
666
|
* The region is clipped to the image, so the result can be smaller than the requested size
|
|
860
667
|
* @param x The x offset (0-based)
|
|
861
668
|
* @param y The y offset (0-based)
|
|
862
|
-
* @param width The new
|
|
863
|
-
* @param height The new
|
|
669
|
+
* @param width The new width
|
|
670
|
+
* @param height The new height
|
|
864
671
|
*/
|
|
865
672
|
crop(x: number, y: number, width: number, height: number): this;
|
|
866
673
|
/**
|
|
867
|
-
* Copies a region of the image into a new image
|
|
674
|
+
* Copies a region of the image into a new image and leaves the image unchanged (like {@link Image.crop} on a clone,
|
|
868
675
|
* without copying the whole image). The region is clipped to the image, so the result can be smaller than the
|
|
869
676
|
* requested size
|
|
870
677
|
* @param x The x offset (0-based)
|
|
@@ -872,54 +679,18 @@ export declare class Image {
|
|
|
872
679
|
* @param width The region's width
|
|
873
680
|
* @param height The region's height
|
|
874
681
|
*/
|
|
875
|
-
|
|
682
|
+
extract(x: number, y: number, width: number, height: number): Image;
|
|
876
683
|
/**
|
|
877
684
|
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
878
|
-
*
|
|
879
|
-
* unchanged
|
|
685
|
+
* An image that only has the color stays unchanged ({@link Frame.trim} also moves the frame's offsets)
|
|
880
686
|
* @param options See {@link TrimOptions}
|
|
881
687
|
*/
|
|
882
688
|
trim(options?: TrimOptions): this;
|
|
883
|
-
/**
|
|
884
|
-
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
885
|
-
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
886
|
-
* unchanged
|
|
887
|
-
* @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
|
|
888
|
-
* same color whatever their RGB values
|
|
889
|
-
* @param options See {@link TrimOptions}
|
|
890
|
-
* @deprecated Pass {@link TrimOptions} instead, the positional arguments will be removed in 4.0
|
|
891
|
-
*/
|
|
892
|
-
trim(color?: Color, options?: TrimOptions): this;
|
|
893
|
-
/**
|
|
894
|
-
* Draws a box at the specified coordinates (0-based), clipped to the image
|
|
895
|
-
* @param x The x offset
|
|
896
|
-
* @param y The y offset
|
|
897
|
-
* @param width The box width
|
|
898
|
-
* @param height The box height
|
|
899
|
-
* @param color The color to fill the box in with, a function gets coordinates relative to the box
|
|
900
|
-
*/
|
|
901
|
-
drawBox(x: number, y: number, width: number, height: number, color: Color | ColorFunction): this;
|
|
902
|
-
/**
|
|
903
|
-
* Draws an antialiased circle around the center of the specified pixel (0-based)
|
|
904
|
-
* @param x The center x position
|
|
905
|
-
* @param y The center y position
|
|
906
|
-
* @param radius The circles radius in pixels
|
|
907
|
-
* @param color The color, a function gets coordinates relative to the circle's bounding box
|
|
908
|
-
*/
|
|
909
|
-
drawCircle(x: number, y: number, radius: number, color: Color | ColorFunction): this;
|
|
910
689
|
/**
|
|
911
690
|
* Crops the image into a circle with an antialiased edge
|
|
912
691
|
* @param options See {@link CropCircleOptions}
|
|
913
692
|
*/
|
|
914
693
|
cropCircle(options?: CropCircleOptions): this;
|
|
915
|
-
/**
|
|
916
|
-
* Crops the image into a circle with an antialiased edge
|
|
917
|
-
* @param max Whether to use the larger dimension for the size. Default: `false`
|
|
918
|
-
* @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
|
|
919
|
-
* @deprecated Pass {@link CropCircleOptions} instead, `cropCircle({ size: 'cover' })`. The arguments will be
|
|
920
|
-
* removed in 4.0
|
|
921
|
-
*/
|
|
922
|
-
cropCircle(max?: boolean, feathering?: number): this;
|
|
923
694
|
/**
|
|
924
695
|
* Sets the RGB of every pixel to the given color, keeping each pixel's own alpha. Turns an image into a silhouette
|
|
925
696
|
* or tints it: `image.recolor(0xffffffff)` makes every pixel white, keeping its transparency
|
|
@@ -936,81 +707,33 @@ export declare class Image {
|
|
|
936
707
|
/**
|
|
937
708
|
* Scales the opacity of the image
|
|
938
709
|
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
939
|
-
* @param options See {@link AdjustOptions}
|
|
940
|
-
*/
|
|
941
|
-
opacity(opacity: number, options?: AdjustOptions): this;
|
|
942
|
-
/**
|
|
943
|
-
* Scales the opacity of the image
|
|
944
|
-
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
945
|
-
* @param absolute Whether to set the opacity (true) instead of scaling it (false)
|
|
946
|
-
* @deprecated Use {@link Image.opacity} to scale; for a fixed alpha, `absolute` is removed in 4.0
|
|
947
710
|
*/
|
|
948
|
-
opacity(opacity: number
|
|
711
|
+
opacity(opacity: number): this;
|
|
949
712
|
/**
|
|
950
713
|
* Scales the red channel
|
|
951
714
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
952
|
-
* @param options See {@link AdjustOptions}
|
|
953
715
|
*/
|
|
954
|
-
red(factor: number
|
|
955
|
-
/**
|
|
956
|
-
* Scales the red channel
|
|
957
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
958
|
-
* @param absolute Whether to set every pixel's red channel to `factor` * 255 (true) instead of scaling it (false)
|
|
959
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
960
|
-
*/
|
|
961
|
-
red(factor: number, absolute?: boolean): this;
|
|
962
|
-
/**
|
|
963
|
-
* Scales the green channel
|
|
964
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
965
|
-
* @param options See {@link AdjustOptions}
|
|
966
|
-
*/
|
|
967
|
-
green(factor: number, options?: AdjustOptions): this;
|
|
716
|
+
red(factor: number): this;
|
|
968
717
|
/**
|
|
969
718
|
* Scales the green channel
|
|
970
719
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
971
|
-
* @param absolute Whether to set every pixel's green channel to `factor` * 255 (true) instead of scaling it (false)
|
|
972
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
973
720
|
*/
|
|
974
|
-
green(factor: number
|
|
721
|
+
green(factor: number): this;
|
|
975
722
|
/**
|
|
976
723
|
* Scales the blue channel
|
|
977
724
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
978
|
-
* @param options See {@link AdjustOptions}
|
|
979
725
|
*/
|
|
980
|
-
blue(factor: number
|
|
981
|
-
/**
|
|
982
|
-
* Scales the blue channel
|
|
983
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
984
|
-
* @param absolute Whether to set every pixel's blue channel to `factor` * 255 (true) instead of scaling it (false)
|
|
985
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
986
|
-
*/
|
|
987
|
-
blue(factor: number, absolute?: boolean): this;
|
|
726
|
+
blue(factor: number): this;
|
|
988
727
|
/**
|
|
989
728
|
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
990
|
-
* @param
|
|
991
|
-
* @param options See {@link AdjustOptions}
|
|
992
|
-
*/
|
|
993
|
-
lightness(value: number, options?: AdjustOptions): this;
|
|
994
|
-
/**
|
|
995
|
-
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
996
|
-
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
997
|
-
* @param absolute Whether to set the lightness (true) instead of scaling it (false)
|
|
998
|
-
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
999
|
-
*/
|
|
1000
|
-
lightness(value: number, absolute?: boolean): this;
|
|
1001
|
-
/**
|
|
1002
|
-
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
1003
|
-
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
1004
|
-
* @param options See {@link AdjustOptions}
|
|
729
|
+
* @param factor The factor to multiply the lightness with (>= 0, results are clamped)
|
|
1005
730
|
*/
|
|
1006
|
-
|
|
731
|
+
lightness(factor: number): this;
|
|
1007
732
|
/**
|
|
1008
|
-
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it
|
|
1009
|
-
* @param
|
|
1010
|
-
* @param absolute Whether to set the saturation (true) instead of scaling it (false)
|
|
1011
|
-
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
733
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it grayscale
|
|
734
|
+
* @param factor The factor to multiply the saturation with (>= 0, results are clamped)
|
|
1012
735
|
*/
|
|
1013
|
-
saturation(
|
|
736
|
+
saturation(factor: number): this;
|
|
1014
737
|
/**
|
|
1015
738
|
* Composites (overlays) the source onto this image
|
|
1016
739
|
* @param source The image to place
|
|
@@ -1018,29 +741,20 @@ export declare class Image {
|
|
|
1018
741
|
*/
|
|
1019
742
|
composite(source: Image, options?: CompositeOptions): this;
|
|
1020
743
|
/**
|
|
1021
|
-
*
|
|
1022
|
-
* @param source The image to place
|
|
1023
|
-
* @param [x=0] The x position to place the image at
|
|
1024
|
-
* @param [y=0] The y position to place the image at
|
|
1025
|
-
* @param options Opacity and blend mode, see {@link CompositeOptions}
|
|
1026
|
-
* @deprecated Pass {@link CompositeOptions} instead, the positional arguments will be removed in 4.0
|
|
1027
|
-
*/
|
|
1028
|
-
composite(source: Image, x?: number, y?: number, options?: CompositeOptions): this;
|
|
1029
|
-
/**
|
|
1030
|
-
* Inverts the images colors
|
|
744
|
+
* Inverts the image's colors
|
|
1031
745
|
*/
|
|
1032
746
|
invert(): this;
|
|
1033
747
|
/**
|
|
1034
|
-
* Inverts the
|
|
748
|
+
* Inverts the image's lightness (HSL), keeping hue and saturation: dark colors become light and vice versa
|
|
1035
749
|
*/
|
|
1036
750
|
invertLightness(): this;
|
|
1037
751
|
/**
|
|
1038
|
-
* Inverts the
|
|
752
|
+
* Inverts the image's value (HSV), keeping hue and saturation: the brightest channel `v` becomes `255 - v`
|
|
1039
753
|
* and the others scale along, black becomes white
|
|
1040
754
|
*/
|
|
1041
755
|
invertValue(): this;
|
|
1042
756
|
/**
|
|
1043
|
-
* Shifts the
|
|
757
|
+
* Shifts the image's hue
|
|
1044
758
|
* @param degrees How many degrees to shift the hue by
|
|
1045
759
|
*/
|
|
1046
760
|
hueShift(degrees: number): this;
|
|
@@ -1055,13 +769,13 @@ export declare class Image {
|
|
|
1055
769
|
* 0x8bac0fff, 0x9bbc0fff] })` for a Game Boy look. Transparent pixels (alpha 0) keep their color and don't count
|
|
1056
770
|
* towards the palette; the other pixels keep their alpha and only their RGB is reduced. The result is deterministic.
|
|
1057
771
|
* With a gain map (an HDR image), the HDR highlights are dropped, like {@link Image.invert} does: the map is neutral
|
|
1058
|
-
* afterwards
|
|
772
|
+
* afterwards
|
|
1059
773
|
* @param options See {@link QuantizeOptions}
|
|
1060
774
|
*/
|
|
1061
775
|
quantize(options?: QuantizeOptions): this;
|
|
1062
776
|
/**
|
|
1063
777
|
* Mixes the colors of every pixel with a color matrix, like SVG's `feColorMatrix`: the new red, green, blue and alpha
|
|
1064
|
-
* are each a sum of the old red, green, blue and alpha times a factor, plus an offset.
|
|
778
|
+
* are each a sum of the old red, green, blue and alpha times a factor, plus an offset. Grayscale, sepia, tints,
|
|
1065
779
|
* swapped channels, color blindness simulation or a mix of those in one pass.
|
|
1066
780
|
*
|
|
1067
781
|
* The values are 20 numbers, four rows of `[red, green, blue, alpha, offset]` for the new red, green, blue and alpha,
|
|
@@ -1090,19 +804,17 @@ export declare class Image {
|
|
|
1090
804
|
* @param matrix The six values [a, b, c, d, e, f]
|
|
1091
805
|
* @param options See {@link TransformOptions}
|
|
1092
806
|
*/
|
|
1093
|
-
transform(matrix:
|
|
807
|
+
transform(matrix: AffineTransform, options?: TransformOptions): this;
|
|
1094
808
|
/**
|
|
1095
809
|
* Adds a shadow behind the image, shaped by its alpha: a drop shadow with an offset, or a glow without one
|
|
1096
810
|
* (`image.dropShadow({ blur: 8, color: 0xff2fb9ff })`, with `spread` to make it stronger). The image grows to fit
|
|
1097
|
-
* the shadow, unless `expand` is `false
|
|
1098
|
-
* grow up and left as far as their offset allows
|
|
811
|
+
* the shadow, unless `expand` is `false`
|
|
1099
812
|
* @param options See {@link ShadowOptions}
|
|
1100
813
|
*/
|
|
1101
814
|
dropShadow(options?: ShadowOptions): this;
|
|
1102
815
|
/**
|
|
1103
816
|
* Draws an outline around the image's shape (its alpha): the sticker effect for cut-out images, or an outline for
|
|
1104
|
-
* text. The image grows to fit it, unless `expand` is `false
|
|
1105
|
-
* the growth), they only grow up and left as far as their offset allows
|
|
817
|
+
* text. The image grows to fit it, unless `expand` is `false`
|
|
1106
818
|
* @param options See {@link OutlineOptions}
|
|
1107
819
|
*/
|
|
1108
820
|
outline(options?: OutlineOptions): this;
|
|
@@ -1111,21 +823,14 @@ export declare class Image {
|
|
|
1111
823
|
* @param options See {@link SharpenOptions}
|
|
1112
824
|
*/
|
|
1113
825
|
sharpen(options?: SharpenOptions): this;
|
|
1114
|
-
/**
|
|
1115
|
-
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
1116
|
-
* @param [amount=1] How strongly to sharpen (0 does nothing)
|
|
1117
|
-
* @param [radius=1] The radius of the blur the image is compared with (larger values sharpen coarser details)
|
|
1118
|
-
* @deprecated Pass {@link SharpenOptions} instead, the positional arguments will be removed in 4.0
|
|
1119
|
-
*/
|
|
1120
|
-
sharpen(amount?: number, radius?: number): this;
|
|
1121
826
|
/**
|
|
1122
827
|
* Multiplies the color channels, e.g. 1.2 makes the image 20% brighter
|
|
1123
828
|
* @param factor The factor (>= 0, 1 keeps the image)
|
|
1124
829
|
*/
|
|
1125
830
|
brightness(factor: number): this;
|
|
1126
831
|
/**
|
|
1127
|
-
* Scales the color channels' distance from mid
|
|
1128
|
-
* @param factor The factor (>= 0, 1 keeps the image, 0 makes it
|
|
832
|
+
* Scales the color channels' distance from mid gray, e.g. 1.5 increases the contrast, 0.5 reduces it
|
|
833
|
+
* @param factor The factor (>= 0, 1 keeps the image, 0 makes it gray)
|
|
1129
834
|
*/
|
|
1130
835
|
contrast(factor: number): this;
|
|
1131
836
|
/**
|
|
@@ -1134,9 +839,9 @@ export declare class Image {
|
|
|
1134
839
|
*/
|
|
1135
840
|
gamma(gamma: number): this;
|
|
1136
841
|
/**
|
|
1137
|
-
* Converts the image to
|
|
842
|
+
* Converts the image to grayscale by its luma (ITU-R 601, like Pillow), keeping the alpha
|
|
1138
843
|
*/
|
|
1139
|
-
|
|
844
|
+
grayscale(): this;
|
|
1140
845
|
/**
|
|
1141
846
|
* Applies a sepia tone
|
|
1142
847
|
*/
|
|
@@ -1150,17 +855,6 @@ export declare class Image {
|
|
|
1150
855
|
* @param options See {@link ColorToAlphaOptions}
|
|
1151
856
|
*/
|
|
1152
857
|
colorToAlpha(options?: ColorToAlphaOptions): this;
|
|
1153
|
-
/**
|
|
1154
|
-
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
1155
|
-
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
1156
|
-
* semi-transparent instead of keeping a fringe of it.
|
|
1157
|
-
* The color is removed everywhere in the image, not only from a connected background: removing a white
|
|
1158
|
-
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
1159
|
-
* @param color The color to remove, by default the color of the top left pixel (e.g. a background)
|
|
1160
|
-
* @param options See {@link ColorToAlphaOptions}
|
|
1161
|
-
* @deprecated Pass {@link ColorToAlphaOptions} instead, the positional arguments will be removed in 4.0
|
|
1162
|
-
*/
|
|
1163
|
-
colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
|
|
1164
858
|
/**
|
|
1165
859
|
* Gets the average color of the image, weighting each pixel by its opacity
|
|
1166
860
|
* @returns The average color (fully opaque), black for fully transparent images
|
|
@@ -1175,158 +869,94 @@ export declare class Image {
|
|
|
1175
869
|
*/
|
|
1176
870
|
dominantColor(options?: DominantColorOptions): Color;
|
|
1177
871
|
/**
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
* @
|
|
1181
|
-
* @param
|
|
1182
|
-
* @return The image's dominant color (fully opaque)
|
|
1183
|
-
* @deprecated Pass {@link DominantColorOptions} instead, the positional arguments will be removed in 4.0
|
|
1184
|
-
*/
|
|
1185
|
-
dominantColor(ignoreBlack?: boolean, ignoreWhite?: boolean, bwThreshold?: number): Color;
|
|
1186
|
-
/**
|
|
1187
|
-
* Rotates the image counterclockwise by the given amount of degrees
|
|
1188
|
-
* @param angle The angle to rotate the image for (in degrees)
|
|
872
|
+
* Rotates the image clockwise by the given angle in degrees (like CSS' `rotate()`; negative angles turn it
|
|
873
|
+
* counterclockwise). Multiples of 90° move whole pixels; other angles resample the image (see
|
|
874
|
+
* {@link RotateOptions.mode}) and, by default, grow it so the corners fit
|
|
875
|
+
* @param angle The angle in degrees, clockwise
|
|
1189
876
|
* @param options See {@link RotateOptions}
|
|
1190
877
|
*/
|
|
1191
878
|
rotate(angle: number, options?: RotateOptions): this;
|
|
1192
|
-
/**
|
|
1193
|
-
* Rotates the image counterclockwise by the given amount of degrees
|
|
1194
|
-
* @param angle The angle to rotate the image for (in degrees)
|
|
1195
|
-
* @param resize Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true`
|
|
1196
|
-
* @deprecated Pass {@link RotateOptions} instead, the positional arguments will be removed in 4.0
|
|
1197
|
-
*/
|
|
1198
|
-
rotate(angle: number, resize?: boolean): this;
|
|
1199
879
|
/**
|
|
1200
880
|
* Flips / mirrors the image horizontally or vertically
|
|
1201
881
|
* @param direction The direction to flip
|
|
1202
882
|
*/
|
|
1203
883
|
flip(direction: 'horizontal' | 'vertical'): this;
|
|
1204
884
|
/**
|
|
1205
|
-
* Rounds the
|
|
885
|
+
* Rounds the image's corners, with antialiased edges
|
|
1206
886
|
* @param options See {@link RoundCornersOptions}
|
|
1207
887
|
*/
|
|
1208
888
|
roundCorners(options?: RoundCornersOptions): this;
|
|
1209
|
-
/**
|
|
1210
|
-
* Rounds the images corners, with antialiased edges
|
|
1211
|
-
* @param [radius=min(width,height)/4] The radius of the corners
|
|
1212
|
-
* @deprecated Pass {@link RoundCornersOptions} instead, the positional arguments will be removed in 4.0
|
|
1213
|
-
*/
|
|
1214
|
-
roundCorners(radius?: number): this;
|
|
1215
889
|
/**
|
|
1216
890
|
* Applies a fisheye (barrel distortion) effect
|
|
1217
891
|
* @param options See {@link FisheyeOptions}
|
|
1218
892
|
*/
|
|
1219
893
|
fisheye(options?: FisheyeOptions): this;
|
|
1220
|
-
/**
|
|
1221
|
-
* Applies a fisheye (barrel distortion) effect
|
|
1222
|
-
* @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
|
|
1223
|
-
* @deprecated Pass {@link FisheyeOptions} instead, the positional arguments will be removed in 4.0
|
|
1224
|
-
*/
|
|
1225
|
-
fisheye(strength?: number): this;
|
|
1226
894
|
/**
|
|
1227
895
|
* Encodes the image into a PNG, with the smallest lossless color type (a palette for up to 256 colors,
|
|
1228
|
-
*
|
|
1229
|
-
* @param options See {@link PNGEncodeOptions}
|
|
1230
|
-
* @return The encoded data
|
|
1231
|
-
*/
|
|
1232
|
-
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
1233
|
-
/**
|
|
1234
|
-
* Encodes the image into a PNG
|
|
1235
|
-
* @param compression The compression level (0-9). Default: `4`
|
|
1236
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1237
|
-
* @return The encoded data
|
|
1238
|
-
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1239
|
-
*/
|
|
1240
|
-
encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
1241
|
-
/**
|
|
1242
|
-
* Encodes the image into a PNG with compression level 4
|
|
1243
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1244
|
-
* @return The encoded data
|
|
1245
|
-
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1246
|
-
*/
|
|
1247
|
-
encodePNG(metadata?: Metadata): Promise<Uint8Array>;
|
|
1248
|
-
/**
|
|
1249
|
-
* Encodes the image into a PNG
|
|
896
|
+
* grayscale or RGB, alpha only if needed). Uses the runtime's native zlib when available
|
|
1250
897
|
* @param options See {@link PNGEncodeOptions}
|
|
1251
898
|
* @return The encoded data
|
|
1252
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1253
|
-
* @group Deprecated
|
|
1254
899
|
*/
|
|
1255
|
-
|
|
900
|
+
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1256
901
|
/**
|
|
1257
|
-
* Encodes the image into a
|
|
1258
|
-
*
|
|
1259
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1260
|
-
* @return The encoded data
|
|
1261
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1262
|
-
* @group Deprecated
|
|
1263
|
-
*/
|
|
1264
|
-
encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
1265
|
-
/**
|
|
1266
|
-
* Encodes the image into a PNG with compression level 4
|
|
1267
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1268
|
-
* @return The encoded data
|
|
1269
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1270
|
-
* @group Deprecated
|
|
1271
|
-
*/
|
|
1272
|
-
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
1273
|
-
/**
|
|
1274
|
-
* Encodes the image into a JPEG
|
|
902
|
+
* Encodes the image into a JPEG. JPEG has no transparency: an image with transparent or translucent pixels is
|
|
903
|
+
* composited onto the `background` color (black by default) first, the image itself stays unchanged
|
|
1275
904
|
* @param options See {@link JPEGEncodeOptions}
|
|
1276
905
|
*/
|
|
1277
|
-
encodeJPEG(options?: JPEGEncodeOptions): Promise<Uint8Array
|
|
1278
|
-
/**
|
|
1279
|
-
* Encodes the image into a JPEG
|
|
1280
|
-
* @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
|
|
1281
|
-
* @deprecated Pass {@link JPEGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1282
|
-
*/
|
|
1283
|
-
encodeJPEG(quality?: number): Promise<Uint8Array>;
|
|
906
|
+
encodeJPEG(options?: JPEGEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1284
907
|
/**
|
|
1285
908
|
* Encodes the image as WebP: lossless (usually 20-30% smaller than PNG, but slower to encode), or lossy with a
|
|
1286
909
|
* quality
|
|
1287
910
|
* @param options See {@link WebPEncodeOptions}
|
|
1288
911
|
*/
|
|
1289
|
-
encodeWebP(
|
|
912
|
+
encodeWebP(options?: WebPEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1290
913
|
/**
|
|
1291
914
|
* Encodes the image as run length encoded TGA (32 bit, or 24 bit if the image is opaque)
|
|
1292
|
-
* @param options See {@link
|
|
915
|
+
* @param options See {@link TGAEncodeOptions}
|
|
1293
916
|
*/
|
|
1294
|
-
encodeTGA(
|
|
917
|
+
encodeTGA(options?: TGAEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
918
|
+
/**
|
|
919
|
+
* Encodes the image as a GIF (one frame): at most 256 colors, transparency only on or off (pixels with an alpha below
|
|
920
|
+
* 128 become transparent). For animations, see {@link Animation.encodeGIF}
|
|
921
|
+
* @param options The palette size, the dithering and the metadata, see {@link GIFEncodeOptions}
|
|
922
|
+
*/
|
|
923
|
+
encodeGIF(options?: GIFEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1295
924
|
/**
|
|
1296
925
|
* Encodes the image as BMP: with a palette if it is opaque and has at most 256 colors, else with 24 bit pixels, or
|
|
1297
926
|
* 32 bit ones if it has transparency
|
|
1298
927
|
*/
|
|
1299
|
-
encodeBMP(): Promise<Uint8Array
|
|
928
|
+
encodeBMP(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1300
929
|
/**
|
|
1301
930
|
* Encodes the image as QOI (3 channels if the image is opaque)
|
|
1302
931
|
*/
|
|
1303
|
-
encodeQOI(): Promise<Uint8Array
|
|
932
|
+
encodeQOI(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1304
933
|
/**
|
|
1305
934
|
* Encodes the image as AVIF (AV1, with an alpha image if the image has transparency)
|
|
1306
935
|
* @param options See {@link AVIFEncodeOptions}
|
|
1307
936
|
*/
|
|
1308
|
-
encodeAVIF(
|
|
937
|
+
encodeAVIF(options?: AVIFEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1309
938
|
/**
|
|
1310
939
|
* Encodes the image as JPEG XL: losslessly (the default) like libjxl's `cjxl -e 3` (a palette of up to 1024 colors,
|
|
1311
940
|
* else palettes of channels using few of their values; YCoCg; the weighted predictor in contexts of its error;
|
|
1312
|
-
*
|
|
941
|
+
* grayscale if the image is), at effort 0 the codestream byte for byte like `cjxl -e 1` on CPUs with AVX2 or NEON
|
|
1313
942
|
* (its fast lossless mode: the gradient predictor, a palette if the image has at most 511 colors besides black,
|
|
1314
943
|
* else YCoCg), or lossy with a quality (like `cjxl -q`: XYB, varblocks of libjxl's search, chroma from luma, the
|
|
1315
944
|
* edge preserving filter). Alpha (if the image has transparency) is lossless either way. The codestream is in the
|
|
1316
945
|
* container, with the metadata as Exif
|
|
1317
946
|
* @param options See {@link JXLEncodeOptions}
|
|
1318
947
|
*/
|
|
1319
|
-
encodeJXL(
|
|
948
|
+
encodeJXL(options?: JXLEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1320
949
|
/**
|
|
1321
|
-
* Encodes the image as the smallest fitting Netpbm format: PBM for black and white images, PGM for
|
|
950
|
+
* Encodes the image as the smallest fitting Netpbm format: PBM for black and white images, PGM for grayscale ones,
|
|
1322
951
|
* PPM for others, PAM if the image has transparency
|
|
1323
952
|
*/
|
|
1324
|
-
encodePNM(): Promise<Uint8Array
|
|
953
|
+
encodePNM(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1325
954
|
/**
|
|
1326
955
|
* Decodes an image (PNG, JPEG, TIFF, WebP, BMP, ICO, CUR, QOI, PBM, PGM, PPM, PAM, PFM, Radiance HDR, TGA, AVIF or
|
|
1327
|
-
* JPEG XL). For
|
|
1328
|
-
* {@link Animation.decode}
|
|
1329
|
-
*
|
|
956
|
+
* JPEG XL). For animations (GIFs, animated WebPs, AVIF image sequences, JPEG XL animations) this is the first frame,
|
|
957
|
+
* composed onto the canvas as {@link Animation.decode} has it, and decoding stops after it: use
|
|
958
|
+
* {@link Animation.decode} for all frames. For APNGs this is the default image, which is what viewers without APNG
|
|
959
|
+
* support show; for icons and cursors it's their largest image
|
|
1330
960
|
* @param input The binary data to decode
|
|
1331
961
|
* @param options See {@link DecodeOptions}. JPEGs, TIFFs and PNGs are rotated/mirrored as their orientation tag
|
|
1332
962
|
* (Exif, for PNGs also XMP) says by default: photos taken with a rotated camera are stored sideways
|
|
@@ -1334,26 +964,12 @@ export declare class Image {
|
|
|
1334
964
|
*/
|
|
1335
965
|
static decode(input: BinaryData, options?: DecodeOptions): Promise<Image>;
|
|
1336
966
|
/**
|
|
1337
|
-
*
|
|
1338
|
-
* @group Deprecated
|
|
1339
|
-
*/
|
|
1340
|
-
static readonly SVG_MODE_SCALE = 1;
|
|
1341
|
-
/**
|
|
1342
|
-
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1343
|
-
* @group Deprecated
|
|
1344
|
-
*/
|
|
1345
|
-
static readonly SVG_MODE_WIDTH = 2;
|
|
1346
|
-
/**
|
|
1347
|
-
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1348
|
-
* @group Deprecated
|
|
1349
|
-
*/
|
|
1350
|
-
static readonly SVG_MODE_HEIGHT = 3;
|
|
1351
|
-
/**
|
|
1352
|
-
* Creates a new image from the given SVG
|
|
967
|
+
* Creates a new image from the given SVG.
|
|
1353
968
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
1354
969
|
* masks, opacity, blend modes, filters (all primitives and the filter functions) and images embedded as data URIs
|
|
1355
|
-
* (PNG, JPEG, GIF, WebP, SVG) or given with {@link
|
|
1356
|
-
* (see {@link
|
|
970
|
+
* (PNG, JPEG, GIF, WebP, SVG) or given with {@link RenderSVGOptions.images}, and text with the given or embedded fonts
|
|
971
|
+
* (see {@link RenderSVGOptions.fonts}). Hrefs are resolved from the options and the data URIs only, never from files or URLs:
|
|
972
|
+
* drawing an image that isn't given, or can't be decoded, throws.
|
|
1357
973
|
* @example
|
|
1358
974
|
* ```ts
|
|
1359
975
|
* const logo = await Image.renderSVG(
|
|
@@ -1362,19 +978,10 @@ export declare class Image {
|
|
|
1362
978
|
* );
|
|
1363
979
|
* ```
|
|
1364
980
|
* @param svg The SVG content
|
|
1365
|
-
* @param options See {@link
|
|
981
|
+
* @param options See {@link RenderSVGOptions}
|
|
1366
982
|
* @return The rendered SVG graphic
|
|
1367
983
|
*/
|
|
1368
|
-
static renderSVG(svg: string | BinaryData, options?:
|
|
1369
|
-
/**
|
|
1370
|
-
* Creates a new image from the given SVG
|
|
1371
|
-
* @param svg The SVG content
|
|
1372
|
-
* @param size The size to use
|
|
1373
|
-
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
1374
|
-
* @return The rendered SVG graphic
|
|
1375
|
-
* @deprecated Pass {@link SVGOptions} instead, the positional arguments will be removed in 4.0
|
|
1376
|
-
*/
|
|
1377
|
-
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|
|
984
|
+
static renderSVG(svg: string | BinaryData, options?: RenderSVGOptions): Promise<Image>;
|
|
1378
985
|
/**
|
|
1379
986
|
* Creates a new image containing the rendered text.
|
|
1380
987
|
* @param text Text to render
|
|
@@ -1383,37 +990,9 @@ export declare class Image {
|
|
|
1383
990
|
* @return The rendered text
|
|
1384
991
|
*/
|
|
1385
992
|
static renderText(text: string, options: RenderTextOptions): Promise<Image>;
|
|
1386
|
-
/**
|
|
1387
|
-
* Creates a new image containing the rendered text.
|
|
1388
|
-
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
1389
|
-
* character comes from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height.
|
|
1390
|
-
* Color glyphs (COLR layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any
|
|
1391
|
-
* script is shaped like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts,
|
|
1392
|
-
* marks)
|
|
1393
|
-
* @param size Font size in pixels (per em)
|
|
1394
|
-
* @param text Text to render
|
|
1395
|
-
* @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
|
|
1396
|
-
* side
|
|
1397
|
-
* @return The rendered text
|
|
1398
|
-
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1399
|
-
* This signature will be removed in 4.0
|
|
1400
|
-
*/
|
|
1401
|
-
static renderText(font: BinaryData | BinaryData[], size: number, text: string, options?: TextOptions): Promise<Image>;
|
|
1402
|
-
/**
|
|
1403
|
-
* Creates a new image containing the rendered text.
|
|
1404
|
-
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
1405
|
-
* character comes from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height.
|
|
1406
|
-
* Color glyphs (COLR layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any
|
|
1407
|
-
* script is shaped like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts,
|
|
1408
|
-
* marks)
|
|
1409
|
-
* @param size Font size in pixels (per em)
|
|
1410
|
-
* @param text Text to render
|
|
1411
|
-
* @param [color=0xffffffff] Text color to use
|
|
1412
|
-
* @param [layout] The text layout to use
|
|
1413
|
-
* @param style Outline, see {@link TextStyle}; the image grows by the outline width on every side
|
|
1414
|
-
* @return The rendered text
|
|
1415
|
-
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1416
|
-
* This signature will be removed in 4.0
|
|
1417
|
-
*/
|
|
1418
|
-
static renderText(font: BinaryData | BinaryData[], size: number, text: string, color?: Color, layout?: TextLayout, style?: TextStyle): Promise<Image>;
|
|
1419
993
|
}
|
|
994
|
+
/**
|
|
995
|
+
* The size of an image of `width` x `height` resized to fit inside a box of `boxWidth` x `boxHeight`, keeping its aspect
|
|
996
|
+
* ratio: the limiting side matches the box exactly (rounded instead of floored), the other one is at least 1 pixel
|
|
997
|
+
*/
|
|
998
|
+
export declare function insideSize(width: number, height: number, boxWidth: number, boxHeight: number): [width: number, height: number];
|