imagescript 3.16.1 → 3.18.0
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 +4 -4
- package/dist/animation-encoder.d.ts +37 -36
- package/dist/animation-encoder.js +8 -5
- package/dist/animation.d.ts +61 -14
- package/dist/animation.js +51 -19
- package/dist/codecs/gif.js +1 -1
- package/dist/codecs/jxl.js +1 -1
- package/dist/codecs/png.js +3 -2
- package/dist/codecs/webp.js +6 -2
- package/dist/colors.d.ts +79 -0
- package/dist/colors.js +161 -0
- package/dist/frame.d.ts +80 -15
- package/dist/frame.js +17 -16
- package/dist/gainmap.d.ts +16 -0
- package/dist/gainmap.js +3 -2
- package/dist/gif.d.ts +2 -1
- package/dist/image-type.d.ts +52 -13
- package/dist/image.d.ts +322 -119
- package/dist/image.js +115 -195
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/render/svg.js +2 -2
- package/dist/text-layout.d.ts +4 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/image.d.ts
CHANGED
|
@@ -1,16 +1,63 @@
|
|
|
1
1
|
import type { ToneMapping } from './codecs/hdr.js';
|
|
2
2
|
import { BinaryData } from './util/mem.js';
|
|
3
|
-
import { TextLayout } from './text-layout.js';
|
|
3
|
+
import { TextLayout, 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`) */
|
|
7
7
|
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
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Resampling filters for {@link Image.resize} and the other scaling functions, see {@link ResizeModes}.
|
|
12
|
+
* The upper case names (`'RESIZE_BILINEAR'`, the values of the deprecated `Image.RESIZE_*`) still work, they are
|
|
13
|
+
* removed in 4.0
|
|
14
|
+
*/
|
|
15
|
+
export type ResizeMode = 'nearest-neighbor' | 'bilinear' | 'bicubic' | 'area' | 'RESIZE_NEAREST_NEIGHBOR' | 'RESIZE_BILINEAR' | 'RESIZE_BICUBIC' | 'RESIZE_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
|
+
}
|
|
14
61
|
/** Blend modes of {@link Image.composite}, named like CSS' mix-blend-mode values */
|
|
15
62
|
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'add';
|
|
16
63
|
/** Options of {@link Image.composite} */
|
|
@@ -24,16 +71,26 @@ export interface CompositeOptions {
|
|
|
24
71
|
/** How the colors are mixed. Default: `'normal'` */
|
|
25
72
|
mode?: BlendMode;
|
|
26
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The size for {@link Image.resize}, {@link Frame.resize} and {@link Animation.resize}, and how to resize: a side
|
|
76
|
+
* that is missing follows from the other one, keeping the aspect ratio
|
|
77
|
+
*/
|
|
78
|
+
export interface ResizeToOptions extends ResizeOptions {
|
|
79
|
+
/** The new width. Without it, it follows from the height */
|
|
80
|
+
width?: number;
|
|
81
|
+
/** The new height. Without it, it follows from the width */
|
|
82
|
+
height?: number;
|
|
83
|
+
}
|
|
27
84
|
/** Options of {@link Image.scale}, {@link Image.resize}, {@link Image.contain}, {@link Image.fit} and {@link Image.cover} */
|
|
28
85
|
export interface ResizeOptions {
|
|
29
|
-
/** The resizing mode. Default: {@link
|
|
86
|
+
/** The resizing mode. Default: {@link ResizeModes.BILINEAR} */
|
|
30
87
|
mode?: ResizeMode;
|
|
31
88
|
/**
|
|
32
89
|
* Whether to round to 8 bits between the two passes, so two channels share the multiplications of both: about
|
|
33
90
|
* 15-25% faster for opaque images, with 10-25% of the channel values a step off the precise result (instead of
|
|
34
91
|
* about 1%, never more than 1). Transparent images are premultiplied to 8 bits like browsers do, which makes them
|
|
35
92
|
* about twice as fast: what shows once they're composited differs by up to about 2 steps, pixels that are almost
|
|
36
|
-
* transparent keep less of their color. Only affects {@link
|
|
93
|
+
* transparent keep less of their color. Only affects {@link ResizeModes.BILINEAR} and {@link ResizeModes.AREA},
|
|
37
94
|
* down to about a third of the size. Default: `true`
|
|
38
95
|
*/
|
|
39
96
|
fast?: boolean;
|
|
@@ -43,7 +100,10 @@ export interface ResizeOptions {
|
|
|
43
100
|
* and {@link Image.saturation}
|
|
44
101
|
*/
|
|
45
102
|
export interface AdjustOptions {
|
|
46
|
-
/**
|
|
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
|
+
*/
|
|
47
107
|
absolute?: boolean;
|
|
48
108
|
}
|
|
49
109
|
/** Options of {@link Image.sharpen} */
|
|
@@ -67,12 +127,13 @@ export interface JPEGEncodeOptions {
|
|
|
67
127
|
/** Metadata to include, see {@link Metadata} */
|
|
68
128
|
metadata?: Metadata;
|
|
69
129
|
/**
|
|
70
|
-
* Whether to write the image's {@link Image.gainMap} (an Ultra HDR JPEG, brighter on HDR displays), or how
|
|
71
|
-
*
|
|
72
|
-
* map's size). Default: `true` (written if there is one)
|
|
130
|
+
* Whether to write the image's {@link Image.gainMap} (an Ultra HDR JPEG, brighter on HDR displays), or how.
|
|
131
|
+
* Default: `true` (written if there is one)
|
|
73
132
|
*/
|
|
74
133
|
gainMap?: boolean | {
|
|
134
|
+
/** The map's JPEG quality (1-100). Default: `90` */
|
|
75
135
|
quality?: number;
|
|
136
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
76
137
|
scale?: number;
|
|
77
138
|
};
|
|
78
139
|
}
|
|
@@ -135,8 +196,8 @@ export interface SVGOptions {
|
|
|
135
196
|
/** The scale, or the width or height in pixels, see `mode`. Default: `1` */
|
|
136
197
|
size?: number;
|
|
137
198
|
/**
|
|
138
|
-
* What `size` is: one of {@link
|
|
139
|
-
* Default: {@link
|
|
199
|
+
* What `size` is: one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT}.
|
|
200
|
+
* Default: {@link SVGScaleModes.SCALE}
|
|
140
201
|
*/
|
|
141
202
|
mode?: SVGScaleMode;
|
|
142
203
|
/**
|
|
@@ -156,6 +217,22 @@ export interface TextOptions extends TextStyle {
|
|
|
156
217
|
/** The text layout. Default: `new TextLayout()` */
|
|
157
218
|
layout?: TextLayout;
|
|
158
219
|
}
|
|
220
|
+
/** Options of {@link Image.renderText}: the font and size, the text color and layout, and its style (see {@link TextStyle}) */
|
|
221
|
+
export interface RenderTextOptions extends TextStyle {
|
|
222
|
+
/**
|
|
223
|
+
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every character comes
|
|
224
|
+
* from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height. Color glyphs (COLR
|
|
225
|
+
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any script is shaped
|
|
226
|
+
* like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts, marks)
|
|
227
|
+
*/
|
|
228
|
+
font: BinaryData | BinaryData[];
|
|
229
|
+
/** Font size in pixels (per em) */
|
|
230
|
+
size: number;
|
|
231
|
+
/** The text color. Default: `0xffffffff` */
|
|
232
|
+
color?: Color;
|
|
233
|
+
/** The text layout, as {@link TextLayoutOptions} or a {@link TextLayout}. Default: the defaults of `TextLayout` */
|
|
234
|
+
layout?: TextLayoutOptions | TextLayout;
|
|
235
|
+
}
|
|
159
236
|
/** Options of {@link Image.decode} */
|
|
160
237
|
export interface DecodeOptions {
|
|
161
238
|
/** Whether to rotate/mirror JPEGs, TIFFs, PNGs and WebPs as their orientation tag (Exif or XMP) says. Default: `true` */
|
|
@@ -221,12 +298,13 @@ export interface JXLEncodeOptions {
|
|
|
221
298
|
/** Metadata to include, see {@link Metadata} */
|
|
222
299
|
metadata?: Metadata;
|
|
223
300
|
/**
|
|
224
|
-
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a jhgm box, like libjxl's), or how
|
|
225
|
-
* `
|
|
226
|
-
* its own). Default: `true`
|
|
301
|
+
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a jhgm box, like libjxl's), or how.
|
|
302
|
+
* Default: `true` (written if there is one)
|
|
227
303
|
*/
|
|
228
304
|
gainMap?: boolean | {
|
|
305
|
+
/** The map's quality (1-100 like `quality`, 100 lossless). Default: `90` */
|
|
229
306
|
quality?: number;
|
|
307
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
230
308
|
scale?: number;
|
|
231
309
|
};
|
|
232
310
|
}
|
|
@@ -251,11 +329,12 @@ export interface AVIFEncodeOptions {
|
|
|
251
329
|
metadata?: Metadata;
|
|
252
330
|
/**
|
|
253
331
|
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a tone mapped item, like libavif
|
|
254
|
-
* writes), or how: `
|
|
255
|
-
* Default: `true`
|
|
332
|
+
* writes), or how. Default: `true` (written if there is one)
|
|
256
333
|
*/
|
|
257
334
|
gainMap?: boolean | {
|
|
335
|
+
/** The map's quality (1-100). Default: `90` */
|
|
258
336
|
quality?: number;
|
|
337
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
259
338
|
scale?: number;
|
|
260
339
|
};
|
|
261
340
|
}
|
|
@@ -289,7 +368,16 @@ export interface TextStyle {
|
|
|
289
368
|
}
|
|
290
369
|
/** Options of {@link Image.cropCircle} */
|
|
291
370
|
export interface CropCircleOptions {
|
|
292
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* The circle's size: `'contain'` fits it inside the image (the smaller dimension is its diameter, no hard edges),
|
|
373
|
+
* `'cover'` covers the image (the larger dimension is its diameter, the corners of a rectangular image stay
|
|
374
|
+
* transparent on the shorter side). Default: `'contain'`
|
|
375
|
+
*/
|
|
376
|
+
size?: 'contain' | 'cover';
|
|
377
|
+
/**
|
|
378
|
+
* Whether to use the larger dimension for the size. Default: `false`
|
|
379
|
+
* @deprecated Use `size: 'cover'` (`true`) or `size: 'contain'` (`false`), `max` will be removed in 4.0
|
|
380
|
+
*/
|
|
293
381
|
max?: boolean;
|
|
294
382
|
/** Share of the radius (0..1) over which the edge fades out. Default: `0` */
|
|
295
383
|
feathering?: number;
|
|
@@ -317,6 +405,11 @@ export interface RotateOptions {
|
|
|
317
405
|
}
|
|
318
406
|
/** Options of {@link Image.trim} */
|
|
319
407
|
export interface TrimOptions {
|
|
408
|
+
/**
|
|
409
|
+
* The border color, by default the color of the top left pixel. Fully transparent pixels count as the same color
|
|
410
|
+
* whatever their RGB values
|
|
411
|
+
*/
|
|
412
|
+
color?: Color;
|
|
320
413
|
/**
|
|
321
414
|
* How far (0-1) a pixel's channels may be from the color for it to be trimmed, e.g. for JPEG artifacts or
|
|
322
415
|
* antialiasing. Default: `0`
|
|
@@ -325,6 +418,8 @@ export interface TrimOptions {
|
|
|
325
418
|
}
|
|
326
419
|
/** Options of {@link Image.colorToAlpha} */
|
|
327
420
|
export interface ColorToAlphaOptions {
|
|
421
|
+
/** The color to remove, by default the color of the top left pixel (e.g. a background) */
|
|
422
|
+
color?: Color;
|
|
328
423
|
/** Pixels at most this far from the color (0-1) become fully transparent. Default: 0 */
|
|
329
424
|
transparencyThreshold?: number;
|
|
330
425
|
/** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
|
|
@@ -333,6 +428,7 @@ export interface ColorToAlphaOptions {
|
|
|
333
428
|
/**
|
|
334
429
|
* Text metadata written into PNGs
|
|
335
430
|
* @deprecated Use {@link Metadata}, which all encoders take
|
|
431
|
+
* @group Deprecated
|
|
336
432
|
*/
|
|
337
433
|
export type PNGMetadata = Metadata;
|
|
338
434
|
/**
|
|
@@ -341,9 +437,9 @@ export type PNGMetadata = Metadata;
|
|
|
341
437
|
*/
|
|
342
438
|
export declare class Image {
|
|
343
439
|
/**
|
|
344
|
-
* Creates a new image with the given dimensions
|
|
345
|
-
* @param width
|
|
346
|
-
* @param height
|
|
440
|
+
* Creates a new image with the given dimensions, all pixels transparent black
|
|
441
|
+
* @param width The width in pixels
|
|
442
|
+
* @param height The height in pixels
|
|
347
443
|
*/
|
|
348
444
|
constructor(width: number, height: number);
|
|
349
445
|
/**
|
|
@@ -351,13 +447,20 @@ export declare class Image {
|
|
|
351
447
|
* displays. {@link Image.encodeJPEG} writes it. `null` removes it
|
|
352
448
|
*/
|
|
353
449
|
get gainMap(): GainMap | null;
|
|
450
|
+
/**
|
|
451
|
+
* Replaces the gain map
|
|
452
|
+
* @param gainMap The new gain map, or `null` to remove it
|
|
453
|
+
*/
|
|
354
454
|
set gainMap(gainMap: GainMap | null);
|
|
355
455
|
/**
|
|
356
456
|
* The image's RGBA pixel data. It can be replaced by any 8-bit array with width * height * 4 bytes
|
|
357
457
|
* (it is used as is, without copying)
|
|
358
458
|
*/
|
|
359
459
|
get bitmap(): Uint8ClampedArray;
|
|
360
|
-
/**
|
|
460
|
+
/**
|
|
461
|
+
* Replaces the pixel data
|
|
462
|
+
* @param bitmap The new RGBA data, width * height * 4 bytes (used as is, without copying)
|
|
463
|
+
*/
|
|
361
464
|
set bitmap(bitmap: Uint8ClampedArray | Uint8Array);
|
|
362
465
|
/** A short description for debugging, e.g. `Image<64x64>` */
|
|
363
466
|
toString(): string;
|
|
@@ -369,14 +472,28 @@ export declare class Image {
|
|
|
369
472
|
* The images height
|
|
370
473
|
*/
|
|
371
474
|
get height(): number;
|
|
475
|
+
/**
|
|
476
|
+
* Yields an [x, y] array for every pixel in the image (0-based), row by row
|
|
477
|
+
* @yields The coordinates of the pixel ([x, y])
|
|
478
|
+
*/
|
|
479
|
+
coordinates(): Generator<[x: number, y: number], void, undefined>;
|
|
480
|
+
/**
|
|
481
|
+
* Yields an [x, y, color] array for every pixel in the image (0-based), row by row
|
|
482
|
+
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
483
|
+
*/
|
|
484
|
+
pixels(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
372
485
|
/**
|
|
373
486
|
* Yields an [x, y] array for every pixel in the image (0-based)
|
|
374
487
|
* @yields The coordinates of the pixel ([x, y])
|
|
488
|
+
* @deprecated Use {@link Image.coordinates}, iterating over the image will be removed in 4.0
|
|
489
|
+
* @group Deprecated
|
|
375
490
|
*/
|
|
376
491
|
[Symbol.iterator](): Generator<[x: number, y: number], void, undefined>;
|
|
377
492
|
/**
|
|
378
493
|
* Yields an [x, y, color] array for every pixel in the image (0-based)
|
|
379
494
|
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
495
|
+
* @deprecated Use {@link Image.pixels}, `iterateWithColors()` will be removed in 4.0
|
|
496
|
+
* @group Deprecated
|
|
380
497
|
*/
|
|
381
498
|
iterateWithColors(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
382
499
|
/**
|
|
@@ -385,7 +502,8 @@ export declare class Image {
|
|
|
385
502
|
* @param g green (0..255)
|
|
386
503
|
* @param b blue (0..255)
|
|
387
504
|
* @param a alpha (0..255)
|
|
388
|
-
* @
|
|
505
|
+
* @deprecated Use {@link Colors.fromRGBA}, `Image.rgbaToColor` will be removed in 4.0
|
|
506
|
+
* @group Deprecated
|
|
389
507
|
*/
|
|
390
508
|
static rgbaToColor(r: number, g: number, b: number, a: number): Color;
|
|
391
509
|
/**
|
|
@@ -393,7 +511,8 @@ export declare class Image {
|
|
|
393
511
|
* @param r red (0..255)
|
|
394
512
|
* @param g green (0..255)
|
|
395
513
|
* @param b blue (0..255)
|
|
396
|
-
* @
|
|
514
|
+
* @deprecated Use {@link Colors.fromRGB}, `Image.rgbToColor` will be removed in 4.0
|
|
515
|
+
* @group Deprecated
|
|
397
516
|
*/
|
|
398
517
|
static rgbToColor(r: number, g: number, b: number): Color;
|
|
399
518
|
/**
|
|
@@ -402,7 +521,8 @@ export declare class Image {
|
|
|
402
521
|
* @param s saturation (0..1)
|
|
403
522
|
* @param l lightness (0..1)
|
|
404
523
|
* @param a opacity (0..1)
|
|
405
|
-
* @
|
|
524
|
+
* @deprecated Use {@link Colors.fromHSLA}, `Image.hslaToColor` will be removed in 4.0
|
|
525
|
+
* @group Deprecated
|
|
406
526
|
*/
|
|
407
527
|
static hslaToColor(h: number, s: number, l: number, a: number): Color;
|
|
408
528
|
/**
|
|
@@ -410,60 +530,65 @@ export declare class Image {
|
|
|
410
530
|
* @param h hue (0..1)
|
|
411
531
|
* @param s saturation (0..1)
|
|
412
532
|
* @param l lightness (0..1)
|
|
413
|
-
* @
|
|
533
|
+
* @deprecated Use {@link Colors.fromHSL}, `Image.hslToColor` will be removed in 4.0
|
|
534
|
+
* @group Deprecated
|
|
414
535
|
*/
|
|
415
536
|
static hslToColor(h: number, s: number, l: number): Color;
|
|
416
537
|
/**
|
|
417
538
|
* Converts an RGBA value to an array of HSLA values
|
|
418
|
-
* @param r
|
|
419
|
-
* @param g
|
|
420
|
-
* @param b
|
|
421
|
-
* @param a
|
|
422
|
-
* @
|
|
539
|
+
* @param r red (0..255)
|
|
540
|
+
* @param g green (0..255)
|
|
541
|
+
* @param b blue (0..255)
|
|
542
|
+
* @param a alpha (0..255)
|
|
543
|
+
* @deprecated Use {@link Colors.toHSLA}, `Image.rgbaToHSLA` will be removed in 4.0
|
|
544
|
+
* @group Deprecated
|
|
423
545
|
*/
|
|
424
546
|
static rgbaToHSLA(r: number, g: number, b: number, a: number): [h: number, s: number, l: number, a: number];
|
|
425
547
|
/**
|
|
426
548
|
* Converts a color value to an array of RGBA values
|
|
427
549
|
* @param color The color value to convert
|
|
428
|
-
* @
|
|
550
|
+
* @deprecated Use {@link Colors.toRGBA}, `Image.colorToRGBA` will be removed in 4.0
|
|
551
|
+
* @group Deprecated
|
|
429
552
|
*/
|
|
430
553
|
static colorToRGBA(color: Color): [r: number, g: number, b: number, a: number];
|
|
431
554
|
/**
|
|
432
555
|
* Converts a color value to an array of RGB values (ignoring the colors alpha)
|
|
433
556
|
* @param color The color value to convert
|
|
434
|
-
* @
|
|
557
|
+
* @deprecated Use {@link Colors.toRGB}, `Image.colorToRGB` will be removed in 4.0
|
|
558
|
+
* @group Deprecated
|
|
435
559
|
*/
|
|
436
560
|
static colorToRGB(color: Color): [r: number, g: number, b: number];
|
|
561
|
+
/**
|
|
562
|
+
* Creates a multi-point gradient generator
|
|
563
|
+
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
564
|
+
* @deprecated Use {@link Colors.gradient}, `Image.gradient` will be removed in 4.0
|
|
565
|
+
* @group Deprecated
|
|
566
|
+
*/
|
|
567
|
+
static gradient(colors: Record<number, Color>): (position: number) => Color;
|
|
437
568
|
/**
|
|
438
569
|
* Gets the pixel color at the specified position (0-based)
|
|
439
|
-
* @param x
|
|
440
|
-
* @param y
|
|
441
|
-
* @returns The color value
|
|
570
|
+
* @param x The x coordinate
|
|
571
|
+
* @param y The y coordinate
|
|
572
|
+
* @returns The color value (`0xRRGGBBAA`)
|
|
442
573
|
*/
|
|
443
574
|
getPixelAt(x: number, y: number): Color;
|
|
444
575
|
/**
|
|
445
576
|
* Gets a view of the RGBA components of the pixel at the specified position (0-based)
|
|
446
|
-
* @param x
|
|
447
|
-
* @param y
|
|
448
|
-
* @returns The
|
|
577
|
+
* @param x The x coordinate
|
|
578
|
+
* @param y The y coordinate
|
|
579
|
+
* @returns The pixel's 4 bytes in {@link Image.bitmap}: writing to them changes the pixel
|
|
449
580
|
*/
|
|
450
581
|
getRGBAAt(x: number, y: number): Uint8ClampedArray;
|
|
451
582
|
/**
|
|
452
583
|
* Sets the pixel color for the specified position (0-based)
|
|
453
|
-
* @param x
|
|
454
|
-
* @param y
|
|
455
|
-
* @param pixelColor
|
|
584
|
+
* @param x The x coordinate
|
|
585
|
+
* @param y The y coordinate
|
|
586
|
+
* @param pixelColor The new color (`0xRRGGBBAA`)
|
|
456
587
|
*/
|
|
457
588
|
setPixelAt(x: number, y: number, pixelColor: Color): this;
|
|
458
|
-
/**
|
|
459
|
-
* @callback colorFunction
|
|
460
|
-
* @param x 0-based x coordinate
|
|
461
|
-
* @param y 0-based y coordinate
|
|
462
|
-
* @returns pixel color
|
|
463
|
-
*/
|
|
464
589
|
/**
|
|
465
590
|
* Fills the image data with the supplied color
|
|
466
|
-
* @param color
|
|
591
|
+
* @param color The color, or a function returning the color of each pixel
|
|
467
592
|
*/
|
|
468
593
|
fill(color: Color | ColorFunction): this;
|
|
469
594
|
/**
|
|
@@ -471,25 +596,31 @@ export declare class Image {
|
|
|
471
596
|
*/
|
|
472
597
|
clone(): Image;
|
|
473
598
|
/**
|
|
474
|
-
* Use {@link
|
|
599
|
+
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
600
|
+
* @group Deprecated
|
|
475
601
|
*/
|
|
476
|
-
static
|
|
602
|
+
static readonly RESIZE_NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
477
603
|
/**
|
|
478
|
-
*
|
|
604
|
+
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
605
|
+
* @group Deprecated
|
|
479
606
|
*/
|
|
480
|
-
static
|
|
607
|
+
static readonly RESIZE_BILINEAR = "RESIZE_BILINEAR";
|
|
481
608
|
/**
|
|
482
|
-
*
|
|
609
|
+
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
610
|
+
* @group Deprecated
|
|
483
611
|
*/
|
|
484
|
-
static
|
|
612
|
+
static readonly RESIZE_BICUBIC = "RESIZE_BICUBIC";
|
|
485
613
|
/**
|
|
486
|
-
*
|
|
614
|
+
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
615
|
+
* @group Deprecated
|
|
487
616
|
*/
|
|
488
|
-
static
|
|
617
|
+
static readonly RESIZE_AREA = "RESIZE_AREA";
|
|
489
618
|
/**
|
|
490
|
-
*
|
|
619
|
+
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `Image.RESIZE_*` will
|
|
620
|
+
* be removed in 4.0
|
|
621
|
+
* @group Deprecated
|
|
491
622
|
*/
|
|
492
|
-
static
|
|
623
|
+
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
493
624
|
/**
|
|
494
625
|
* Resizes the image by the given factor
|
|
495
626
|
* @param factor The factor to resize the image with
|
|
@@ -499,12 +630,13 @@ export declare class Image {
|
|
|
499
630
|
/**
|
|
500
631
|
* Resizes the image by the given factor
|
|
501
632
|
* @param factor The factor to resize the image with
|
|
502
|
-
* @param [mode=
|
|
633
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
634
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
503
635
|
*/
|
|
504
636
|
scale(factor: number, mode?: ResizeMode): this;
|
|
505
637
|
/**
|
|
506
638
|
* Resizes the image to the given dimensions.
|
|
507
|
-
*
|
|
639
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
508
640
|
* @param width The new width
|
|
509
641
|
* @param height The new height
|
|
510
642
|
* @param options See {@link ResizeOptions}
|
|
@@ -513,13 +645,20 @@ export declare class Image {
|
|
|
513
645
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
514
646
|
/**
|
|
515
647
|
* Resizes the image to the given dimensions.
|
|
516
|
-
*
|
|
648
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
517
649
|
* @param width The new width
|
|
518
650
|
* @param height The new height
|
|
519
|
-
* @param [mode=
|
|
651
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
520
652
|
* @returns The resized image
|
|
653
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
521
654
|
*/
|
|
522
655
|
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
656
|
+
/**
|
|
657
|
+
* Resizes the image: to the given width or height (the other side keeps the aspect ratio), or to both
|
|
658
|
+
* @param options The size and how to resize, see {@link ResizeToOptions}
|
|
659
|
+
* @returns The resized image
|
|
660
|
+
*/
|
|
661
|
+
resize(options: ResizeToOptions): this;
|
|
523
662
|
/**
|
|
524
663
|
* Resizes the image so it is contained in the given bounding box.
|
|
525
664
|
* Can return an image with one axis smaller than the given bounding box.
|
|
@@ -534,8 +673,9 @@ export declare class Image {
|
|
|
534
673
|
* Can return an image with one axis smaller than the given bounding box.
|
|
535
674
|
* @param width The width of the bounding box
|
|
536
675
|
* @param height The height of the bounding box
|
|
537
|
-
* @param [mode=
|
|
676
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
538
677
|
* @returns The resized image
|
|
678
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
539
679
|
*/
|
|
540
680
|
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
541
681
|
/**
|
|
@@ -552,8 +692,9 @@ export declare class Image {
|
|
|
552
692
|
* Always returns the exact dimensions of the bounding box.
|
|
553
693
|
* @param width The width of the bounding box
|
|
554
694
|
* @param height The height of the bounding box
|
|
555
|
-
* @param [mode=
|
|
695
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
556
696
|
* @returns The resized image
|
|
697
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
557
698
|
*/
|
|
558
699
|
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
559
700
|
/**
|
|
@@ -570,8 +711,9 @@ export declare class Image {
|
|
|
570
711
|
* Always returns the exact dimensions of the bounding box.
|
|
571
712
|
* @param width The width of the bounding box
|
|
572
713
|
* @param height The height of the bounding box
|
|
573
|
-
* @param [mode=
|
|
714
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
574
715
|
* @returns The resized image
|
|
716
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
575
717
|
*/
|
|
576
718
|
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
577
719
|
/**
|
|
@@ -593,6 +735,13 @@ export declare class Image {
|
|
|
593
735
|
* @param height The region's height
|
|
594
736
|
*/
|
|
595
737
|
region(x: number, y: number, width: number, height: number): Image;
|
|
738
|
+
/**
|
|
739
|
+
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
740
|
+
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
741
|
+
* unchanged
|
|
742
|
+
* @param options See {@link TrimOptions}
|
|
743
|
+
*/
|
|
744
|
+
trim(options?: TrimOptions): this;
|
|
596
745
|
/**
|
|
597
746
|
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
598
747
|
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
@@ -600,6 +749,7 @@ export declare class Image {
|
|
|
600
749
|
* @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
|
|
601
750
|
* same color whatever their RGB values
|
|
602
751
|
* @param options See {@link TrimOptions}
|
|
752
|
+
* @deprecated Pass {@link TrimOptions} instead, the positional arguments will be removed in 4.0
|
|
603
753
|
*/
|
|
604
754
|
trim(color?: Color, options?: TrimOptions): this;
|
|
605
755
|
/**
|
|
@@ -628,78 +778,92 @@ export declare class Image {
|
|
|
628
778
|
* Crops the image into a circle with an antialiased edge
|
|
629
779
|
* @param max Whether to use the larger dimension for the size. Default: `false`
|
|
630
780
|
* @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
|
|
781
|
+
* @deprecated Pass {@link CropCircleOptions} instead, `cropCircle({ size: 'cover' })`. The arguments will be
|
|
782
|
+
* removed in 4.0
|
|
631
783
|
*/
|
|
632
784
|
cropCircle(max?: boolean, feathering?: number): this;
|
|
633
785
|
/**
|
|
634
|
-
* Sets the
|
|
635
|
-
*
|
|
786
|
+
* Sets the RGB of every pixel to the given color, keeping each pixel's own alpha. Turns an image into a silhouette
|
|
787
|
+
* or tints it: `image.recolor(0xffffffff)` makes every pixel white, keeping its transparency
|
|
788
|
+
* @param color The color to use, its alpha is ignored
|
|
789
|
+
*/
|
|
790
|
+
recolor(color: Color): this;
|
|
791
|
+
/**
|
|
792
|
+
* Scales the opacity of the image
|
|
793
|
+
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
636
794
|
* @param options See {@link AdjustOptions}
|
|
637
795
|
*/
|
|
638
796
|
opacity(opacity: number, options?: AdjustOptions): this;
|
|
639
797
|
/**
|
|
640
|
-
*
|
|
641
|
-
* @param opacity The
|
|
642
|
-
* @param absolute Whether to
|
|
798
|
+
* Scales the opacity of the image
|
|
799
|
+
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
800
|
+
* @param absolute Whether to set the opacity (true) instead of scaling it (false)
|
|
801
|
+
* @deprecated Use {@link Image.opacity} to scale; for a fixed alpha, `absolute` is removed in 4.0
|
|
643
802
|
*/
|
|
644
803
|
opacity(opacity: number, absolute?: boolean): this;
|
|
645
804
|
/**
|
|
646
|
-
* Scales
|
|
647
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
805
|
+
* Scales the red channel
|
|
806
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
648
807
|
* @param options See {@link AdjustOptions}
|
|
649
808
|
*/
|
|
650
809
|
red(factor: number, options?: AdjustOptions): this;
|
|
651
810
|
/**
|
|
652
|
-
* Scales
|
|
653
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
654
|
-
* @param absolute Whether to
|
|
811
|
+
* Scales the red channel
|
|
812
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
813
|
+
* @param absolute Whether to set every pixel's red channel to `factor` * 255 (true) instead of scaling it (false)
|
|
814
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
655
815
|
*/
|
|
656
816
|
red(factor: number, absolute?: boolean): this;
|
|
657
817
|
/**
|
|
658
|
-
* Scales
|
|
659
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
818
|
+
* Scales the green channel
|
|
819
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
660
820
|
* @param options See {@link AdjustOptions}
|
|
661
821
|
*/
|
|
662
822
|
green(factor: number, options?: AdjustOptions): this;
|
|
663
823
|
/**
|
|
664
|
-
* Scales
|
|
665
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
666
|
-
* @param absolute Whether to
|
|
824
|
+
* Scales the green channel
|
|
825
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
826
|
+
* @param absolute Whether to set every pixel's green channel to `factor` * 255 (true) instead of scaling it (false)
|
|
827
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
667
828
|
*/
|
|
668
829
|
green(factor: number, absolute?: boolean): this;
|
|
669
830
|
/**
|
|
670
|
-
* Scales
|
|
671
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
831
|
+
* Scales the blue channel
|
|
832
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
672
833
|
* @param options See {@link AdjustOptions}
|
|
673
834
|
*/
|
|
674
835
|
blue(factor: number, options?: AdjustOptions): this;
|
|
675
836
|
/**
|
|
676
|
-
* Scales
|
|
677
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
678
|
-
* @param absolute Whether to
|
|
837
|
+
* Scales the blue channel
|
|
838
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
839
|
+
* @param absolute Whether to set every pixel's blue channel to `factor` * 255 (true) instead of scaling it (false)
|
|
840
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
679
841
|
*/
|
|
680
842
|
blue(factor: number, absolute?: boolean): this;
|
|
681
843
|
/**
|
|
682
|
-
*
|
|
683
|
-
* @param value The
|
|
844
|
+
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
845
|
+
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
684
846
|
* @param options See {@link AdjustOptions}
|
|
685
847
|
*/
|
|
686
848
|
lightness(value: number, options?: AdjustOptions): this;
|
|
687
849
|
/**
|
|
688
|
-
*
|
|
689
|
-
* @param value The
|
|
690
|
-
* @param absolute Whether to
|
|
850
|
+
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
851
|
+
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
852
|
+
* @param absolute Whether to set the lightness (true) instead of scaling it (false)
|
|
853
|
+
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
691
854
|
*/
|
|
692
855
|
lightness(value: number, absolute?: boolean): this;
|
|
693
856
|
/**
|
|
694
|
-
*
|
|
695
|
-
* @param value The
|
|
857
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
858
|
+
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
696
859
|
* @param options See {@link AdjustOptions}
|
|
697
860
|
*/
|
|
698
861
|
saturation(value: number, options?: AdjustOptions): this;
|
|
699
862
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @param value The
|
|
702
|
-
* @param absolute Whether to
|
|
863
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
864
|
+
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
865
|
+
* @param absolute Whether to set the saturation (true) instead of scaling it (false)
|
|
866
|
+
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
703
867
|
*/
|
|
704
868
|
saturation(value: number, absolute?: boolean): this;
|
|
705
869
|
/**
|
|
@@ -714,6 +878,7 @@ export declare class Image {
|
|
|
714
878
|
* @param [x=0] The x position to place the image at
|
|
715
879
|
* @param [y=0] The y position to place the image at
|
|
716
880
|
* @param options Opacity and blend mode, see {@link CompositeOptions}
|
|
881
|
+
* @deprecated Pass {@link CompositeOptions} instead, the positional arguments will be removed in 4.0
|
|
717
882
|
*/
|
|
718
883
|
composite(source: Image, x?: number, y?: number, options?: CompositeOptions): this;
|
|
719
884
|
/**
|
|
@@ -748,6 +913,7 @@ export declare class Image {
|
|
|
748
913
|
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
749
914
|
* @param [amount=1] How strongly to sharpen (0 does nothing)
|
|
750
915
|
* @param [radius=1] The radius of the blur the image is compared with (larger values sharpen coarser details)
|
|
916
|
+
* @deprecated Pass {@link SharpenOptions} instead, the positional arguments will be removed in 4.0
|
|
751
917
|
*/
|
|
752
918
|
sharpen(amount?: number, radius?: number): this;
|
|
753
919
|
/**
|
|
@@ -773,6 +939,15 @@ export declare class Image {
|
|
|
773
939
|
* Applies a sepia tone
|
|
774
940
|
*/
|
|
775
941
|
sepia(): this;
|
|
942
|
+
/**
|
|
943
|
+
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
944
|
+
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
945
|
+
* semi-transparent instead of keeping a fringe of it.
|
|
946
|
+
* The color is removed everywhere in the image, not only from a connected background: removing a white
|
|
947
|
+
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
948
|
+
* @param options See {@link ColorToAlphaOptions}
|
|
949
|
+
*/
|
|
950
|
+
colorToAlpha(options?: ColorToAlphaOptions): this;
|
|
776
951
|
/**
|
|
777
952
|
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
778
953
|
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
@@ -781,6 +956,7 @@ export declare class Image {
|
|
|
781
956
|
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
782
957
|
* @param color The color to remove, by default the color of the top left pixel (e.g. a background)
|
|
783
958
|
* @param options See {@link ColorToAlphaOptions}
|
|
959
|
+
* @deprecated Pass {@link ColorToAlphaOptions} instead, the positional arguments will be removed in 4.0
|
|
784
960
|
*/
|
|
785
961
|
colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
|
|
786
962
|
/**
|
|
@@ -802,6 +978,7 @@ export declare class Image {
|
|
|
802
978
|
* @param ignoreWhite Whether to ignore light colors (all channels above 255 minus the threshold). Default: `true`
|
|
803
979
|
* @param bwThreshold The black/white threshold (0-64, in steps of 4 channel values). Default: `15`
|
|
804
980
|
* @return The image's dominant color (fully opaque)
|
|
981
|
+
* @deprecated Pass {@link DominantColorOptions} instead, the positional arguments will be removed in 4.0
|
|
805
982
|
*/
|
|
806
983
|
dominantColor(ignoreBlack?: boolean, ignoreWhite?: boolean, bwThreshold?: number): Color;
|
|
807
984
|
/**
|
|
@@ -814,6 +991,7 @@ export declare class Image {
|
|
|
814
991
|
* Rotates the image counterclockwise by the given amount of degrees
|
|
815
992
|
* @param angle The angle to rotate the image for (in degrees)
|
|
816
993
|
* @param resize Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true`
|
|
994
|
+
* @deprecated Pass {@link RotateOptions} instead, the positional arguments will be removed in 4.0
|
|
817
995
|
*/
|
|
818
996
|
rotate(angle: number, resize?: boolean): this;
|
|
819
997
|
/**
|
|
@@ -821,12 +999,6 @@ export declare class Image {
|
|
|
821
999
|
* @param direction The direction to flip
|
|
822
1000
|
*/
|
|
823
1001
|
flip(direction: 'horizontal' | 'vertical'): this;
|
|
824
|
-
/**
|
|
825
|
-
* Creates a multi-point gradient generator
|
|
826
|
-
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
827
|
-
* @return The gradient generator. The function argument is the position in the gradient (0..1).
|
|
828
|
-
*/
|
|
829
|
-
static gradient(colors: Record<number, Color>): (position: number) => Color;
|
|
830
1002
|
/**
|
|
831
1003
|
* Rounds the images corners, with antialiased edges
|
|
832
1004
|
* @param options See {@link RoundCornersOptions}
|
|
@@ -835,6 +1007,7 @@ export declare class Image {
|
|
|
835
1007
|
/**
|
|
836
1008
|
* Rounds the images corners, with antialiased edges
|
|
837
1009
|
* @param [radius=min(width,height)/4] The radius of the corners
|
|
1010
|
+
* @deprecated Pass {@link RoundCornersOptions} instead, the positional arguments will be removed in 4.0
|
|
838
1011
|
*/
|
|
839
1012
|
roundCorners(radius?: number): this;
|
|
840
1013
|
/**
|
|
@@ -845,6 +1018,7 @@ export declare class Image {
|
|
|
845
1018
|
/**
|
|
846
1019
|
* Applies a fisheye (barrel distortion) effect
|
|
847
1020
|
* @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
|
|
1021
|
+
* @deprecated Pass {@link FisheyeOptions} instead, the positional arguments will be removed in 4.0
|
|
848
1022
|
*/
|
|
849
1023
|
fisheye(strength?: number): this;
|
|
850
1024
|
/**
|
|
@@ -853,35 +1027,47 @@ export declare class Image {
|
|
|
853
1027
|
* @param options See {@link PNGEncodeOptions}
|
|
854
1028
|
* @return The encoded data
|
|
855
1029
|
*/
|
|
856
|
-
|
|
1030
|
+
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
857
1031
|
/**
|
|
858
1032
|
* Encodes the image into a PNG
|
|
859
1033
|
* @param compression The compression level (0-9). Default: `4`
|
|
860
1034
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
861
1035
|
* @return The encoded data
|
|
1036
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
862
1037
|
*/
|
|
863
|
-
|
|
1038
|
+
encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
864
1039
|
/**
|
|
865
1040
|
* Encodes the image into a PNG with compression level 4
|
|
866
1041
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
867
1042
|
* @return The encoded data
|
|
1043
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
868
1044
|
*/
|
|
869
|
-
|
|
1045
|
+
encodePNG(metadata?: Metadata): Promise<Uint8Array>;
|
|
870
1046
|
/**
|
|
871
|
-
* Encodes the image into a PNG
|
|
1047
|
+
* Encodes the image into a PNG
|
|
1048
|
+
* @param options See {@link PNGEncodeOptions}
|
|
1049
|
+
* @return The encoded data
|
|
1050
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1051
|
+
* @group Deprecated
|
|
872
1052
|
*/
|
|
873
|
-
|
|
1053
|
+
encode(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
874
1054
|
/**
|
|
875
|
-
* Encodes the image into a PNG
|
|
1055
|
+
* Encodes the image into a PNG
|
|
876
1056
|
* @param compression The compression level (0-9). Default: `4`
|
|
877
1057
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1058
|
+
* @return The encoded data
|
|
1059
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1060
|
+
* @group Deprecated
|
|
878
1061
|
*/
|
|
879
|
-
|
|
1062
|
+
encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
880
1063
|
/**
|
|
881
|
-
* Encodes the image into a PNG
|
|
1064
|
+
* Encodes the image into a PNG with compression level 4
|
|
882
1065
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1066
|
+
* @return The encoded data
|
|
1067
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1068
|
+
* @group Deprecated
|
|
883
1069
|
*/
|
|
884
|
-
|
|
1070
|
+
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
885
1071
|
/**
|
|
886
1072
|
* Encodes the image into a JPEG
|
|
887
1073
|
* @param options See {@link JPEGEncodeOptions}
|
|
@@ -890,6 +1076,7 @@ export declare class Image {
|
|
|
890
1076
|
/**
|
|
891
1077
|
* Encodes the image into a JPEG
|
|
892
1078
|
* @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
|
|
1079
|
+
* @deprecated Pass {@link JPEGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
893
1080
|
*/
|
|
894
1081
|
encodeJPEG(quality?: number): Promise<Uint8Array>;
|
|
895
1082
|
/**
|
|
@@ -945,17 +1132,20 @@ export declare class Image {
|
|
|
945
1132
|
*/
|
|
946
1133
|
static decode(input: BinaryData, options?: DecodeOptions): Promise<Image>;
|
|
947
1134
|
/**
|
|
948
|
-
*
|
|
1135
|
+
* @deprecated Use {@link SVGScaleModes.SCALE}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1136
|
+
* @group Deprecated
|
|
949
1137
|
*/
|
|
950
|
-
static
|
|
1138
|
+
static readonly SVG_MODE_SCALE = 1;
|
|
951
1139
|
/**
|
|
952
|
-
*
|
|
1140
|
+
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1141
|
+
* @group Deprecated
|
|
953
1142
|
*/
|
|
954
|
-
static
|
|
1143
|
+
static readonly SVG_MODE_WIDTH = 2;
|
|
955
1144
|
/**
|
|
956
|
-
*
|
|
1145
|
+
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1146
|
+
* @group Deprecated
|
|
957
1147
|
*/
|
|
958
|
-
static
|
|
1148
|
+
static readonly SVG_MODE_HEIGHT = 3;
|
|
959
1149
|
/**
|
|
960
1150
|
* Creates a new image from the given SVG
|
|
961
1151
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
@@ -970,10 +1160,19 @@ export declare class Image {
|
|
|
970
1160
|
* Creates a new image from the given SVG
|
|
971
1161
|
* @param svg The SVG content
|
|
972
1162
|
* @param size The size to use
|
|
973
|
-
* @param mode The SVG resizing mode to use (one of {@link
|
|
1163
|
+
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
974
1164
|
* @return The rendered SVG graphic
|
|
1165
|
+
* @deprecated Pass {@link SVGOptions} instead, the positional arguments will be removed in 4.0
|
|
975
1166
|
*/
|
|
976
1167
|
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Creates a new image containing the rendered text.
|
|
1170
|
+
* @param text Text to render
|
|
1171
|
+
* @param options The font and size, color, layout and style, see {@link RenderTextOptions}; the image grows by the
|
|
1172
|
+
* outline width on every side
|
|
1173
|
+
* @return The rendered text
|
|
1174
|
+
*/
|
|
1175
|
+
static renderText(text: string, options: RenderTextOptions): Promise<Image>;
|
|
977
1176
|
/**
|
|
978
1177
|
* Creates a new image containing the rendered text.
|
|
979
1178
|
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
@@ -986,6 +1185,8 @@ export declare class Image {
|
|
|
986
1185
|
* @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
|
|
987
1186
|
* side
|
|
988
1187
|
* @return The rendered text
|
|
1188
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1189
|
+
* This signature will be removed in 4.0
|
|
989
1190
|
*/
|
|
990
1191
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, options?: TextOptions): Promise<Image>;
|
|
991
1192
|
/**
|
|
@@ -1001,6 +1202,8 @@ export declare class Image {
|
|
|
1001
1202
|
* @param [layout] The text layout to use
|
|
1002
1203
|
* @param style Outline, see {@link TextStyle}; the image grows by the outline width on every side
|
|
1003
1204
|
* @return The rendered text
|
|
1205
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1206
|
+
* This signature will be removed in 4.0
|
|
1004
1207
|
*/
|
|
1005
1208
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, color?: Color, layout?: TextLayout, style?: TextStyle): Promise<Image>;
|
|
1006
1209
|
}
|