imagescript 3.20.1 → 4.0.0-rc.1
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/README.md +21 -12
- package/dist/animation-encoder.d.ts +1 -34
- package/dist/animation-encoder.js +24 -23
- package/dist/animation.d.ts +108 -122
- package/dist/animation.js +274 -107
- 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 +2 -2
- 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/colors.d.ts +8 -7
- package/dist/colors.js +13 -3
- package/dist/frame.d.ts +93 -102
- package/dist/frame.js +89 -62
- package/dist/gainmap.d.ts +88 -46
- package/dist/gainmap.js +73 -49
- package/dist/image-type.d.ts +6 -1
- package/dist/image-type.js +4 -1
- package/dist/image.d.ts +287 -732
- package/dist/image.js +255 -404
- package/dist/index.d.ts +15 -25
- package/dist/index.js +15 -14
- package/dist/render/svg.js +7 -2
- package/dist/text-layout.d.ts +5 -35
- package/dist/text-layout.js +9 -9
- package/dist/util/gain.js +12 -12
- package/dist/util/mem.d.ts +1 -1
- package/dist/util/options.js +20 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/gif.d.ts +0 -36
- package/dist/gif.js +0 -22
- package/dist/util/rotate.js +0 -43
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,23 +293,36 @@ 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;
|
|
310
309
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
310
|
+
* Maximum total pixels in the rendered output. Output over the limit throws a RangeError. Raster images decoded
|
|
311
|
+
* from embedded data are limited too and omitted if they exceed it; already-decoded {@link Image} values are used
|
|
312
|
+
* as supplied. Default: `268402689` (16383²); `Infinity` disables the limit
|
|
313
313
|
*/
|
|
314
|
-
|
|
314
|
+
maxPixels?: number;
|
|
315
315
|
/**
|
|
316
|
-
* Fonts for `<text>` (TrueType, OpenType
|
|
316
|
+
* Fonts for `<text>` (TrueType, OpenType or WOFF; not WOFF2 or some newer OpenType outline formats such as CFF2):
|
|
317
|
+
* each text gets the face its `font-family`, `font-weight`, `font-style`
|
|
317
318
|
* and `font-stretch` match best among them, by the names, weights and styles in the fonts (like browsers match
|
|
318
319
|
* installed fonts). Generic families (`serif`, `sans-serif`, `monospace`, ...) are the first font that fits them,
|
|
319
320
|
* other families and text without one get the first font's family; characters a face doesn't have come from the
|
|
320
321
|
* 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.
|
|
322
|
+
* before these for their family names. Without any fonts text isn't rendered. One font can be given without an
|
|
323
|
+
* array. Default: `[]`
|
|
322
324
|
*/
|
|
323
|
-
fonts?: BinaryData[];
|
|
325
|
+
fonts?: BinaryData | BinaryData[];
|
|
324
326
|
/**
|
|
325
327
|
* Images for the `<image>` elements (and `feImage`) by their `href`, the same string the SVG uses: with
|
|
326
328
|
* `images: { 'logo.png': bytes }`, `<image href="logo.png" .../>` draws the image. Values are encoded images (PNG,
|
|
@@ -330,136 +332,114 @@ export interface SVGOptions {
|
|
|
330
332
|
*/
|
|
331
333
|
images?: Record<string, BinaryData | Image>;
|
|
332
334
|
}
|
|
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 {
|
|
335
|
+
/**
|
|
336
|
+
* Options of {@link Image.renderText}: the font and size, the text color, the layout (wrapping, cutting off and alignment,
|
|
337
|
+
* see {@link TextLayoutOptions}) and the style (see {@link TextStyleOptions})
|
|
338
|
+
*/
|
|
339
|
+
export interface RenderTextOptions extends TextStyleOptions, TextLayoutOptions {
|
|
342
340
|
/**
|
|
343
|
-
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use
|
|
341
|
+
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use (not WOFF2 or some newer OpenType outline formats
|
|
342
|
+
* such as CFF2), or several by priority: every character comes
|
|
344
343
|
* 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
|
-
*
|
|
344
|
+
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Shaping includes bidirectional
|
|
345
|
+
* layout, Arabic joining, and script-specific OpenType shapers for Indic scripts, Hebrew, Thai/Lao, Hangul, Khmer,
|
|
346
|
+
* Myanmar and other Universal Shaping Engine scripts; other scripts use default OpenType shaping.
|
|
347
347
|
*/
|
|
348
348
|
font: BinaryData | BinaryData[];
|
|
349
349
|
/** Font size in pixels (per em) */
|
|
350
350
|
size: number;
|
|
351
351
|
/** The text color. Default: `0xffffffff` */
|
|
352
352
|
color?: Color;
|
|
353
|
-
/** The text layout, as {@link TextLayoutOptions} or a {@link TextLayout}. Default: the defaults of `TextLayout` */
|
|
354
|
-
layout?: TextLayoutOptions | TextLayout;
|
|
355
353
|
}
|
|
356
|
-
/** Options of {@link Image.decode} */
|
|
354
|
+
/** Options of {@link Image.decode}, {@link Animation.decode} and {@link decode} */
|
|
357
355
|
export interface DecodeOptions {
|
|
358
|
-
/**
|
|
356
|
+
/**
|
|
357
|
+
* Whether to rotate or mirror the image according to its saved orientation information, so photos taken with a
|
|
358
|
+
* rotated camera display upright. This applies to every animation frame too. Default: `true`
|
|
359
|
+
*/
|
|
359
360
|
applyOrientation?: boolean;
|
|
360
361
|
/**
|
|
361
|
-
* Whether to
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
362
|
+
* Whether to use the image's embedded color profile (color information describing its pixels) to convert its
|
|
363
|
+
* colors to sRGB, the standard used by most screens and browsers. Common RGB and gray profiles described by a
|
|
364
|
+
* color matrix and tone curves are converted, as are AVIFs using other color ranges (such as Display P3 or BT.2020).
|
|
365
|
+
* Colors outside sRGB are clipped. Profiles that rely on lookup tables, CMYK profiles and profiles already in
|
|
366
|
+
* sRGB are left unchanged. Default: `true`
|
|
366
367
|
*/
|
|
367
368
|
applyColorProfile?: boolean;
|
|
368
369
|
/**
|
|
369
|
-
* The
|
|
370
|
-
*
|
|
371
|
-
*
|
|
370
|
+
* The maximum total pixels to decode. An image declaring more pixels throws a RangeError before its pixel buffer
|
|
371
|
+
* is allocated, helping prevent a small or untrusted file from requesting an enormous amount of memory.
|
|
372
|
+
* {@link Animation.decode} counts all frames together because each frame uses a full canvas. Default:
|
|
373
|
+
* `268402689` (16383²); `Infinity` disables the limit
|
|
372
374
|
*/
|
|
373
375
|
maxPixels?: number;
|
|
374
376
|
/**
|
|
375
|
-
* How
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* brighter than white. Default: `'reinhard'`
|
|
377
|
+
* How high-dynamic-range images (which can be brighter than a standard screen's white) become 8-bit sRGB.
|
|
378
|
+
* `'reinhard'` gently compresses bright highlights so the brightest pixel becomes white; images that are not HDR
|
|
379
|
+
* stay unchanged. `'clamp'` clips anything brighter than white. Default: `'reinhard'`
|
|
379
380
|
*/
|
|
380
381
|
toneMapping?: ToneMapping;
|
|
381
382
|
/**
|
|
382
|
-
* Whether to read
|
|
383
|
-
*
|
|
383
|
+
* Whether to read extra HDR brightness data (a gain map) from supported JPEG, AVIF and JPEG XL images into
|
|
384
|
+
* {@link Image.gainMap}. For animations, this also reads maps from supported JPEG XL frames. Default: `true`
|
|
384
385
|
*/
|
|
385
386
|
gainMap?: boolean;
|
|
386
387
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
* one
|
|
390
|
-
* workers can't share memory)
|
|
388
|
+
* Maximum worker threads for formats and image sizes that can be decoded in parallel. Small images may use one
|
|
389
|
+
* thread because starting workers can take longer than decoding them. Default: the available processors, up to 8
|
|
390
|
+
* (one in runtimes that cannot share memory between workers)
|
|
391
391
|
*/
|
|
392
392
|
threads?: number;
|
|
393
393
|
}
|
|
394
394
|
/** Options of {@link Image.encodeJXL} */
|
|
395
|
-
export interface JXLEncodeOptions {
|
|
395
|
+
export interface JXLEncodeOptions extends EncodeOptions {
|
|
396
396
|
/**
|
|
397
|
-
* Lossy compression (0-100
|
|
398
|
-
* Without
|
|
397
|
+
* Lossy compression (0-100): higher values usually preserve more detail but make larger files; `100` is
|
|
398
|
+
* lossless. Without this option, the image is encoded losslessly
|
|
399
399
|
*/
|
|
400
400
|
quality?: number;
|
|
401
401
|
/**
|
|
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`
|
|
402
|
+
* Compression effort (0-2): higher values usually take longer but may make smaller files. `0` prioritizes speed;
|
|
403
|
+
* `2` spends the most time compressing. Default: `1`
|
|
407
404
|
*/
|
|
408
405
|
effort?: number;
|
|
409
406
|
/**
|
|
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
|
|
407
|
+
* Maximum worker threads for compression. Small images or runtimes that cannot share memory between workers use
|
|
408
|
+
* one thread. Default: the available processors, up to 8
|
|
416
409
|
*/
|
|
417
410
|
threads?: number;
|
|
418
|
-
/** Metadata to include, see {@link Metadata} */
|
|
419
|
-
metadata?: Metadata;
|
|
420
411
|
/**
|
|
421
|
-
* Whether to write the image's {@link Image.gainMap}
|
|
422
|
-
* Default: `true` (written if there is one)
|
|
412
|
+
* Whether to write the image's {@link Image.gainMap}, the extra data used to show brighter highlights on HDR
|
|
413
|
+
* displays. Default: `true` (written if there is one)
|
|
423
414
|
*/
|
|
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
|
-
};
|
|
415
|
+
gainMap?: boolean | GainMapEmbedOptions;
|
|
430
416
|
}
|
|
431
417
|
/** Options of {@link Image.encodeAVIF} */
|
|
432
|
-
export interface AVIFEncodeOptions {
|
|
418
|
+
export interface AVIFEncodeOptions extends EncodeOptions {
|
|
433
419
|
/** 0-100, like avifenc's: higher is better and larger, 100 is lossless. Default: `60` */
|
|
434
420
|
quality?: number;
|
|
435
|
-
/** The quality of the
|
|
421
|
+
/** The quality of the transparency channel, if the image has transparency. Default: `100` (lossless) */
|
|
436
422
|
alphaQuality?: number;
|
|
437
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* How much color detail to keep: `'4:4:4'` keeps it all; `'4:2:0'` stores less color detail to make a smaller
|
|
425
|
+
* file. Default: `'4:4:4'`
|
|
426
|
+
*/
|
|
438
427
|
subsampling?: '4:4:4' | '4:2:0';
|
|
439
428
|
/** How hard the encoder searches for the best modes: 0-2, faster to smaller. Default: `1` */
|
|
440
429
|
effort?: number;
|
|
441
430
|
/**
|
|
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
|
|
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
|
|
446
433
|
*/
|
|
447
434
|
threads?: number;
|
|
448
|
-
/** Metadata to include, see {@link Metadata} */
|
|
449
|
-
metadata?: Metadata;
|
|
450
435
|
/**
|
|
451
|
-
* Whether to write the image's {@link Image.gainMap}
|
|
452
|
-
*
|
|
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)
|
|
453
438
|
*/
|
|
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
|
-
};
|
|
439
|
+
gainMap?: boolean | GainMapEmbedOptions;
|
|
460
440
|
}
|
|
461
441
|
/** Text style options of {@link Image.renderText} */
|
|
462
|
-
export interface
|
|
442
|
+
export interface TextStyleOptions {
|
|
463
443
|
/** Width of an outline around the glyphs in pixels. Default: `0` */
|
|
464
444
|
strokeWidth?: number;
|
|
465
445
|
/** Color of the outline. Default: `0x000000ff` */
|
|
@@ -494,11 +474,6 @@ export interface CropCircleOptions {
|
|
|
494
474
|
* transparent on the shorter side). Default: `'contain'`
|
|
495
475
|
*/
|
|
496
476
|
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
477
|
/** Share of the radius (0..1) over which the edge fades out. Default: `0` */
|
|
503
478
|
feathering?: number;
|
|
504
479
|
}
|
|
@@ -513,15 +488,17 @@ export interface DominantColorOptions {
|
|
|
513
488
|
}
|
|
514
489
|
/** Options of {@link Image.rotate} */
|
|
515
490
|
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
491
|
/**
|
|
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`
|
|
492
|
+
* Whether to make the image larger so the rotated corners aren't cut off. Without it, the image keeps its size and
|
|
493
|
+
* the parts outside are lost. Default: `true`
|
|
523
494
|
*/
|
|
524
|
-
|
|
495
|
+
expand?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* How the pixels between the source's are sampled for angles that aren't multiples of 90° (those move whole
|
|
498
|
+
* pixels): `'nearest-neighbor'` (hard pixels, for pixel art), `'bilinear'` (smooth) or `'bicubic'` (sharper, can
|
|
499
|
+
* overshoot a little at hard edges), like {@link TransformOptions.mode}. Default: `'bilinear'`
|
|
500
|
+
*/
|
|
501
|
+
mode?: TransformMode;
|
|
525
502
|
}
|
|
526
503
|
/** Options of {@link Image.trim} */
|
|
527
504
|
export interface TrimOptions {
|
|
@@ -545,12 +522,6 @@ export interface ColorToAlphaOptions {
|
|
|
545
522
|
/** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
|
|
546
523
|
opacityThreshold?: number;
|
|
547
524
|
}
|
|
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
525
|
/**
|
|
555
526
|
* An RGBA image; provides the codecs and the manipulation functions. Methods that change the image modify it in place
|
|
556
527
|
* and return it, so calls can be chained
|
|
@@ -563,8 +534,9 @@ export declare class Image {
|
|
|
563
534
|
*/
|
|
564
535
|
constructor(width: number, height: number);
|
|
565
536
|
/**
|
|
566
|
-
*
|
|
567
|
-
*
|
|
537
|
+
* Extra image data that lets high-dynamic-range (HDR) screens show brighter highlights. Standard screens show the
|
|
538
|
+
* image without the extra brightness. {@link Image.encodeJPEG}, {@link Image.encodeAVIF} and
|
|
539
|
+
* {@link Image.encodeJXL} can write it. `null` means there is no gain map
|
|
568
540
|
*/
|
|
569
541
|
get gainMap(): GainMap | null;
|
|
570
542
|
/**
|
|
@@ -573,8 +545,10 @@ export declare class Image {
|
|
|
573
545
|
*/
|
|
574
546
|
set gainMap(gainMap: GainMap | null);
|
|
575
547
|
/**
|
|
576
|
-
* The image's RGBA pixel data
|
|
577
|
-
*
|
|
548
|
+
* The image's RGBA pixel data (red, green, blue and transparency, four bytes per pixel). It can be replaced by any
|
|
549
|
+
* 8-bit array with width * height * 4 bytes
|
|
550
|
+
* (it is used as is, without copying). Direct changes to this array or {@link Image.setPixelAt} don't update the
|
|
551
|
+
* image's gain map.
|
|
578
552
|
*/
|
|
579
553
|
get bitmap(): Uint8ClampedArray;
|
|
580
554
|
/**
|
|
@@ -585,11 +559,11 @@ export declare class Image {
|
|
|
585
559
|
/** A short description for debugging, e.g. `Image<64x64>` */
|
|
586
560
|
toString(): string;
|
|
587
561
|
/**
|
|
588
|
-
* The
|
|
562
|
+
* The image's width
|
|
589
563
|
*/
|
|
590
564
|
get width(): number;
|
|
591
565
|
/**
|
|
592
|
-
* The
|
|
566
|
+
* The image's height
|
|
593
567
|
*/
|
|
594
568
|
get height(): number;
|
|
595
569
|
/**
|
|
@@ -602,82 +576,6 @@ export declare class Image {
|
|
|
602
576
|
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
603
577
|
*/
|
|
604
578
|
pixels(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
605
|
-
/**
|
|
606
|
-
* Yields an [x, y] array for every pixel in the image (0-based)
|
|
607
|
-
* @yields The coordinates of the pixel ([x, y])
|
|
608
|
-
* @deprecated Use {@link Image.coordinates}, iterating over the image will be removed in 4.0
|
|
609
|
-
* @group Deprecated
|
|
610
|
-
*/
|
|
611
|
-
[Symbol.iterator](): Generator<[x: number, y: number], void, undefined>;
|
|
612
|
-
/**
|
|
613
|
-
* Yields an [x, y, color] array for every pixel in the image (0-based)
|
|
614
|
-
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
615
|
-
* @deprecated Use {@link Image.pixels}, `iterateWithColors()` will be removed in 4.0
|
|
616
|
-
* @group Deprecated
|
|
617
|
-
*/
|
|
618
|
-
iterateWithColors(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
619
|
-
/**
|
|
620
|
-
* Converts RGBA components to an RGBA value, values are rounded and clamped to 0..255
|
|
621
|
-
* @param r red (0..255)
|
|
622
|
-
* @param g green (0..255)
|
|
623
|
-
* @param b blue (0..255)
|
|
624
|
-
* @param a alpha (0..255)
|
|
625
|
-
* @deprecated Use {@link Colors.fromRGBA}, `Image.rgbaToColor` will be removed in 4.0
|
|
626
|
-
* @group Deprecated
|
|
627
|
-
*/
|
|
628
|
-
static rgbaToColor(r: number, g: number, b: number, a: number): Color;
|
|
629
|
-
/**
|
|
630
|
-
* Converts RGB components to an RGBA value (assuming alpha = 255)
|
|
631
|
-
* @param r red (0..255)
|
|
632
|
-
* @param g green (0..255)
|
|
633
|
-
* @param b blue (0..255)
|
|
634
|
-
* @deprecated Use {@link Colors.fromRGB}, `Image.rgbToColor` will be removed in 4.0
|
|
635
|
-
* @group Deprecated
|
|
636
|
-
*/
|
|
637
|
-
static rgbToColor(r: number, g: number, b: number): Color;
|
|
638
|
-
/**
|
|
639
|
-
* Converts HSLA colors to RGBA colors
|
|
640
|
-
* @param h hue (0..1)
|
|
641
|
-
* @param s saturation (0..1)
|
|
642
|
-
* @param l lightness (0..1)
|
|
643
|
-
* @param a opacity (0..1)
|
|
644
|
-
* @deprecated Use {@link Colors.fromHSLA}, `Image.hslaToColor` will be removed in 4.0
|
|
645
|
-
* @group Deprecated
|
|
646
|
-
*/
|
|
647
|
-
static hslaToColor(h: number, s: number, l: number, a: number): Color;
|
|
648
|
-
/**
|
|
649
|
-
* Converts HSL colors to RGBA colors (assuming an opacity of 255)
|
|
650
|
-
* @param h hue (0..1)
|
|
651
|
-
* @param s saturation (0..1)
|
|
652
|
-
* @param l lightness (0..1)
|
|
653
|
-
* @deprecated Use {@link Colors.fromHSL}, `Image.hslToColor` will be removed in 4.0
|
|
654
|
-
* @group Deprecated
|
|
655
|
-
*/
|
|
656
|
-
static hslToColor(h: number, s: number, l: number): Color;
|
|
657
|
-
/**
|
|
658
|
-
* Converts an RGBA value to an array of HSLA values
|
|
659
|
-
* @param r red (0..255)
|
|
660
|
-
* @param g green (0..255)
|
|
661
|
-
* @param b blue (0..255)
|
|
662
|
-
* @param a alpha (0..255)
|
|
663
|
-
* @deprecated Use {@link Colors.toHSLA}, `Image.rgbaToHSLA` will be removed in 4.0
|
|
664
|
-
* @group Deprecated
|
|
665
|
-
*/
|
|
666
|
-
static rgbaToHSLA(r: number, g: number, b: number, a: number): [h: number, s: number, l: number, a: number];
|
|
667
|
-
/**
|
|
668
|
-
* Converts a color value to an array of RGBA values
|
|
669
|
-
* @param color The color value to convert
|
|
670
|
-
* @deprecated Use {@link Colors.toRGBA}, `Image.colorToRGBA` will be removed in 4.0
|
|
671
|
-
* @group Deprecated
|
|
672
|
-
*/
|
|
673
|
-
static colorToRGBA(color: Color): [r: number, g: number, b: number, a: number];
|
|
674
|
-
/**
|
|
675
|
-
* Converts a color value to an array of RGB values (ignoring the colors alpha)
|
|
676
|
-
* @param color The color value to convert
|
|
677
|
-
* @deprecated Use {@link Colors.toRGB}, `Image.colorToRGB` will be removed in 4.0
|
|
678
|
-
* @group Deprecated
|
|
679
|
-
*/
|
|
680
|
-
static colorToRGB(color: Color): [r: number, g: number, b: number];
|
|
681
579
|
/**
|
|
682
580
|
* Creates an image with a linear gradient, like CSS' `linear-gradient()`
|
|
683
581
|
* @param width The image's width
|
|
@@ -695,33 +593,19 @@ export declare class Image {
|
|
|
695
593
|
*/
|
|
696
594
|
static radialGradient(width: number, height: number, options: RadialGradientOptions): Image;
|
|
697
595
|
/**
|
|
698
|
-
*
|
|
699
|
-
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
700
|
-
* @deprecated Use {@link Colors.gradient}, `Image.gradient` will be removed in 4.0
|
|
701
|
-
* @group Deprecated
|
|
702
|
-
*/
|
|
703
|
-
static gradient(colors: Record<number, Color>): (position: number) => Color;
|
|
704
|
-
/**
|
|
705
|
-
* Gets the pixel color at the specified position (0-based)
|
|
596
|
+
* Gets the pixel color at the specified position (0-based). {@link Colors.toRGBA} splits it into its channels
|
|
706
597
|
* @param x The x coordinate
|
|
707
598
|
* @param y The y coordinate
|
|
708
599
|
* @returns The color value (`0xRRGGBBAA`)
|
|
709
600
|
*/
|
|
710
601
|
getPixelAt(x: number, y: number): Color;
|
|
711
|
-
/**
|
|
712
|
-
* Gets a view of the RGBA components of the pixel at the specified position (0-based)
|
|
713
|
-
* @param x The x coordinate
|
|
714
|
-
* @param y The y coordinate
|
|
715
|
-
* @returns The pixel's 4 bytes in {@link Image.bitmap}: writing to them changes the pixel
|
|
716
|
-
*/
|
|
717
|
-
getRGBAAt(x: number, y: number): Uint8ClampedArray;
|
|
718
602
|
/**
|
|
719
603
|
* Sets the pixel color for the specified position (0-based)
|
|
720
604
|
* @param x The x coordinate
|
|
721
605
|
* @param y The y coordinate
|
|
722
|
-
* @param
|
|
606
|
+
* @param color The new color (`0xRRGGBBAA`)
|
|
723
607
|
*/
|
|
724
|
-
setPixelAt(x: number, y: number,
|
|
608
|
+
setPixelAt(x: number, y: number, color: Color): this;
|
|
725
609
|
/**
|
|
726
610
|
* Fills the image data with the supplied color
|
|
727
611
|
* @param color The color, or a function returning the color of each pixel
|
|
@@ -731,45 +615,12 @@ export declare class Image {
|
|
|
731
615
|
* Clones the current image
|
|
732
616
|
*/
|
|
733
617
|
clone(): Image;
|
|
734
|
-
/**
|
|
735
|
-
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
736
|
-
* @group Deprecated
|
|
737
|
-
*/
|
|
738
|
-
static readonly RESIZE_NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
739
|
-
/**
|
|
740
|
-
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
741
|
-
* @group Deprecated
|
|
742
|
-
*/
|
|
743
|
-
static readonly RESIZE_BILINEAR = "RESIZE_BILINEAR";
|
|
744
|
-
/**
|
|
745
|
-
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
746
|
-
* @group Deprecated
|
|
747
|
-
*/
|
|
748
|
-
static readonly RESIZE_BICUBIC = "RESIZE_BICUBIC";
|
|
749
|
-
/**
|
|
750
|
-
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
751
|
-
* @group Deprecated
|
|
752
|
-
*/
|
|
753
|
-
static readonly RESIZE_AREA = "RESIZE_AREA";
|
|
754
|
-
/**
|
|
755
|
-
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `Image.RESIZE_*` will
|
|
756
|
-
* be removed in 4.0
|
|
757
|
-
* @group Deprecated
|
|
758
|
-
*/
|
|
759
|
-
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
760
618
|
/**
|
|
761
619
|
* Resizes the image by the given factor
|
|
762
620
|
* @param factor The factor to resize the image with
|
|
763
621
|
* @param options See {@link ResizeOptions}
|
|
764
622
|
*/
|
|
765
623
|
scale(factor: number, options?: ResizeOptions): this;
|
|
766
|
-
/**
|
|
767
|
-
* Resizes the image by the given factor
|
|
768
|
-
* @param factor The factor to resize the image with
|
|
769
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
770
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
771
|
-
*/
|
|
772
|
-
scale(factor: number, mode?: ResizeMode): this;
|
|
773
624
|
/**
|
|
774
625
|
* Resizes the image to the given dimensions.
|
|
775
626
|
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
@@ -779,90 +630,23 @@ export declare class Image {
|
|
|
779
630
|
* @returns The resized image
|
|
780
631
|
*/
|
|
781
632
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
782
|
-
/**
|
|
783
|
-
* Resizes the image to the given dimensions.
|
|
784
|
-
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
785
|
-
* @param width The new width
|
|
786
|
-
* @param height The new height
|
|
787
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
788
|
-
* @returns The resized image
|
|
789
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
790
|
-
*/
|
|
791
|
-
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
792
633
|
/**
|
|
793
634
|
* Resizes the image: to the given width or height (the other side keeps the aspect ratio), or to both
|
|
794
635
|
* @param options The size and how to resize, see {@link ResizeToOptions}
|
|
795
636
|
* @returns The resized image
|
|
796
637
|
*/
|
|
797
638
|
resize(options: ResizeToOptions): this;
|
|
798
|
-
/**
|
|
799
|
-
* Resizes the image so it is contained in the given bounding box.
|
|
800
|
-
* Can return an image with one axis smaller than the given bounding box.
|
|
801
|
-
* @param width The width of the bounding box
|
|
802
|
-
* @param height The height of the bounding box
|
|
803
|
-
* @param options See {@link ResizeOptions}
|
|
804
|
-
* @returns The resized image
|
|
805
|
-
*/
|
|
806
|
-
contain(width: number, height: number, options?: ResizeOptions): this;
|
|
807
|
-
/**
|
|
808
|
-
* Resizes the image so it is contained in the given bounding box.
|
|
809
|
-
* Can return an image with one axis smaller than the given bounding box.
|
|
810
|
-
* @param width The width of the bounding box
|
|
811
|
-
* @param height The height of the bounding box
|
|
812
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
813
|
-
* @returns The resized image
|
|
814
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
815
|
-
*/
|
|
816
|
-
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
817
|
-
/**
|
|
818
|
-
* Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
|
|
819
|
-
* Always returns the exact dimensions of the bounding box.
|
|
820
|
-
* @param width The width of the bounding box
|
|
821
|
-
* @param height The height of the bounding box
|
|
822
|
-
* @param options See {@link ResizeOptions}
|
|
823
|
-
* @returns The resized image
|
|
824
|
-
*/
|
|
825
|
-
fit(width: number, height: number, options?: ResizeOptions): this;
|
|
826
|
-
/**
|
|
827
|
-
* Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
|
|
828
|
-
* Always returns the exact dimensions of the bounding box.
|
|
829
|
-
* @param width The width of the bounding box
|
|
830
|
-
* @param height The height of the bounding box
|
|
831
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
832
|
-
* @returns The resized image
|
|
833
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
834
|
-
*/
|
|
835
|
-
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
836
|
-
/**
|
|
837
|
-
* Resizes the image so it covers the given bounding box, cropping the overflowing edges.
|
|
838
|
-
* Always returns the exact dimensions of the bounding box.
|
|
839
|
-
* @param width The width of the bounding box
|
|
840
|
-
* @param height The height of the bounding box
|
|
841
|
-
* @param options See {@link ResizeOptions}
|
|
842
|
-
* @returns The resized image
|
|
843
|
-
*/
|
|
844
|
-
cover(width: number, height: number, options?: ResizeOptions): this;
|
|
845
|
-
/**
|
|
846
|
-
* Resizes the image so it covers the given bounding box, cropping the overflowing edges.
|
|
847
|
-
* Always returns the exact dimensions of the bounding box.
|
|
848
|
-
* @param width The width of the bounding box
|
|
849
|
-
* @param height The height of the bounding box
|
|
850
|
-
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
851
|
-
* @returns The resized image
|
|
852
|
-
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
853
|
-
*/
|
|
854
|
-
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
855
639
|
/**
|
|
856
640
|
* Crops an image to the specified dimensions.
|
|
857
641
|
* The region is clipped to the image, so the result can be smaller than the requested size
|
|
858
642
|
* @param x The x offset (0-based)
|
|
859
643
|
* @param y The y offset (0-based)
|
|
860
|
-
* @param width The new
|
|
861
|
-
* @param height The new
|
|
644
|
+
* @param width The new width
|
|
645
|
+
* @param height The new height
|
|
862
646
|
*/
|
|
863
647
|
crop(x: number, y: number, width: number, height: number): this;
|
|
864
648
|
/**
|
|
865
|
-
* Copies a region of the image into a new image
|
|
649
|
+
* Copies a region of the image into a new image and leaves the image unchanged (like {@link Image.crop} on a clone,
|
|
866
650
|
* without copying the whole image). The region is clipped to the image, so the result can be smaller than the
|
|
867
651
|
* requested size
|
|
868
652
|
* @param x The x offset (0-based)
|
|
@@ -870,54 +654,18 @@ export declare class Image {
|
|
|
870
654
|
* @param width The region's width
|
|
871
655
|
* @param height The region's height
|
|
872
656
|
*/
|
|
873
|
-
|
|
657
|
+
extract(x: number, y: number, width: number, height: number): Image;
|
|
874
658
|
/**
|
|
875
659
|
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
876
|
-
*
|
|
877
|
-
* unchanged
|
|
660
|
+
* An image that only has the color stays unchanged ({@link Frame.trim} also moves the frame's offsets)
|
|
878
661
|
* @param options See {@link TrimOptions}
|
|
879
662
|
*/
|
|
880
663
|
trim(options?: TrimOptions): this;
|
|
881
|
-
/**
|
|
882
|
-
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
883
|
-
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
884
|
-
* unchanged
|
|
885
|
-
* @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
|
|
886
|
-
* same color whatever their RGB values
|
|
887
|
-
* @param options See {@link TrimOptions}
|
|
888
|
-
* @deprecated Pass {@link TrimOptions} instead, the positional arguments will be removed in 4.0
|
|
889
|
-
*/
|
|
890
|
-
trim(color?: Color, options?: TrimOptions): this;
|
|
891
|
-
/**
|
|
892
|
-
* Draws a box at the specified coordinates (0-based), clipped to the image
|
|
893
|
-
* @param x The x offset
|
|
894
|
-
* @param y The y offset
|
|
895
|
-
* @param width The box width
|
|
896
|
-
* @param height The box height
|
|
897
|
-
* @param color The color to fill the box in with, a function gets coordinates relative to the box
|
|
898
|
-
*/
|
|
899
|
-
drawBox(x: number, y: number, width: number, height: number, color: Color | ColorFunction): this;
|
|
900
|
-
/**
|
|
901
|
-
* Draws an antialiased circle around the center of the specified pixel (0-based)
|
|
902
|
-
* @param x The center x position
|
|
903
|
-
* @param y The center y position
|
|
904
|
-
* @param radius The circles radius in pixels
|
|
905
|
-
* @param color The color, a function gets coordinates relative to the circle's bounding box
|
|
906
|
-
*/
|
|
907
|
-
drawCircle(x: number, y: number, radius: number, color: Color | ColorFunction): this;
|
|
908
664
|
/**
|
|
909
665
|
* Crops the image into a circle with an antialiased edge
|
|
910
666
|
* @param options See {@link CropCircleOptions}
|
|
911
667
|
*/
|
|
912
668
|
cropCircle(options?: CropCircleOptions): this;
|
|
913
|
-
/**
|
|
914
|
-
* Crops the image into a circle with an antialiased edge
|
|
915
|
-
* @param max Whether to use the larger dimension for the size. Default: `false`
|
|
916
|
-
* @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
|
|
917
|
-
* @deprecated Pass {@link CropCircleOptions} instead, `cropCircle({ size: 'cover' })`. The arguments will be
|
|
918
|
-
* removed in 4.0
|
|
919
|
-
*/
|
|
920
|
-
cropCircle(max?: boolean, feathering?: number): this;
|
|
921
669
|
/**
|
|
922
670
|
* Sets the RGB of every pixel to the given color, keeping each pixel's own alpha. Turns an image into a silhouette
|
|
923
671
|
* or tints it: `image.recolor(0xffffffff)` makes every pixel white, keeping its transparency
|
|
@@ -934,81 +682,33 @@ export declare class Image {
|
|
|
934
682
|
/**
|
|
935
683
|
* Scales the opacity of the image
|
|
936
684
|
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
937
|
-
* @param options See {@link AdjustOptions}
|
|
938
|
-
*/
|
|
939
|
-
opacity(opacity: number, options?: AdjustOptions): this;
|
|
940
|
-
/**
|
|
941
|
-
* Scales the opacity of the image
|
|
942
|
-
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
943
|
-
* @param absolute Whether to set the opacity (true) instead of scaling it (false)
|
|
944
|
-
* @deprecated Use {@link Image.opacity} to scale; for a fixed alpha, `absolute` is removed in 4.0
|
|
945
|
-
*/
|
|
946
|
-
opacity(opacity: number, absolute?: boolean): this;
|
|
947
|
-
/**
|
|
948
|
-
* Scales the red channel
|
|
949
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
950
|
-
* @param options See {@link AdjustOptions}
|
|
951
685
|
*/
|
|
952
|
-
|
|
686
|
+
opacity(opacity: number): this;
|
|
953
687
|
/**
|
|
954
688
|
* Scales the red channel
|
|
955
689
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
956
|
-
* @param absolute Whether to set every pixel's red channel to `factor` * 255 (true) instead of scaling it (false)
|
|
957
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
958
|
-
*/
|
|
959
|
-
red(factor: number, absolute?: boolean): this;
|
|
960
|
-
/**
|
|
961
|
-
* Scales the green channel
|
|
962
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
963
|
-
* @param options See {@link AdjustOptions}
|
|
964
690
|
*/
|
|
965
|
-
|
|
691
|
+
red(factor: number): this;
|
|
966
692
|
/**
|
|
967
693
|
* Scales the green channel
|
|
968
694
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
969
|
-
* @param absolute Whether to set every pixel's green channel to `factor` * 255 (true) instead of scaling it (false)
|
|
970
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
971
|
-
*/
|
|
972
|
-
green(factor: number, absolute?: boolean): this;
|
|
973
|
-
/**
|
|
974
|
-
* Scales the blue channel
|
|
975
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
976
|
-
* @param options See {@link AdjustOptions}
|
|
977
695
|
*/
|
|
978
|
-
|
|
696
|
+
green(factor: number): this;
|
|
979
697
|
/**
|
|
980
698
|
* Scales the blue channel
|
|
981
699
|
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
982
|
-
* @param absolute Whether to set every pixel's blue channel to `factor` * 255 (true) instead of scaling it (false)
|
|
983
|
-
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
984
|
-
*/
|
|
985
|
-
blue(factor: number, absolute?: boolean): this;
|
|
986
|
-
/**
|
|
987
|
-
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
988
|
-
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
989
|
-
* @param options See {@link AdjustOptions}
|
|
990
700
|
*/
|
|
991
|
-
|
|
701
|
+
blue(factor: number): this;
|
|
992
702
|
/**
|
|
993
703
|
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
994
|
-
* @param
|
|
995
|
-
* @param absolute Whether to set the lightness (true) instead of scaling it (false)
|
|
996
|
-
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
997
|
-
*/
|
|
998
|
-
lightness(value: number, absolute?: boolean): this;
|
|
999
|
-
/**
|
|
1000
|
-
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
1001
|
-
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
1002
|
-
* @param options See {@link AdjustOptions}
|
|
704
|
+
* @param factor The factor to multiply the lightness with (>= 0, results are clamped)
|
|
1003
705
|
*/
|
|
1004
|
-
|
|
706
|
+
lightness(factor: number): this;
|
|
1005
707
|
/**
|
|
1006
|
-
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it
|
|
1007
|
-
* @param
|
|
1008
|
-
* @param absolute Whether to set the saturation (true) instead of scaling it (false)
|
|
1009
|
-
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
708
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it grayscale
|
|
709
|
+
* @param factor The factor to multiply the saturation with (>= 0, results are clamped)
|
|
1010
710
|
*/
|
|
1011
|
-
saturation(
|
|
711
|
+
saturation(factor: number): this;
|
|
1012
712
|
/**
|
|
1013
713
|
* Composites (overlays) the source onto this image
|
|
1014
714
|
* @param source The image to place
|
|
@@ -1016,29 +716,20 @@ export declare class Image {
|
|
|
1016
716
|
*/
|
|
1017
717
|
composite(source: Image, options?: CompositeOptions): this;
|
|
1018
718
|
/**
|
|
1019
|
-
*
|
|
1020
|
-
* @param source The image to place
|
|
1021
|
-
* @param [x=0] The x position to place the image at
|
|
1022
|
-
* @param [y=0] The y position to place the image at
|
|
1023
|
-
* @param options Opacity and blend mode, see {@link CompositeOptions}
|
|
1024
|
-
* @deprecated Pass {@link CompositeOptions} instead, the positional arguments will be removed in 4.0
|
|
1025
|
-
*/
|
|
1026
|
-
composite(source: Image, x?: number, y?: number, options?: CompositeOptions): this;
|
|
1027
|
-
/**
|
|
1028
|
-
* Inverts the images colors
|
|
719
|
+
* Inverts the image's colors
|
|
1029
720
|
*/
|
|
1030
721
|
invert(): this;
|
|
1031
722
|
/**
|
|
1032
|
-
* Inverts the
|
|
723
|
+
* Inverts the image's lightness (HSL), keeping hue and saturation: dark colors become light and vice versa
|
|
1033
724
|
*/
|
|
1034
725
|
invertLightness(): this;
|
|
1035
726
|
/**
|
|
1036
|
-
* Inverts the
|
|
727
|
+
* Inverts the image's value (HSV), keeping hue and saturation: the brightest channel `v` becomes `255 - v`
|
|
1037
728
|
* and the others scale along, black becomes white
|
|
1038
729
|
*/
|
|
1039
730
|
invertValue(): this;
|
|
1040
731
|
/**
|
|
1041
|
-
* Shifts the
|
|
732
|
+
* Shifts the image's hue
|
|
1042
733
|
* @param degrees How many degrees to shift the hue by
|
|
1043
734
|
*/
|
|
1044
735
|
hueShift(degrees: number): this;
|
|
@@ -1053,13 +744,13 @@ export declare class Image {
|
|
|
1053
744
|
* 0x8bac0fff, 0x9bbc0fff] })` for a Game Boy look. Transparent pixels (alpha 0) keep their color and don't count
|
|
1054
745
|
* towards the palette; the other pixels keep their alpha and only their RGB is reduced. The result is deterministic.
|
|
1055
746
|
* With a gain map (an HDR image), the HDR highlights are dropped, like {@link Image.invert} does: the map is neutral
|
|
1056
|
-
* afterwards
|
|
747
|
+
* afterwards
|
|
1057
748
|
* @param options See {@link QuantizeOptions}
|
|
1058
749
|
*/
|
|
1059
750
|
quantize(options?: QuantizeOptions): this;
|
|
1060
751
|
/**
|
|
1061
752
|
* Mixes the colors of every pixel with a color matrix, like SVG's `feColorMatrix`: the new red, green, blue and alpha
|
|
1062
|
-
* are each a sum of the old red, green, blue and alpha times a factor, plus an offset.
|
|
753
|
+
* are each a sum of the old red, green, blue and alpha times a factor, plus an offset. Grayscale, sepia, tints,
|
|
1063
754
|
* swapped channels, color blindness simulation or a mix of those in one pass.
|
|
1064
755
|
*
|
|
1065
756
|
* The values are 20 numbers, four rows of `[red, green, blue, alpha, offset]` for the new red, green, blue and alpha,
|
|
@@ -1088,19 +779,17 @@ export declare class Image {
|
|
|
1088
779
|
* @param matrix The six values [a, b, c, d, e, f]
|
|
1089
780
|
* @param options See {@link TransformOptions}
|
|
1090
781
|
*/
|
|
1091
|
-
transform(matrix:
|
|
782
|
+
transform(matrix: AffineTransform, options?: TransformOptions): this;
|
|
1092
783
|
/**
|
|
1093
784
|
* Adds a shadow behind the image, shaped by its alpha: a drop shadow with an offset, or a glow without one
|
|
1094
785
|
* (`image.dropShadow({ blur: 8, color: 0xff2fb9ff })`, with `spread` to make it stronger). The image grows to fit
|
|
1095
|
-
* the shadow, unless `expand` is `false
|
|
1096
|
-
* grow up and left as far as their offset allows
|
|
786
|
+
* the shadow, unless `expand` is `false`
|
|
1097
787
|
* @param options See {@link ShadowOptions}
|
|
1098
788
|
*/
|
|
1099
789
|
dropShadow(options?: ShadowOptions): this;
|
|
1100
790
|
/**
|
|
1101
791
|
* Draws an outline around the image's shape (its alpha): the sticker effect for cut-out images, or an outline for
|
|
1102
|
-
* text. The image grows to fit it, unless `expand` is `false
|
|
1103
|
-
* the growth), they only grow up and left as far as their offset allows
|
|
792
|
+
* text. The image grows to fit it, unless `expand` is `false`
|
|
1104
793
|
* @param options See {@link OutlineOptions}
|
|
1105
794
|
*/
|
|
1106
795
|
outline(options?: OutlineOptions): this;
|
|
@@ -1109,21 +798,14 @@ export declare class Image {
|
|
|
1109
798
|
* @param options See {@link SharpenOptions}
|
|
1110
799
|
*/
|
|
1111
800
|
sharpen(options?: SharpenOptions): this;
|
|
1112
|
-
/**
|
|
1113
|
-
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
1114
|
-
* @param [amount=1] How strongly to sharpen (0 does nothing)
|
|
1115
|
-
* @param [radius=1] The radius of the blur the image is compared with (larger values sharpen coarser details)
|
|
1116
|
-
* @deprecated Pass {@link SharpenOptions} instead, the positional arguments will be removed in 4.0
|
|
1117
|
-
*/
|
|
1118
|
-
sharpen(amount?: number, radius?: number): this;
|
|
1119
801
|
/**
|
|
1120
802
|
* Multiplies the color channels, e.g. 1.2 makes the image 20% brighter
|
|
1121
803
|
* @param factor The factor (>= 0, 1 keeps the image)
|
|
1122
804
|
*/
|
|
1123
805
|
brightness(factor: number): this;
|
|
1124
806
|
/**
|
|
1125
|
-
* Scales the color channels' distance from mid
|
|
1126
|
-
* @param factor The factor (>= 0, 1 keeps the image, 0 makes it
|
|
807
|
+
* Scales the color channels' distance from mid gray, e.g. 1.5 increases the contrast, 0.5 reduces it
|
|
808
|
+
* @param factor The factor (>= 0, 1 keeps the image, 0 makes it gray)
|
|
1127
809
|
*/
|
|
1128
810
|
contrast(factor: number): this;
|
|
1129
811
|
/**
|
|
@@ -1132,9 +814,9 @@ export declare class Image {
|
|
|
1132
814
|
*/
|
|
1133
815
|
gamma(gamma: number): this;
|
|
1134
816
|
/**
|
|
1135
|
-
* Converts the image to
|
|
817
|
+
* Converts the image to grayscale by its luma (ITU-R 601, like Pillow), keeping the alpha
|
|
1136
818
|
*/
|
|
1137
|
-
|
|
819
|
+
grayscale(): this;
|
|
1138
820
|
/**
|
|
1139
821
|
* Applies a sepia tone
|
|
1140
822
|
*/
|
|
@@ -1148,17 +830,6 @@ export declare class Image {
|
|
|
1148
830
|
* @param options See {@link ColorToAlphaOptions}
|
|
1149
831
|
*/
|
|
1150
832
|
colorToAlpha(options?: ColorToAlphaOptions): this;
|
|
1151
|
-
/**
|
|
1152
|
-
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
1153
|
-
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
1154
|
-
* semi-transparent instead of keeping a fringe of it.
|
|
1155
|
-
* The color is removed everywhere in the image, not only from a connected background: removing a white
|
|
1156
|
-
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
1157
|
-
* @param color The color to remove, by default the color of the top left pixel (e.g. a background)
|
|
1158
|
-
* @param options See {@link ColorToAlphaOptions}
|
|
1159
|
-
* @deprecated Pass {@link ColorToAlphaOptions} instead, the positional arguments will be removed in 4.0
|
|
1160
|
-
*/
|
|
1161
|
-
colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
|
|
1162
833
|
/**
|
|
1163
834
|
* Gets the average color of the image, weighting each pixel by its opacity
|
|
1164
835
|
* @returns The average color (fully opaque), black for fully transparent images
|
|
@@ -1173,158 +844,94 @@ export declare class Image {
|
|
|
1173
844
|
*/
|
|
1174
845
|
dominantColor(options?: DominantColorOptions): Color;
|
|
1175
846
|
/**
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* @
|
|
1179
|
-
* @param
|
|
1180
|
-
* @return The image's dominant color (fully opaque)
|
|
1181
|
-
* @deprecated Pass {@link DominantColorOptions} instead, the positional arguments will be removed in 4.0
|
|
1182
|
-
*/
|
|
1183
|
-
dominantColor(ignoreBlack?: boolean, ignoreWhite?: boolean, bwThreshold?: number): Color;
|
|
1184
|
-
/**
|
|
1185
|
-
* Rotates the image counterclockwise by the given amount of degrees
|
|
1186
|
-
* @param angle The angle to rotate the image for (in degrees)
|
|
847
|
+
* Rotates the image clockwise by the given angle in degrees (like CSS' `rotate()`; negative angles turn it
|
|
848
|
+
* counterclockwise). Multiples of 90° move whole pixels; other angles resample the image (see
|
|
849
|
+
* {@link RotateOptions.mode}) and, by default, grow it so the corners fit
|
|
850
|
+
* @param angle The angle in degrees, clockwise
|
|
1187
851
|
* @param options See {@link RotateOptions}
|
|
1188
852
|
*/
|
|
1189
853
|
rotate(angle: number, options?: RotateOptions): this;
|
|
1190
|
-
/**
|
|
1191
|
-
* Rotates the image counterclockwise by the given amount of degrees
|
|
1192
|
-
* @param angle The angle to rotate the image for (in degrees)
|
|
1193
|
-
* @param resize Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true`
|
|
1194
|
-
* @deprecated Pass {@link RotateOptions} instead, the positional arguments will be removed in 4.0
|
|
1195
|
-
*/
|
|
1196
|
-
rotate(angle: number, resize?: boolean): this;
|
|
1197
854
|
/**
|
|
1198
855
|
* Flips / mirrors the image horizontally or vertically
|
|
1199
856
|
* @param direction The direction to flip
|
|
1200
857
|
*/
|
|
1201
858
|
flip(direction: 'horizontal' | 'vertical'): this;
|
|
1202
859
|
/**
|
|
1203
|
-
* Rounds the
|
|
860
|
+
* Rounds the image's corners, with antialiased edges
|
|
1204
861
|
* @param options See {@link RoundCornersOptions}
|
|
1205
862
|
*/
|
|
1206
863
|
roundCorners(options?: RoundCornersOptions): this;
|
|
1207
|
-
/**
|
|
1208
|
-
* Rounds the images corners, with antialiased edges
|
|
1209
|
-
* @param [radius=min(width,height)/4] The radius of the corners
|
|
1210
|
-
* @deprecated Pass {@link RoundCornersOptions} instead, the positional arguments will be removed in 4.0
|
|
1211
|
-
*/
|
|
1212
|
-
roundCorners(radius?: number): this;
|
|
1213
864
|
/**
|
|
1214
865
|
* Applies a fisheye (barrel distortion) effect
|
|
1215
866
|
* @param options See {@link FisheyeOptions}
|
|
1216
867
|
*/
|
|
1217
868
|
fisheye(options?: FisheyeOptions): this;
|
|
1218
|
-
/**
|
|
1219
|
-
* Applies a fisheye (barrel distortion) effect
|
|
1220
|
-
* @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
|
|
1221
|
-
* @deprecated Pass {@link FisheyeOptions} instead, the positional arguments will be removed in 4.0
|
|
1222
|
-
*/
|
|
1223
|
-
fisheye(strength?: number): this;
|
|
1224
869
|
/**
|
|
1225
870
|
* Encodes the image into a PNG, with the smallest lossless color type (a palette for up to 256 colors,
|
|
1226
|
-
*
|
|
1227
|
-
* @param options See {@link PNGEncodeOptions}
|
|
1228
|
-
* @return The encoded data
|
|
1229
|
-
*/
|
|
1230
|
-
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
1231
|
-
/**
|
|
1232
|
-
* Encodes the image into a PNG
|
|
1233
|
-
* @param compression The compression level (0-9). Default: `4`
|
|
1234
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1235
|
-
* @return The encoded data
|
|
1236
|
-
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1237
|
-
*/
|
|
1238
|
-
encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
1239
|
-
/**
|
|
1240
|
-
* Encodes the image into a PNG with compression level 4
|
|
1241
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1242
|
-
* @return The encoded data
|
|
1243
|
-
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1244
|
-
*/
|
|
1245
|
-
encodePNG(metadata?: Metadata): Promise<Uint8Array>;
|
|
1246
|
-
/**
|
|
1247
|
-
* Encodes the image into a PNG
|
|
871
|
+
* grayscale or RGB, alpha only if needed). Uses the runtime's native zlib when available
|
|
1248
872
|
* @param options See {@link PNGEncodeOptions}
|
|
1249
873
|
* @return The encoded data
|
|
1250
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1251
|
-
* @group Deprecated
|
|
1252
874
|
*/
|
|
1253
|
-
|
|
875
|
+
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1254
876
|
/**
|
|
1255
|
-
* Encodes the image into a
|
|
1256
|
-
*
|
|
1257
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1258
|
-
* @return The encoded data
|
|
1259
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1260
|
-
* @group Deprecated
|
|
1261
|
-
*/
|
|
1262
|
-
encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
1263
|
-
/**
|
|
1264
|
-
* Encodes the image into a PNG with compression level 4
|
|
1265
|
-
* @param metadata Metadata to include, see {@link Metadata}
|
|
1266
|
-
* @return The encoded data
|
|
1267
|
-
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1268
|
-
* @group Deprecated
|
|
1269
|
-
*/
|
|
1270
|
-
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
1271
|
-
/**
|
|
1272
|
-
* Encodes the image into a JPEG
|
|
877
|
+
* Encodes the image into a JPEG. JPEG has no transparency: an image with transparent or translucent pixels is
|
|
878
|
+
* composited onto the `background` color (black by default) first, the image itself stays unchanged
|
|
1273
879
|
* @param options See {@link JPEGEncodeOptions}
|
|
1274
880
|
*/
|
|
1275
|
-
encodeJPEG(options?: JPEGEncodeOptions): Promise<Uint8Array
|
|
1276
|
-
/**
|
|
1277
|
-
* Encodes the image into a JPEG
|
|
1278
|
-
* @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
|
|
1279
|
-
* @deprecated Pass {@link JPEGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
1280
|
-
*/
|
|
1281
|
-
encodeJPEG(quality?: number): Promise<Uint8Array>;
|
|
881
|
+
encodeJPEG(options?: JPEGEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1282
882
|
/**
|
|
1283
883
|
* Encodes the image as WebP: lossless (usually 20-30% smaller than PNG, but slower to encode), or lossy with a
|
|
1284
884
|
* quality
|
|
1285
885
|
* @param options See {@link WebPEncodeOptions}
|
|
1286
886
|
*/
|
|
1287
|
-
encodeWebP(
|
|
887
|
+
encodeWebP(options?: WebPEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1288
888
|
/**
|
|
1289
889
|
* Encodes the image as run length encoded TGA (32 bit, or 24 bit if the image is opaque)
|
|
1290
|
-
* @param options See {@link
|
|
890
|
+
* @param options See {@link TGAEncodeOptions}
|
|
1291
891
|
*/
|
|
1292
|
-
encodeTGA(
|
|
892
|
+
encodeTGA(options?: TGAEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
893
|
+
/**
|
|
894
|
+
* Encodes the image as a GIF (one frame): at most 256 colors, transparency only on or off (pixels with an alpha below
|
|
895
|
+
* 128 become transparent). For animations, see {@link Animation.encodeGIF}
|
|
896
|
+
* @param options The palette size, the dithering and the metadata, see {@link GIFEncodeOptions}
|
|
897
|
+
*/
|
|
898
|
+
encodeGIF(options?: GIFEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1293
899
|
/**
|
|
1294
900
|
* Encodes the image as BMP: with a palette if it is opaque and has at most 256 colors, else with 24 bit pixels, or
|
|
1295
901
|
* 32 bit ones if it has transparency
|
|
1296
902
|
*/
|
|
1297
|
-
encodeBMP(): Promise<Uint8Array
|
|
903
|
+
encodeBMP(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1298
904
|
/**
|
|
1299
905
|
* Encodes the image as QOI (3 channels if the image is opaque)
|
|
1300
906
|
*/
|
|
1301
|
-
encodeQOI(): Promise<Uint8Array
|
|
907
|
+
encodeQOI(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1302
908
|
/**
|
|
1303
909
|
* Encodes the image as AVIF (AV1, with an alpha image if the image has transparency)
|
|
1304
910
|
* @param options See {@link AVIFEncodeOptions}
|
|
1305
911
|
*/
|
|
1306
|
-
encodeAVIF(
|
|
912
|
+
encodeAVIF(options?: AVIFEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1307
913
|
/**
|
|
1308
914
|
* Encodes the image as JPEG XL: losslessly (the default) like libjxl's `cjxl -e 3` (a palette of up to 1024 colors,
|
|
1309
915
|
* else palettes of channels using few of their values; YCoCg; the weighted predictor in contexts of its error;
|
|
1310
|
-
*
|
|
916
|
+
* grayscale if the image is), at effort 0 the codestream byte for byte like `cjxl -e 1` on CPUs with AVX2 or NEON
|
|
1311
917
|
* (its fast lossless mode: the gradient predictor, a palette if the image has at most 511 colors besides black,
|
|
1312
918
|
* else YCoCg), or lossy with a quality (like `cjxl -q`: XYB, varblocks of libjxl's search, chroma from luma, the
|
|
1313
919
|
* edge preserving filter). Alpha (if the image has transparency) is lossless either way. The codestream is in the
|
|
1314
920
|
* container, with the metadata as Exif
|
|
1315
921
|
* @param options See {@link JXLEncodeOptions}
|
|
1316
922
|
*/
|
|
1317
|
-
encodeJXL(
|
|
923
|
+
encodeJXL(options?: JXLEncodeOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
1318
924
|
/**
|
|
1319
|
-
* Encodes the image as the smallest fitting Netpbm format: PBM for black and white images, PGM for
|
|
925
|
+
* Encodes the image as the smallest fitting Netpbm format: PBM for black and white images, PGM for grayscale ones,
|
|
1320
926
|
* PPM for others, PAM if the image has transparency
|
|
1321
927
|
*/
|
|
1322
|
-
encodePNM(): Promise<Uint8Array
|
|
928
|
+
encodePNM(): Promise<Uint8Array<ArrayBuffer>>;
|
|
1323
929
|
/**
|
|
1324
930
|
* Decodes an image (PNG, JPEG, TIFF, WebP, BMP, ICO, CUR, QOI, PBM, PGM, PPM, PAM, PFM, Radiance HDR, TGA, AVIF or
|
|
1325
|
-
* JPEG XL). For
|
|
1326
|
-
* {@link Animation.decode}
|
|
1327
|
-
*
|
|
931
|
+
* JPEG XL). For animations (GIFs, animated WebPs, AVIF image sequences, JPEG XL animations) this is the first frame,
|
|
932
|
+
* composed onto the canvas as {@link Animation.decode} has it, and decoding stops after it: use
|
|
933
|
+
* {@link Animation.decode} for all frames. For APNGs this is the default image, which is what viewers without APNG
|
|
934
|
+
* support show; for icons and cursors it's their largest image
|
|
1328
935
|
* @param input The binary data to decode
|
|
1329
936
|
* @param options See {@link DecodeOptions}. JPEGs, TIFFs and PNGs are rotated/mirrored as their orientation tag
|
|
1330
937
|
* (Exif, for PNGs also XMP) says by default: photos taken with a rotated camera are stored sideways
|
|
@@ -1332,26 +939,11 @@ export declare class Image {
|
|
|
1332
939
|
*/
|
|
1333
940
|
static decode(input: BinaryData, options?: DecodeOptions): Promise<Image>;
|
|
1334
941
|
/**
|
|
1335
|
-
*
|
|
1336
|
-
* @group Deprecated
|
|
1337
|
-
*/
|
|
1338
|
-
static readonly SVG_MODE_SCALE = 1;
|
|
1339
|
-
/**
|
|
1340
|
-
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1341
|
-
* @group Deprecated
|
|
1342
|
-
*/
|
|
1343
|
-
static readonly SVG_MODE_WIDTH = 2;
|
|
1344
|
-
/**
|
|
1345
|
-
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1346
|
-
* @group Deprecated
|
|
1347
|
-
*/
|
|
1348
|
-
static readonly SVG_MODE_HEIGHT = 3;
|
|
1349
|
-
/**
|
|
1350
|
-
* Creates a new image from the given SVG
|
|
942
|
+
* Creates a new image from the given SVG.
|
|
1351
943
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
1352
944
|
* masks, opacity, blend modes, filters (all primitives and the filter functions) and images embedded as data URIs
|
|
1353
|
-
* (PNG, JPEG, GIF, WebP, SVG) or given with {@link
|
|
1354
|
-
* (see {@link
|
|
945
|
+
* (PNG, JPEG, GIF, WebP, SVG) or given with {@link RenderSVGOptions.images}, and text with the given or embedded fonts
|
|
946
|
+
* (see {@link RenderSVGOptions.fonts}). Hrefs are resolved from the options and the data URIs only, never from files or URLs.
|
|
1355
947
|
* @example
|
|
1356
948
|
* ```ts
|
|
1357
949
|
* const logo = await Image.renderSVG(
|
|
@@ -1360,19 +952,10 @@ export declare class Image {
|
|
|
1360
952
|
* );
|
|
1361
953
|
* ```
|
|
1362
954
|
* @param svg The SVG content
|
|
1363
|
-
* @param options See {@link
|
|
955
|
+
* @param options See {@link RenderSVGOptions}
|
|
1364
956
|
* @return The rendered SVG graphic
|
|
1365
957
|
*/
|
|
1366
|
-
static renderSVG(svg: string | BinaryData, options?:
|
|
1367
|
-
/**
|
|
1368
|
-
* Creates a new image from the given SVG
|
|
1369
|
-
* @param svg The SVG content
|
|
1370
|
-
* @param size The size to use
|
|
1371
|
-
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
1372
|
-
* @return The rendered SVG graphic
|
|
1373
|
-
* @deprecated Pass {@link SVGOptions} instead, the positional arguments will be removed in 4.0
|
|
1374
|
-
*/
|
|
1375
|
-
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|
|
958
|
+
static renderSVG(svg: string | BinaryData, options?: RenderSVGOptions): Promise<Image>;
|
|
1376
959
|
/**
|
|
1377
960
|
* Creates a new image containing the rendered text.
|
|
1378
961
|
* @param text Text to render
|
|
@@ -1381,37 +964,9 @@ export declare class Image {
|
|
|
1381
964
|
* @return The rendered text
|
|
1382
965
|
*/
|
|
1383
966
|
static renderText(text: string, options: RenderTextOptions): Promise<Image>;
|
|
1384
|
-
/**
|
|
1385
|
-
* Creates a new image containing the rendered text.
|
|
1386
|
-
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
1387
|
-
* character comes from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height.
|
|
1388
|
-
* Color glyphs (COLR layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any
|
|
1389
|
-
* script is shaped like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts,
|
|
1390
|
-
* marks)
|
|
1391
|
-
* @param size Font size in pixels (per em)
|
|
1392
|
-
* @param text Text to render
|
|
1393
|
-
* @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
|
|
1394
|
-
* side
|
|
1395
|
-
* @return The rendered text
|
|
1396
|
-
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1397
|
-
* This signature will be removed in 4.0
|
|
1398
|
-
*/
|
|
1399
|
-
static renderText(font: BinaryData | BinaryData[], size: number, text: string, options?: TextOptions): Promise<Image>;
|
|
1400
|
-
/**
|
|
1401
|
-
* Creates a new image containing the rendered text.
|
|
1402
|
-
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
1403
|
-
* character comes from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height.
|
|
1404
|
-
* Color glyphs (COLR layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any
|
|
1405
|
-
* script is shaped like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts,
|
|
1406
|
-
* marks)
|
|
1407
|
-
* @param size Font size in pixels (per em)
|
|
1408
|
-
* @param text Text to render
|
|
1409
|
-
* @param [color=0xffffffff] Text color to use
|
|
1410
|
-
* @param [layout] The text layout to use
|
|
1411
|
-
* @param style Outline, see {@link TextStyle}; the image grows by the outline width on every side
|
|
1412
|
-
* @return The rendered text
|
|
1413
|
-
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1414
|
-
* This signature will be removed in 4.0
|
|
1415
|
-
*/
|
|
1416
|
-
static renderText(font: BinaryData | BinaryData[], size: number, text: string, color?: Color, layout?: TextLayout, style?: TextStyle): Promise<Image>;
|
|
1417
967
|
}
|
|
968
|
+
/**
|
|
969
|
+
* The size of an image of `width` x `height` resized to fit inside a box of `boxWidth` x `boxHeight`, keeping its aspect
|
|
970
|
+
* ratio: the limiting side matches the box exactly (rounded instead of floored), the other one is at least 1 pixel
|
|
971
|
+
*/
|
|
972
|
+
export declare function insideSize(width: number, height: number, boxWidth: number, boxHeight: number): [width: number, height: number];
|