imagescript 3.17.0 → 3.19.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 +6 -6
- package/dist/animation-encoder.d.ts +27 -34
- package/dist/animation-encoder.js +2 -2
- package/dist/animation.d.ts +48 -13
- package/dist/animation.js +45 -13
- 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/frame.d.ts +36 -7
- package/dist/frame.js +12 -3
- package/dist/gainmap.d.ts +12 -0
- package/dist/gainmap.js +3 -2
- package/dist/gif.d.ts +1 -1
- package/dist/image.d.ts +257 -34
- package/dist/image.js +218 -33
- package/dist/index.d.ts +2 -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/gif.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare class GIF extends Animation {
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new GIF image
|
|
14
14
|
* @param frames The frames to create the GIF from
|
|
15
|
-
* @param loopCountOrOptions How many times to repeat the GIF (
|
|
15
|
+
* @param loopCountOrOptions How many times to repeat the GIF (`Infinity` = forever, 0 = play once), or see
|
|
16
16
|
* {@link AnimationOptions}
|
|
17
17
|
*/
|
|
18
18
|
constructor(frames: Frame[], loopCountOrOptions?: number | AnimationOptions);
|
package/dist/image.d.ts
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
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
|
-
/** Resampling filters for {@link Image.resize} and the other scaling functions, see {@link ResizeModes} */
|
|
11
|
-
export type ResizeMode = 'RESIZE_NEAREST_NEIGHBOR' | 'RESIZE_BILINEAR' | 'RESIZE_BICUBIC' | 'RESIZE_AREA';
|
|
12
|
-
/** How {@link Image.renderSVG} scales, see {@link SVGScaleModes} */
|
|
13
|
-
export type SVGScaleMode = 1 | 2 | 3;
|
|
14
10
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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 })`
|
|
17
24
|
*/
|
|
18
25
|
export declare class ResizeModes {
|
|
19
26
|
/**
|
|
20
27
|
* Use {@link https://en.wikipedia.org/wiki/Image_scaling#Nearest-neighbor_interpolation Nearest-neighbor} resizing
|
|
21
28
|
*/
|
|
22
|
-
static readonly NEAREST_NEIGHBOR = "
|
|
29
|
+
static readonly NEAREST_NEIGHBOR = "nearest-neighbor";
|
|
23
30
|
/**
|
|
24
31
|
* Bilinear resizing (the default). When shrinking, the filter widens with the scale factor, so every source pixel
|
|
25
32
|
* contributes
|
|
26
33
|
*/
|
|
27
|
-
static readonly BILINEAR = "
|
|
34
|
+
static readonly BILINEAR = "bilinear";
|
|
28
35
|
/** Bicubic (Catmull-Rom) resizing, sharper than bilinear, especially when enlarging */
|
|
29
|
-
static readonly BICUBIC = "
|
|
36
|
+
static readonly BICUBIC = "bicubic";
|
|
30
37
|
/**
|
|
31
38
|
* Area averaging (box filter): every output pixel is the average of the source pixels it covers. Meant for
|
|
32
39
|
* shrinking
|
|
33
40
|
*/
|
|
34
|
-
static readonly AREA = "
|
|
41
|
+
static readonly AREA = "area";
|
|
35
42
|
/**
|
|
36
43
|
* Not a filter: passed as the width or the height, that side follows from the other one, keeping the image's
|
|
37
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
|
|
38
47
|
*/
|
|
39
48
|
static readonly AUTO = -1;
|
|
40
49
|
private constructor();
|
|
@@ -42,11 +51,11 @@ export declare class ResizeModes {
|
|
|
42
51
|
/** How {@link Image.renderSVG} scales the SVG to the given size */
|
|
43
52
|
export declare class SVGScaleModes {
|
|
44
53
|
/** The size is a factor of the SVG's own size */
|
|
45
|
-
static readonly SCALE =
|
|
54
|
+
static readonly SCALE = "scale";
|
|
46
55
|
/** The size is the width in pixels, the height follows the SVG's aspect ratio */
|
|
47
|
-
static readonly WIDTH =
|
|
56
|
+
static readonly WIDTH = "width";
|
|
48
57
|
/** The size is the height in pixels, the width follows the SVG's aspect ratio */
|
|
49
|
-
static readonly HEIGHT =
|
|
58
|
+
static readonly HEIGHT = "height";
|
|
50
59
|
private constructor();
|
|
51
60
|
}
|
|
52
61
|
/** Blend modes of {@link Image.composite}, named like CSS' mix-blend-mode values */
|
|
@@ -62,6 +71,16 @@ export interface CompositeOptions {
|
|
|
62
71
|
/** How the colors are mixed. Default: `'normal'` */
|
|
63
72
|
mode?: BlendMode;
|
|
64
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
|
+
}
|
|
65
84
|
/** Options of {@link Image.scale}, {@link Image.resize}, {@link Image.contain}, {@link Image.fit} and {@link Image.cover} */
|
|
66
85
|
export interface ResizeOptions {
|
|
67
86
|
/** The resizing mode. Default: {@link ResizeModes.BILINEAR} */
|
|
@@ -94,6 +113,63 @@ export interface SharpenOptions {
|
|
|
94
113
|
/** The radius of the blur the image is compared with (larger values sharpen coarser details). Default: `1` */
|
|
95
114
|
radius?: number;
|
|
96
115
|
}
|
|
116
|
+
/** Options of {@link Image.dropShadow} */
|
|
117
|
+
export interface ShadowOptions {
|
|
118
|
+
/** How far to move the shadow to the right (negative values: to the left), in pixels. Default: `0` */
|
|
119
|
+
x?: number;
|
|
120
|
+
/** How far to move the shadow down (negative values: up), in pixels. Default: `0` */
|
|
121
|
+
y?: number;
|
|
122
|
+
/** How soft the shadow's edge is: the standard deviation of a gaussian blur in pixels, like {@link Image.blur}. Default: `0` */
|
|
123
|
+
blur?: number;
|
|
124
|
+
/** How far to grow the shadow's shape before blurring it, in pixels. Default: `0` */
|
|
125
|
+
spread?: number;
|
|
126
|
+
/** The shadow's color, its alpha is the shadow's opacity. Default: `0x00000080` (50% black) */
|
|
127
|
+
color?: Color;
|
|
128
|
+
/**
|
|
129
|
+
* Whether to make the image larger so the shadow isn't cut off. Without it, the image keeps its size and the part
|
|
130
|
+
* of the shadow outside is lost. Default: `true`
|
|
131
|
+
*/
|
|
132
|
+
expand?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** Options of {@link Image.outline} */
|
|
135
|
+
export interface OutlineOptions {
|
|
136
|
+
/** The outline's width in pixels. Default: `1` */
|
|
137
|
+
width?: number;
|
|
138
|
+
/** The outline's color. Default: `0x000000ff` */
|
|
139
|
+
color?: Color;
|
|
140
|
+
/**
|
|
141
|
+
* Whether to make the image larger so the outline isn't cut off. Without it, the image keeps its size and the
|
|
142
|
+
* outline is cut where the image ends. Default: `true`
|
|
143
|
+
*/
|
|
144
|
+
expand?: boolean;
|
|
145
|
+
}
|
|
146
|
+
/** The colors of a gradient, see {@link Image.linearGradient} */
|
|
147
|
+
export interface GradientOptions {
|
|
148
|
+
/**
|
|
149
|
+
* The colors along the gradient: their positions (0..1) and colors, like {@link Colors.gradient} takes them
|
|
150
|
+
* (`{ 0: 0xff0000ff, 0.5: 0xffff00ff, 1: 0x00ff00ff }`), or just the colors, evenly spaced
|
|
151
|
+
* (`[0xff0000ff, 0x00ff00ff]`)
|
|
152
|
+
*/
|
|
153
|
+
stops: Record<number, Color> | Color[];
|
|
154
|
+
}
|
|
155
|
+
/** Options of {@link Image.linearGradient} */
|
|
156
|
+
export interface LinearGradientOptions extends GradientOptions {
|
|
157
|
+
/**
|
|
158
|
+
* The direction of the gradient in degrees, like CSS' `linear-gradient()`: `0` goes up, `90` to the right, `180`
|
|
159
|
+
* down, `270` to the left. The first stop is at the start of the line through the center that touches the
|
|
160
|
+
* corners. Default: `180`
|
|
161
|
+
*/
|
|
162
|
+
angle?: number;
|
|
163
|
+
}
|
|
164
|
+
/** Options of {@link Image.radialGradient} */
|
|
165
|
+
export interface RadialGradientOptions extends GradientOptions {
|
|
166
|
+
/** The x position of the center in pixels. Default: the middle of the image */
|
|
167
|
+
x?: number;
|
|
168
|
+
/** The y position of the center in pixels. Default: the middle of the image */
|
|
169
|
+
y?: number;
|
|
170
|
+
/** The radius of the last stop in pixels. Default: the distance to the farthest corner */
|
|
171
|
+
radius?: number;
|
|
172
|
+
}
|
|
97
173
|
/** Options of {@link Image.encode} */
|
|
98
174
|
export interface PNGEncodeOptions {
|
|
99
175
|
/** The compression level (0-9), higher is smaller but slower. Default: `4` */
|
|
@@ -198,6 +274,22 @@ export interface TextOptions extends TextStyle {
|
|
|
198
274
|
/** The text layout. Default: `new TextLayout()` */
|
|
199
275
|
layout?: TextLayout;
|
|
200
276
|
}
|
|
277
|
+
/** Options of {@link Image.renderText}: the font and size, the text color and layout, and its style (see {@link TextStyle}) */
|
|
278
|
+
export interface RenderTextOptions extends TextStyle {
|
|
279
|
+
/**
|
|
280
|
+
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every character comes
|
|
281
|
+
* from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height. Color glyphs (COLR
|
|
282
|
+
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any script is shaped
|
|
283
|
+
* like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts, marks)
|
|
284
|
+
*/
|
|
285
|
+
font: BinaryData | BinaryData[];
|
|
286
|
+
/** Font size in pixels (per em) */
|
|
287
|
+
size: number;
|
|
288
|
+
/** The text color. Default: `0xffffffff` */
|
|
289
|
+
color?: Color;
|
|
290
|
+
/** The text layout, as {@link TextLayoutOptions} or a {@link TextLayout}. Default: the defaults of `TextLayout` */
|
|
291
|
+
layout?: TextLayoutOptions | TextLayout;
|
|
292
|
+
}
|
|
201
293
|
/** Options of {@link Image.decode} */
|
|
202
294
|
export interface DecodeOptions {
|
|
203
295
|
/** Whether to rotate/mirror JPEGs, TIFFs, PNGs and WebPs as their orientation tag (Exif or XMP) says. Default: `true` */
|
|
@@ -333,7 +425,16 @@ export interface TextStyle {
|
|
|
333
425
|
}
|
|
334
426
|
/** Options of {@link Image.cropCircle} */
|
|
335
427
|
export interface CropCircleOptions {
|
|
336
|
-
/**
|
|
428
|
+
/**
|
|
429
|
+
* The circle's size: `'contain'` fits it inside the image (the smaller dimension is its diameter, no hard edges),
|
|
430
|
+
* `'cover'` covers the image (the larger dimension is its diameter, the corners of a rectangular image stay
|
|
431
|
+
* transparent on the shorter side). Default: `'contain'`
|
|
432
|
+
*/
|
|
433
|
+
size?: 'contain' | 'cover';
|
|
434
|
+
/**
|
|
435
|
+
* Whether to use the larger dimension for the size. Default: `false`
|
|
436
|
+
* @deprecated Use `size: 'cover'` (`true`) or `size: 'contain'` (`false`), `max` will be removed in 4.0
|
|
437
|
+
*/
|
|
337
438
|
max?: boolean;
|
|
338
439
|
/** Share of the radius (0..1) over which the edge fades out. Default: `0` */
|
|
339
440
|
feathering?: number;
|
|
@@ -361,6 +462,11 @@ export interface RotateOptions {
|
|
|
361
462
|
}
|
|
362
463
|
/** Options of {@link Image.trim} */
|
|
363
464
|
export interface TrimOptions {
|
|
465
|
+
/**
|
|
466
|
+
* The border color, by default the color of the top left pixel. Fully transparent pixels count as the same color
|
|
467
|
+
* whatever their RGB values
|
|
468
|
+
*/
|
|
469
|
+
color?: Color;
|
|
364
470
|
/**
|
|
365
471
|
* How far (0-1) a pixel's channels may be from the color for it to be trimmed, e.g. for JPEG artifacts or
|
|
366
472
|
* antialiasing. Default: `0`
|
|
@@ -369,6 +475,8 @@ export interface TrimOptions {
|
|
|
369
475
|
}
|
|
370
476
|
/** Options of {@link Image.colorToAlpha} */
|
|
371
477
|
export interface ColorToAlphaOptions {
|
|
478
|
+
/** The color to remove, by default the color of the top left pixel (e.g. a background) */
|
|
479
|
+
color?: Color;
|
|
372
480
|
/** Pixels at most this far from the color (0-1) become fully transparent. Default: 0 */
|
|
373
481
|
transparencyThreshold?: number;
|
|
374
482
|
/** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
|
|
@@ -421,14 +529,28 @@ export declare class Image {
|
|
|
421
529
|
* The images height
|
|
422
530
|
*/
|
|
423
531
|
get height(): number;
|
|
532
|
+
/**
|
|
533
|
+
* Yields an [x, y] array for every pixel in the image (0-based), row by row
|
|
534
|
+
* @yields The coordinates of the pixel ([x, y])
|
|
535
|
+
*/
|
|
536
|
+
coordinates(): Generator<[x: number, y: number], void, undefined>;
|
|
537
|
+
/**
|
|
538
|
+
* Yields an [x, y, color] array for every pixel in the image (0-based), row by row
|
|
539
|
+
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
540
|
+
*/
|
|
541
|
+
pixels(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
424
542
|
/**
|
|
425
543
|
* Yields an [x, y] array for every pixel in the image (0-based)
|
|
426
544
|
* @yields The coordinates of the pixel ([x, y])
|
|
545
|
+
* @deprecated Use {@link Image.coordinates}, iterating over the image will be removed in 4.0
|
|
546
|
+
* @group Deprecated
|
|
427
547
|
*/
|
|
428
548
|
[Symbol.iterator](): Generator<[x: number, y: number], void, undefined>;
|
|
429
549
|
/**
|
|
430
550
|
* Yields an [x, y, color] array for every pixel in the image (0-based)
|
|
431
551
|
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
552
|
+
* @deprecated Use {@link Image.pixels}, `iterateWithColors()` will be removed in 4.0
|
|
553
|
+
* @group Deprecated
|
|
432
554
|
*/
|
|
433
555
|
iterateWithColors(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
434
556
|
/**
|
|
@@ -493,6 +615,22 @@ export declare class Image {
|
|
|
493
615
|
* @group Deprecated
|
|
494
616
|
*/
|
|
495
617
|
static colorToRGB(color: Color): [r: number, g: number, b: number];
|
|
618
|
+
/**
|
|
619
|
+
* Creates an image with a linear gradient, like CSS' `linear-gradient()`
|
|
620
|
+
* @param width The image's width
|
|
621
|
+
* @param height The image's height
|
|
622
|
+
* @param options The colors and the direction, see {@link LinearGradientOptions}
|
|
623
|
+
* @returns The new image
|
|
624
|
+
*/
|
|
625
|
+
static linearGradient(width: number, height: number, options: LinearGradientOptions): Image;
|
|
626
|
+
/**
|
|
627
|
+
* Creates an image with a radial (circular) gradient, like CSS' `radial-gradient(circle)`
|
|
628
|
+
* @param width The image's width
|
|
629
|
+
* @param height The image's height
|
|
630
|
+
* @param options The colors and the circle, see {@link RadialGradientOptions}
|
|
631
|
+
* @returns The new image
|
|
632
|
+
*/
|
|
633
|
+
static radialGradient(width: number, height: number, options: RadialGradientOptions): Image;
|
|
496
634
|
/**
|
|
497
635
|
* Creates a multi-point gradient generator
|
|
498
636
|
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
@@ -534,24 +672,25 @@ export declare class Image {
|
|
|
534
672
|
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
535
673
|
* @group Deprecated
|
|
536
674
|
*/
|
|
537
|
-
static readonly RESIZE_NEAREST_NEIGHBOR
|
|
675
|
+
static readonly RESIZE_NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
538
676
|
/**
|
|
539
677
|
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
540
678
|
* @group Deprecated
|
|
541
679
|
*/
|
|
542
|
-
static readonly RESIZE_BILINEAR
|
|
680
|
+
static readonly RESIZE_BILINEAR = "RESIZE_BILINEAR";
|
|
543
681
|
/**
|
|
544
682
|
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
545
683
|
* @group Deprecated
|
|
546
684
|
*/
|
|
547
|
-
static readonly RESIZE_BICUBIC
|
|
685
|
+
static readonly RESIZE_BICUBIC = "RESIZE_BICUBIC";
|
|
548
686
|
/**
|
|
549
687
|
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
550
688
|
* @group Deprecated
|
|
551
689
|
*/
|
|
552
|
-
static readonly RESIZE_AREA
|
|
690
|
+
static readonly RESIZE_AREA = "RESIZE_AREA";
|
|
553
691
|
/**
|
|
554
|
-
* @deprecated
|
|
692
|
+
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `Image.RESIZE_*` will
|
|
693
|
+
* be removed in 4.0
|
|
555
694
|
* @group Deprecated
|
|
556
695
|
*/
|
|
557
696
|
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
@@ -565,11 +704,12 @@ export declare class Image {
|
|
|
565
704
|
* Resizes the image by the given factor
|
|
566
705
|
* @param factor The factor to resize the image with
|
|
567
706
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
707
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
568
708
|
*/
|
|
569
709
|
scale(factor: number, mode?: ResizeMode): this;
|
|
570
710
|
/**
|
|
571
711
|
* Resizes the image to the given dimensions.
|
|
572
|
-
*
|
|
712
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
573
713
|
* @param width The new width
|
|
574
714
|
* @param height The new height
|
|
575
715
|
* @param options See {@link ResizeOptions}
|
|
@@ -578,13 +718,20 @@ export declare class Image {
|
|
|
578
718
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
579
719
|
/**
|
|
580
720
|
* Resizes the image to the given dimensions.
|
|
581
|
-
*
|
|
721
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
582
722
|
* @param width The new width
|
|
583
723
|
* @param height The new height
|
|
584
724
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
585
725
|
* @returns The resized image
|
|
726
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
586
727
|
*/
|
|
587
728
|
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
729
|
+
/**
|
|
730
|
+
* Resizes the image: to the given width or height (the other side keeps the aspect ratio), or to both
|
|
731
|
+
* @param options The size and how to resize, see {@link ResizeToOptions}
|
|
732
|
+
* @returns The resized image
|
|
733
|
+
*/
|
|
734
|
+
resize(options: ResizeToOptions): this;
|
|
588
735
|
/**
|
|
589
736
|
* Resizes the image so it is contained in the given bounding box.
|
|
590
737
|
* Can return an image with one axis smaller than the given bounding box.
|
|
@@ -601,6 +748,7 @@ export declare class Image {
|
|
|
601
748
|
* @param height The height of the bounding box
|
|
602
749
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
603
750
|
* @returns The resized image
|
|
751
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
604
752
|
*/
|
|
605
753
|
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
606
754
|
/**
|
|
@@ -619,6 +767,7 @@ export declare class Image {
|
|
|
619
767
|
* @param height The height of the bounding box
|
|
620
768
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
621
769
|
* @returns The resized image
|
|
770
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
622
771
|
*/
|
|
623
772
|
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
624
773
|
/**
|
|
@@ -637,6 +786,7 @@ export declare class Image {
|
|
|
637
786
|
* @param height The height of the bounding box
|
|
638
787
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
639
788
|
* @returns The resized image
|
|
789
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
640
790
|
*/
|
|
641
791
|
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
642
792
|
/**
|
|
@@ -658,6 +808,13 @@ export declare class Image {
|
|
|
658
808
|
* @param height The region's height
|
|
659
809
|
*/
|
|
660
810
|
region(x: number, y: number, width: number, height: number): Image;
|
|
811
|
+
/**
|
|
812
|
+
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
813
|
+
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
814
|
+
* unchanged
|
|
815
|
+
* @param options See {@link TrimOptions}
|
|
816
|
+
*/
|
|
817
|
+
trim(options?: TrimOptions): this;
|
|
661
818
|
/**
|
|
662
819
|
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
663
820
|
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
@@ -665,6 +822,7 @@ export declare class Image {
|
|
|
665
822
|
* @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
|
|
666
823
|
* same color whatever their RGB values
|
|
667
824
|
* @param options See {@link TrimOptions}
|
|
825
|
+
* @deprecated Pass {@link TrimOptions} instead, the positional arguments will be removed in 4.0
|
|
668
826
|
*/
|
|
669
827
|
trim(color?: Color, options?: TrimOptions): this;
|
|
670
828
|
/**
|
|
@@ -693,6 +851,8 @@ export declare class Image {
|
|
|
693
851
|
* Crops the image into a circle with an antialiased edge
|
|
694
852
|
* @param max Whether to use the larger dimension for the size. Default: `false`
|
|
695
853
|
* @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
|
|
854
|
+
* @deprecated Pass {@link CropCircleOptions} instead, `cropCircle({ size: 'cover' })`. The arguments will be
|
|
855
|
+
* removed in 4.0
|
|
696
856
|
*/
|
|
697
857
|
cropCircle(max?: boolean, feathering?: number): this;
|
|
698
858
|
/**
|
|
@@ -701,6 +861,13 @@ export declare class Image {
|
|
|
701
861
|
* @param color The color to use, its alpha is ignored
|
|
702
862
|
*/
|
|
703
863
|
recolor(color: Color): this;
|
|
864
|
+
/**
|
|
865
|
+
* Sets the RGB of every pixel to the RGB of the same pixel of another image, keeping each pixel's own alpha. With a
|
|
866
|
+
* gradient this fills a shape with it, e.g. gradient text:
|
|
867
|
+
* `text.recolor(Image.linearGradient(text.width, text.height, { stops: [0x22d3eeff, 0xfb923cff], angle: 90 }))`
|
|
868
|
+
* @param colors The image to take the colors from, it has to have the same size. Its alpha is ignored
|
|
869
|
+
*/
|
|
870
|
+
recolor(colors: Image): this;
|
|
704
871
|
/**
|
|
705
872
|
* Scales the opacity of the image
|
|
706
873
|
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
@@ -791,6 +958,7 @@ export declare class Image {
|
|
|
791
958
|
* @param [x=0] The x position to place the image at
|
|
792
959
|
* @param [y=0] The y position to place the image at
|
|
793
960
|
* @param options Opacity and blend mode, see {@link CompositeOptions}
|
|
961
|
+
* @deprecated Pass {@link CompositeOptions} instead, the positional arguments will be removed in 4.0
|
|
794
962
|
*/
|
|
795
963
|
composite(source: Image, x?: number, y?: number, options?: CompositeOptions): this;
|
|
796
964
|
/**
|
|
@@ -816,6 +984,21 @@ export declare class Image {
|
|
|
816
984
|
* @param radius The blur radius: the gaussian's standard deviation in pixels, like CSS' blur()
|
|
817
985
|
*/
|
|
818
986
|
blur(radius: number): this;
|
|
987
|
+
/**
|
|
988
|
+
* Adds a shadow behind the image, shaped by its alpha: a drop shadow with an offset, or a glow without one
|
|
989
|
+
* (`image.dropShadow({ blur: 8, color: 0xff2fb9ff })`, with `spread` to make it stronger). The image grows to fit
|
|
990
|
+
* the shadow, unless `expand` is `false`. Frames stay where they are (their offsets move with the growth), they only
|
|
991
|
+
* grow up and left as far as their offset allows
|
|
992
|
+
* @param options See {@link ShadowOptions}
|
|
993
|
+
*/
|
|
994
|
+
dropShadow(options?: ShadowOptions): this;
|
|
995
|
+
/**
|
|
996
|
+
* Draws an outline around the image's shape (its alpha): the sticker effect for cut-out images, or an outline for
|
|
997
|
+
* text. The image grows to fit it, unless `expand` is `false`. Frames stay where they are (their offsets move with
|
|
998
|
+
* the growth), they only grow up and left as far as their offset allows
|
|
999
|
+
* @param options See {@link OutlineOptions}
|
|
1000
|
+
*/
|
|
1001
|
+
outline(options?: OutlineOptions): this;
|
|
819
1002
|
/**
|
|
820
1003
|
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
821
1004
|
* @param options See {@link SharpenOptions}
|
|
@@ -825,6 +1008,7 @@ export declare class Image {
|
|
|
825
1008
|
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
826
1009
|
* @param [amount=1] How strongly to sharpen (0 does nothing)
|
|
827
1010
|
* @param [radius=1] The radius of the blur the image is compared with (larger values sharpen coarser details)
|
|
1011
|
+
* @deprecated Pass {@link SharpenOptions} instead, the positional arguments will be removed in 4.0
|
|
828
1012
|
*/
|
|
829
1013
|
sharpen(amount?: number, radius?: number): this;
|
|
830
1014
|
/**
|
|
@@ -850,6 +1034,15 @@ export declare class Image {
|
|
|
850
1034
|
* Applies a sepia tone
|
|
851
1035
|
*/
|
|
852
1036
|
sepia(): this;
|
|
1037
|
+
/**
|
|
1038
|
+
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
1039
|
+
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
1040
|
+
* semi-transparent instead of keeping a fringe of it.
|
|
1041
|
+
* The color is removed everywhere in the image, not only from a connected background: removing a white
|
|
1042
|
+
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
1043
|
+
* @param options See {@link ColorToAlphaOptions}
|
|
1044
|
+
*/
|
|
1045
|
+
colorToAlpha(options?: ColorToAlphaOptions): this;
|
|
853
1046
|
/**
|
|
854
1047
|
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
855
1048
|
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
@@ -858,6 +1051,7 @@ export declare class Image {
|
|
|
858
1051
|
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
859
1052
|
* @param color The color to remove, by default the color of the top left pixel (e.g. a background)
|
|
860
1053
|
* @param options See {@link ColorToAlphaOptions}
|
|
1054
|
+
* @deprecated Pass {@link ColorToAlphaOptions} instead, the positional arguments will be removed in 4.0
|
|
861
1055
|
*/
|
|
862
1056
|
colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
|
|
863
1057
|
/**
|
|
@@ -879,6 +1073,7 @@ export declare class Image {
|
|
|
879
1073
|
* @param ignoreWhite Whether to ignore light colors (all channels above 255 minus the threshold). Default: `true`
|
|
880
1074
|
* @param bwThreshold The black/white threshold (0-64, in steps of 4 channel values). Default: `15`
|
|
881
1075
|
* @return The image's dominant color (fully opaque)
|
|
1076
|
+
* @deprecated Pass {@link DominantColorOptions} instead, the positional arguments will be removed in 4.0
|
|
882
1077
|
*/
|
|
883
1078
|
dominantColor(ignoreBlack?: boolean, ignoreWhite?: boolean, bwThreshold?: number): Color;
|
|
884
1079
|
/**
|
|
@@ -891,6 +1086,7 @@ export declare class Image {
|
|
|
891
1086
|
* Rotates the image counterclockwise by the given amount of degrees
|
|
892
1087
|
* @param angle The angle to rotate the image for (in degrees)
|
|
893
1088
|
* @param resize Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true`
|
|
1089
|
+
* @deprecated Pass {@link RotateOptions} instead, the positional arguments will be removed in 4.0
|
|
894
1090
|
*/
|
|
895
1091
|
rotate(angle: number, resize?: boolean): this;
|
|
896
1092
|
/**
|
|
@@ -906,6 +1102,7 @@ export declare class Image {
|
|
|
906
1102
|
/**
|
|
907
1103
|
* Rounds the images corners, with antialiased edges
|
|
908
1104
|
* @param [radius=min(width,height)/4] The radius of the corners
|
|
1105
|
+
* @deprecated Pass {@link RoundCornersOptions} instead, the positional arguments will be removed in 4.0
|
|
909
1106
|
*/
|
|
910
1107
|
roundCorners(radius?: number): this;
|
|
911
1108
|
/**
|
|
@@ -916,6 +1113,7 @@ export declare class Image {
|
|
|
916
1113
|
/**
|
|
917
1114
|
* Applies a fisheye (barrel distortion) effect
|
|
918
1115
|
* @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
|
|
1116
|
+
* @deprecated Pass {@link FisheyeOptions} instead, the positional arguments will be removed in 4.0
|
|
919
1117
|
*/
|
|
920
1118
|
fisheye(strength?: number): this;
|
|
921
1119
|
/**
|
|
@@ -924,36 +1122,47 @@ export declare class Image {
|
|
|
924
1122
|
* @param options See {@link PNGEncodeOptions}
|
|
925
1123
|
* @return The encoded data
|
|
926
1124
|
*/
|
|
927
|
-
|
|
1125
|
+
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
928
1126
|
/**
|
|
929
1127
|
* Encodes the image into a PNG
|
|
930
1128
|
* @param compression The compression level (0-9). Default: `4`
|
|
931
1129
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
932
1130
|
* @return The encoded data
|
|
1131
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
933
1132
|
*/
|
|
934
|
-
|
|
1133
|
+
encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
935
1134
|
/**
|
|
936
1135
|
* Encodes the image into a PNG with compression level 4
|
|
937
1136
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
938
1137
|
* @return The encoded data
|
|
1138
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
939
1139
|
*/
|
|
940
|
-
|
|
1140
|
+
encodePNG(metadata?: Metadata): Promise<Uint8Array>;
|
|
941
1141
|
/**
|
|
942
|
-
* Encodes the image into a PNG
|
|
1142
|
+
* Encodes the image into a PNG
|
|
943
1143
|
* @param options See {@link PNGEncodeOptions}
|
|
1144
|
+
* @return The encoded data
|
|
1145
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1146
|
+
* @group Deprecated
|
|
944
1147
|
*/
|
|
945
|
-
|
|
1148
|
+
encode(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
946
1149
|
/**
|
|
947
|
-
* Encodes the image into a PNG
|
|
1150
|
+
* Encodes the image into a PNG
|
|
948
1151
|
* @param compression The compression level (0-9). Default: `4`
|
|
949
1152
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1153
|
+
* @return The encoded data
|
|
1154
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1155
|
+
* @group Deprecated
|
|
950
1156
|
*/
|
|
951
|
-
|
|
1157
|
+
encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
952
1158
|
/**
|
|
953
|
-
* Encodes the image into a PNG
|
|
1159
|
+
* Encodes the image into a PNG with compression level 4
|
|
954
1160
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1161
|
+
* @return The encoded data
|
|
1162
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1163
|
+
* @group Deprecated
|
|
955
1164
|
*/
|
|
956
|
-
|
|
1165
|
+
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
957
1166
|
/**
|
|
958
1167
|
* Encodes the image into a JPEG
|
|
959
1168
|
* @param options See {@link JPEGEncodeOptions}
|
|
@@ -962,6 +1171,7 @@ export declare class Image {
|
|
|
962
1171
|
/**
|
|
963
1172
|
* Encodes the image into a JPEG
|
|
964
1173
|
* @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
|
|
1174
|
+
* @deprecated Pass {@link JPEGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
965
1175
|
*/
|
|
966
1176
|
encodeJPEG(quality?: number): Promise<Uint8Array>;
|
|
967
1177
|
/**
|
|
@@ -1020,17 +1230,17 @@ export declare class Image {
|
|
|
1020
1230
|
* @deprecated Use {@link SVGScaleModes.SCALE}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1021
1231
|
* @group Deprecated
|
|
1022
1232
|
*/
|
|
1023
|
-
static readonly SVG_MODE_SCALE
|
|
1233
|
+
static readonly SVG_MODE_SCALE = 1;
|
|
1024
1234
|
/**
|
|
1025
1235
|
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1026
1236
|
* @group Deprecated
|
|
1027
1237
|
*/
|
|
1028
|
-
static readonly SVG_MODE_WIDTH
|
|
1238
|
+
static readonly SVG_MODE_WIDTH = 2;
|
|
1029
1239
|
/**
|
|
1030
1240
|
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1031
1241
|
* @group Deprecated
|
|
1032
1242
|
*/
|
|
1033
|
-
static readonly SVG_MODE_HEIGHT
|
|
1243
|
+
static readonly SVG_MODE_HEIGHT = 3;
|
|
1034
1244
|
/**
|
|
1035
1245
|
* Creates a new image from the given SVG
|
|
1036
1246
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
@@ -1047,8 +1257,17 @@ export declare class Image {
|
|
|
1047
1257
|
* @param size The size to use
|
|
1048
1258
|
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
1049
1259
|
* @return The rendered SVG graphic
|
|
1260
|
+
* @deprecated Pass {@link SVGOptions} instead, the positional arguments will be removed in 4.0
|
|
1050
1261
|
*/
|
|
1051
1262
|
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Creates a new image containing the rendered text.
|
|
1265
|
+
* @param text Text to render
|
|
1266
|
+
* @param options The font and size, color, layout and style, see {@link RenderTextOptions}; the image grows by the
|
|
1267
|
+
* outline width on every side
|
|
1268
|
+
* @return The rendered text
|
|
1269
|
+
*/
|
|
1270
|
+
static renderText(text: string, options: RenderTextOptions): Promise<Image>;
|
|
1052
1271
|
/**
|
|
1053
1272
|
* Creates a new image containing the rendered text.
|
|
1054
1273
|
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
@@ -1061,6 +1280,8 @@ export declare class Image {
|
|
|
1061
1280
|
* @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
|
|
1062
1281
|
* side
|
|
1063
1282
|
* @return The rendered text
|
|
1283
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1284
|
+
* This signature will be removed in 4.0
|
|
1064
1285
|
*/
|
|
1065
1286
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, options?: TextOptions): Promise<Image>;
|
|
1066
1287
|
/**
|
|
@@ -1076,6 +1297,8 @@ export declare class Image {
|
|
|
1076
1297
|
* @param [layout] The text layout to use
|
|
1077
1298
|
* @param style Outline, see {@link TextStyle}; the image grows by the outline width on every side
|
|
1078
1299
|
* @return The rendered text
|
|
1300
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1301
|
+
* This signature will be removed in 4.0
|
|
1079
1302
|
*/
|
|
1080
1303
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, color?: Color, layout?: TextLayout, style?: TextStyle): Promise<Image>;
|
|
1081
1304
|
}
|