imagescript 3.16.0 → 3.17.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 +10 -2
- package/dist/animation-encoder.js +6 -3
- package/dist/animation.d.ts +15 -3
- package/dist/animation.js +7 -7
- package/dist/codecs/jpeg.js +3 -2
- package/dist/colors.d.ts +79 -0
- package/dist/colors.js +161 -0
- package/dist/frame.d.ts +47 -11
- package/dist/frame.js +12 -13
- package/dist/gainmap.d.ts +4 -0
- package/dist/gif.d.ts +1 -0
- package/dist/image-type.d.ts +52 -13
- package/dist/image.d.ts +181 -106
- package/dist/image.js +63 -181
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/image-type.d.ts
CHANGED
|
@@ -10,30 +10,69 @@ export declare class ImageType {
|
|
|
10
10
|
* @returns The image type, or null if it isn't supported
|
|
11
11
|
*/
|
|
12
12
|
static getType(data: BinaryData): ImageTypeName | null;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Whether the data starts like a PNG
|
|
15
|
+
* @param data The file's data
|
|
16
|
+
*/
|
|
14
17
|
static isPNG(data: BinaryData): boolean;
|
|
15
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Whether the data starts like a JPEG
|
|
20
|
+
* @param data The file's data
|
|
21
|
+
*/
|
|
16
22
|
static isJPEG(data: BinaryData): boolean;
|
|
17
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Whether the data starts like a TIFF (or BigTIFF)
|
|
25
|
+
* @param data The file's data
|
|
26
|
+
*/
|
|
18
27
|
static isTIFF(data: BinaryData): boolean;
|
|
19
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Whether the data starts like a GIF
|
|
30
|
+
* @param data The file's data
|
|
31
|
+
*/
|
|
20
32
|
static isGIF(data: BinaryData): boolean;
|
|
21
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Whether the data starts like a WebP
|
|
35
|
+
* @param data The file's data
|
|
36
|
+
*/
|
|
22
37
|
static isWebP(data: BinaryData): boolean;
|
|
23
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Whether the data starts like an AVIF (the avif or avis brand)
|
|
40
|
+
* @param data The file's data
|
|
41
|
+
*/
|
|
24
42
|
static isAVIF(data: BinaryData): boolean;
|
|
25
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Whether the data starts like a JPEG XL (a codestream or the container)
|
|
45
|
+
* @param data The file's data
|
|
46
|
+
*/
|
|
26
47
|
static isJXL(data: BinaryData): boolean;
|
|
27
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Whether the data starts like a BMP
|
|
50
|
+
* @param data The file's data
|
|
51
|
+
*/
|
|
28
52
|
static isBMP(data: BinaryData): boolean;
|
|
29
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Whether the data is a Windows icon or cursor (ICO or CUR)
|
|
55
|
+
* @param data The file's data
|
|
56
|
+
*/
|
|
30
57
|
static isICO(data: BinaryData): boolean;
|
|
31
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Whether the data starts like a QOI
|
|
60
|
+
* @param data The file's data
|
|
61
|
+
*/
|
|
32
62
|
static isQOI(data: BinaryData): boolean;
|
|
33
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Whether the data starts like a Netpbm image (PBM, PGM, PPM, PAM or PFM)
|
|
65
|
+
* @param data The file's data
|
|
66
|
+
*/
|
|
34
67
|
static isPNM(data: BinaryData): boolean;
|
|
35
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Whether the data starts like a Radiance HDR
|
|
70
|
+
* @param data The file's data
|
|
71
|
+
*/
|
|
36
72
|
static isHDR(data: BinaryData): boolean;
|
|
37
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Whether the data looks like a TGA (which has no magic number: its header has to be consistent)
|
|
75
|
+
* @param data The file's data
|
|
76
|
+
*/
|
|
38
77
|
static isTGA(data: BinaryData): boolean;
|
|
39
78
|
}
|
package/dist/image.d.ts
CHANGED
|
@@ -7,10 +7,48 @@ import { GainMap } from './gainmap.js';
|
|
|
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
|
|
10
|
+
/** Resampling filters for {@link Image.resize} and the other scaling functions, see {@link ResizeModes} */
|
|
11
11
|
export type ResizeMode = 'RESIZE_NEAREST_NEIGHBOR' | 'RESIZE_BILINEAR' | 'RESIZE_BICUBIC' | 'RESIZE_AREA';
|
|
12
|
-
/** How {@link Image.renderSVG} scales
|
|
12
|
+
/** How {@link Image.renderSVG} scales, see {@link SVGScaleModes} */
|
|
13
13
|
export type SVGScaleMode = 1 | 2 | 3;
|
|
14
|
+
/**
|
|
15
|
+
* The resampling filters of {@link Image.resize} and the other scaling functions, and {@link ResizeModes.AUTO} for
|
|
16
|
+
* a width or height that keeps the aspect ratio: `image.resize(256, ResizeModes.AUTO, ResizeModes.BICUBIC)`
|
|
17
|
+
*/
|
|
18
|
+
export declare class ResizeModes {
|
|
19
|
+
/**
|
|
20
|
+
* Use {@link https://en.wikipedia.org/wiki/Image_scaling#Nearest-neighbor_interpolation Nearest-neighbor} resizing
|
|
21
|
+
*/
|
|
22
|
+
static readonly NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
23
|
+
/**
|
|
24
|
+
* Bilinear resizing (the default). When shrinking, the filter widens with the scale factor, so every source pixel
|
|
25
|
+
* contributes
|
|
26
|
+
*/
|
|
27
|
+
static readonly BILINEAR = "RESIZE_BILINEAR";
|
|
28
|
+
/** Bicubic (Catmull-Rom) resizing, sharper than bilinear, especially when enlarging */
|
|
29
|
+
static readonly BICUBIC = "RESIZE_BICUBIC";
|
|
30
|
+
/**
|
|
31
|
+
* Area averaging (box filter): every output pixel is the average of the source pixels it covers. Meant for
|
|
32
|
+
* shrinking
|
|
33
|
+
*/
|
|
34
|
+
static readonly AREA = "RESIZE_AREA";
|
|
35
|
+
/**
|
|
36
|
+
* Not a filter: passed as the width or the height, that side follows from the other one, keeping the image's
|
|
37
|
+
* aspect ratio
|
|
38
|
+
*/
|
|
39
|
+
static readonly AUTO = -1;
|
|
40
|
+
private constructor();
|
|
41
|
+
}
|
|
42
|
+
/** How {@link Image.renderSVG} scales the SVG to the given size */
|
|
43
|
+
export declare class SVGScaleModes {
|
|
44
|
+
/** The size is a factor of the SVG's own size */
|
|
45
|
+
static readonly SCALE = 1;
|
|
46
|
+
/** The size is the width in pixels, the height follows the SVG's aspect ratio */
|
|
47
|
+
static readonly WIDTH = 2;
|
|
48
|
+
/** The size is the height in pixels, the width follows the SVG's aspect ratio */
|
|
49
|
+
static readonly HEIGHT = 3;
|
|
50
|
+
private constructor();
|
|
51
|
+
}
|
|
14
52
|
/** Blend modes of {@link Image.composite}, named like CSS' mix-blend-mode values */
|
|
15
53
|
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'add';
|
|
16
54
|
/** Options of {@link Image.composite} */
|
|
@@ -26,14 +64,14 @@ export interface CompositeOptions {
|
|
|
26
64
|
}
|
|
27
65
|
/** Options of {@link Image.scale}, {@link Image.resize}, {@link Image.contain}, {@link Image.fit} and {@link Image.cover} */
|
|
28
66
|
export interface ResizeOptions {
|
|
29
|
-
/** The resizing mode. Default: {@link
|
|
67
|
+
/** The resizing mode. Default: {@link ResizeModes.BILINEAR} */
|
|
30
68
|
mode?: ResizeMode;
|
|
31
69
|
/**
|
|
32
70
|
* Whether to round to 8 bits between the two passes, so two channels share the multiplications of both: about
|
|
33
71
|
* 15-25% faster for opaque images, with 10-25% of the channel values a step off the precise result (instead of
|
|
34
72
|
* about 1%, never more than 1). Transparent images are premultiplied to 8 bits like browsers do, which makes them
|
|
35
73
|
* 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
|
|
74
|
+
* transparent keep less of their color. Only affects {@link ResizeModes.BILINEAR} and {@link ResizeModes.AREA},
|
|
37
75
|
* down to about a third of the size. Default: `true`
|
|
38
76
|
*/
|
|
39
77
|
fast?: boolean;
|
|
@@ -43,7 +81,10 @@ export interface ResizeOptions {
|
|
|
43
81
|
* and {@link Image.saturation}
|
|
44
82
|
*/
|
|
45
83
|
export interface AdjustOptions {
|
|
46
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Whether to set the value (true) or scale the current one (false). Default: `false`
|
|
86
|
+
* @deprecated Removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
87
|
+
*/
|
|
47
88
|
absolute?: boolean;
|
|
48
89
|
}
|
|
49
90
|
/** Options of {@link Image.sharpen} */
|
|
@@ -67,12 +108,13 @@ export interface JPEGEncodeOptions {
|
|
|
67
108
|
/** Metadata to include, see {@link Metadata} */
|
|
68
109
|
metadata?: Metadata;
|
|
69
110
|
/**
|
|
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)
|
|
111
|
+
* Whether to write the image's {@link Image.gainMap} (an Ultra HDR JPEG, brighter on HDR displays), or how.
|
|
112
|
+
* Default: `true` (written if there is one)
|
|
73
113
|
*/
|
|
74
114
|
gainMap?: boolean | {
|
|
115
|
+
/** The map's JPEG quality (1-100). Default: `90` */
|
|
75
116
|
quality?: number;
|
|
117
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
76
118
|
scale?: number;
|
|
77
119
|
};
|
|
78
120
|
}
|
|
@@ -135,8 +177,8 @@ export interface SVGOptions {
|
|
|
135
177
|
/** The scale, or the width or height in pixels, see `mode`. Default: `1` */
|
|
136
178
|
size?: number;
|
|
137
179
|
/**
|
|
138
|
-
* What `size` is: one of {@link
|
|
139
|
-
* Default: {@link
|
|
180
|
+
* What `size` is: one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT}.
|
|
181
|
+
* Default: {@link SVGScaleModes.SCALE}
|
|
140
182
|
*/
|
|
141
183
|
mode?: SVGScaleMode;
|
|
142
184
|
/**
|
|
@@ -221,12 +263,13 @@ export interface JXLEncodeOptions {
|
|
|
221
263
|
/** Metadata to include, see {@link Metadata} */
|
|
222
264
|
metadata?: Metadata;
|
|
223
265
|
/**
|
|
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`
|
|
266
|
+
* Whether to write the image's {@link Image.gainMap} (brighter on HDR displays: a jhgm box, like libjxl's), or how.
|
|
267
|
+
* Default: `true` (written if there is one)
|
|
227
268
|
*/
|
|
228
269
|
gainMap?: boolean | {
|
|
270
|
+
/** The map's quality (1-100 like `quality`, 100 lossless). Default: `90` */
|
|
229
271
|
quality?: number;
|
|
272
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
230
273
|
scale?: number;
|
|
231
274
|
};
|
|
232
275
|
}
|
|
@@ -251,11 +294,12 @@ export interface AVIFEncodeOptions {
|
|
|
251
294
|
metadata?: Metadata;
|
|
252
295
|
/**
|
|
253
296
|
* 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`
|
|
297
|
+
* writes), or how. Default: `true` (written if there is one)
|
|
256
298
|
*/
|
|
257
299
|
gainMap?: boolean | {
|
|
300
|
+
/** The map's quality (1-100). Default: `90` */
|
|
258
301
|
quality?: number;
|
|
302
|
+
/** The map's size as a factor of the image's (0-1). Default: the map's own size */
|
|
259
303
|
scale?: number;
|
|
260
304
|
};
|
|
261
305
|
}
|
|
@@ -333,6 +377,7 @@ export interface ColorToAlphaOptions {
|
|
|
333
377
|
/**
|
|
334
378
|
* Text metadata written into PNGs
|
|
335
379
|
* @deprecated Use {@link Metadata}, which all encoders take
|
|
380
|
+
* @group Deprecated
|
|
336
381
|
*/
|
|
337
382
|
export type PNGMetadata = Metadata;
|
|
338
383
|
/**
|
|
@@ -341,9 +386,9 @@ export type PNGMetadata = Metadata;
|
|
|
341
386
|
*/
|
|
342
387
|
export declare class Image {
|
|
343
388
|
/**
|
|
344
|
-
* Creates a new image with the given dimensions
|
|
345
|
-
* @param width
|
|
346
|
-
* @param height
|
|
389
|
+
* Creates a new image with the given dimensions, all pixels transparent black
|
|
390
|
+
* @param width The width in pixels
|
|
391
|
+
* @param height The height in pixels
|
|
347
392
|
*/
|
|
348
393
|
constructor(width: number, height: number);
|
|
349
394
|
/**
|
|
@@ -351,13 +396,20 @@ export declare class Image {
|
|
|
351
396
|
* displays. {@link Image.encodeJPEG} writes it. `null` removes it
|
|
352
397
|
*/
|
|
353
398
|
get gainMap(): GainMap | null;
|
|
399
|
+
/**
|
|
400
|
+
* Replaces the gain map
|
|
401
|
+
* @param gainMap The new gain map, or `null` to remove it
|
|
402
|
+
*/
|
|
354
403
|
set gainMap(gainMap: GainMap | null);
|
|
355
404
|
/**
|
|
356
405
|
* The image's RGBA pixel data. It can be replaced by any 8-bit array with width * height * 4 bytes
|
|
357
406
|
* (it is used as is, without copying)
|
|
358
407
|
*/
|
|
359
408
|
get bitmap(): Uint8ClampedArray;
|
|
360
|
-
/**
|
|
409
|
+
/**
|
|
410
|
+
* Replaces the pixel data
|
|
411
|
+
* @param bitmap The new RGBA data, width * height * 4 bytes (used as is, without copying)
|
|
412
|
+
*/
|
|
361
413
|
set bitmap(bitmap: Uint8ClampedArray | Uint8Array);
|
|
362
414
|
/** A short description for debugging, e.g. `Image<64x64>` */
|
|
363
415
|
toString(): string;
|
|
@@ -385,7 +437,8 @@ export declare class Image {
|
|
|
385
437
|
* @param g green (0..255)
|
|
386
438
|
* @param b blue (0..255)
|
|
387
439
|
* @param a alpha (0..255)
|
|
388
|
-
* @
|
|
440
|
+
* @deprecated Use {@link Colors.fromRGBA}, `Image.rgbaToColor` will be removed in 4.0
|
|
441
|
+
* @group Deprecated
|
|
389
442
|
*/
|
|
390
443
|
static rgbaToColor(r: number, g: number, b: number, a: number): Color;
|
|
391
444
|
/**
|
|
@@ -393,7 +446,8 @@ export declare class Image {
|
|
|
393
446
|
* @param r red (0..255)
|
|
394
447
|
* @param g green (0..255)
|
|
395
448
|
* @param b blue (0..255)
|
|
396
|
-
* @
|
|
449
|
+
* @deprecated Use {@link Colors.fromRGB}, `Image.rgbToColor` will be removed in 4.0
|
|
450
|
+
* @group Deprecated
|
|
397
451
|
*/
|
|
398
452
|
static rgbToColor(r: number, g: number, b: number): Color;
|
|
399
453
|
/**
|
|
@@ -402,7 +456,8 @@ export declare class Image {
|
|
|
402
456
|
* @param s saturation (0..1)
|
|
403
457
|
* @param l lightness (0..1)
|
|
404
458
|
* @param a opacity (0..1)
|
|
405
|
-
* @
|
|
459
|
+
* @deprecated Use {@link Colors.fromHSLA}, `Image.hslaToColor` will be removed in 4.0
|
|
460
|
+
* @group Deprecated
|
|
406
461
|
*/
|
|
407
462
|
static hslaToColor(h: number, s: number, l: number, a: number): Color;
|
|
408
463
|
/**
|
|
@@ -410,60 +465,65 @@ export declare class Image {
|
|
|
410
465
|
* @param h hue (0..1)
|
|
411
466
|
* @param s saturation (0..1)
|
|
412
467
|
* @param l lightness (0..1)
|
|
413
|
-
* @
|
|
468
|
+
* @deprecated Use {@link Colors.fromHSL}, `Image.hslToColor` will be removed in 4.0
|
|
469
|
+
* @group Deprecated
|
|
414
470
|
*/
|
|
415
471
|
static hslToColor(h: number, s: number, l: number): Color;
|
|
416
472
|
/**
|
|
417
473
|
* Converts an RGBA value to an array of HSLA values
|
|
418
|
-
* @param r
|
|
419
|
-
* @param g
|
|
420
|
-
* @param b
|
|
421
|
-
* @param a
|
|
422
|
-
* @
|
|
474
|
+
* @param r red (0..255)
|
|
475
|
+
* @param g green (0..255)
|
|
476
|
+
* @param b blue (0..255)
|
|
477
|
+
* @param a alpha (0..255)
|
|
478
|
+
* @deprecated Use {@link Colors.toHSLA}, `Image.rgbaToHSLA` will be removed in 4.0
|
|
479
|
+
* @group Deprecated
|
|
423
480
|
*/
|
|
424
481
|
static rgbaToHSLA(r: number, g: number, b: number, a: number): [h: number, s: number, l: number, a: number];
|
|
425
482
|
/**
|
|
426
483
|
* Converts a color value to an array of RGBA values
|
|
427
484
|
* @param color The color value to convert
|
|
428
|
-
* @
|
|
485
|
+
* @deprecated Use {@link Colors.toRGBA}, `Image.colorToRGBA` will be removed in 4.0
|
|
486
|
+
* @group Deprecated
|
|
429
487
|
*/
|
|
430
488
|
static colorToRGBA(color: Color): [r: number, g: number, b: number, a: number];
|
|
431
489
|
/**
|
|
432
490
|
* Converts a color value to an array of RGB values (ignoring the colors alpha)
|
|
433
491
|
* @param color The color value to convert
|
|
434
|
-
* @
|
|
492
|
+
* @deprecated Use {@link Colors.toRGB}, `Image.colorToRGB` will be removed in 4.0
|
|
493
|
+
* @group Deprecated
|
|
435
494
|
*/
|
|
436
495
|
static colorToRGB(color: Color): [r: number, g: number, b: number];
|
|
496
|
+
/**
|
|
497
|
+
* Creates a multi-point gradient generator
|
|
498
|
+
* @param colors The gradient points to use (e.g. `{0: 0xff0000ff, 1: 0x00ff00ff}`)
|
|
499
|
+
* @deprecated Use {@link Colors.gradient}, `Image.gradient` will be removed in 4.0
|
|
500
|
+
* @group Deprecated
|
|
501
|
+
*/
|
|
502
|
+
static gradient(colors: Record<number, Color>): (position: number) => Color;
|
|
437
503
|
/**
|
|
438
504
|
* Gets the pixel color at the specified position (0-based)
|
|
439
|
-
* @param x
|
|
440
|
-
* @param y
|
|
441
|
-
* @returns The color value
|
|
505
|
+
* @param x The x coordinate
|
|
506
|
+
* @param y The y coordinate
|
|
507
|
+
* @returns The color value (`0xRRGGBBAA`)
|
|
442
508
|
*/
|
|
443
509
|
getPixelAt(x: number, y: number): Color;
|
|
444
510
|
/**
|
|
445
511
|
* 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
|
|
512
|
+
* @param x The x coordinate
|
|
513
|
+
* @param y The y coordinate
|
|
514
|
+
* @returns The pixel's 4 bytes in {@link Image.bitmap}: writing to them changes the pixel
|
|
449
515
|
*/
|
|
450
516
|
getRGBAAt(x: number, y: number): Uint8ClampedArray;
|
|
451
517
|
/**
|
|
452
518
|
* Sets the pixel color for the specified position (0-based)
|
|
453
|
-
* @param x
|
|
454
|
-
* @param y
|
|
455
|
-
* @param pixelColor
|
|
519
|
+
* @param x The x coordinate
|
|
520
|
+
* @param y The y coordinate
|
|
521
|
+
* @param pixelColor The new color (`0xRRGGBBAA`)
|
|
456
522
|
*/
|
|
457
523
|
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
524
|
/**
|
|
465
525
|
* Fills the image data with the supplied color
|
|
466
|
-
* @param color
|
|
526
|
+
* @param color The color, or a function returning the color of each pixel
|
|
467
527
|
*/
|
|
468
528
|
fill(color: Color | ColorFunction): this;
|
|
469
529
|
/**
|
|
@@ -471,25 +531,30 @@ export declare class Image {
|
|
|
471
531
|
*/
|
|
472
532
|
clone(): Image;
|
|
473
533
|
/**
|
|
474
|
-
* Use {@link
|
|
534
|
+
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
535
|
+
* @group Deprecated
|
|
475
536
|
*/
|
|
476
|
-
static
|
|
537
|
+
static readonly RESIZE_NEAREST_NEIGHBOR: typeof ResizeModes.NEAREST_NEIGHBOR;
|
|
477
538
|
/**
|
|
478
|
-
*
|
|
539
|
+
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
540
|
+
* @group Deprecated
|
|
479
541
|
*/
|
|
480
|
-
static
|
|
542
|
+
static readonly RESIZE_BILINEAR: typeof ResizeModes.BILINEAR;
|
|
481
543
|
/**
|
|
482
|
-
*
|
|
544
|
+
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
545
|
+
* @group Deprecated
|
|
483
546
|
*/
|
|
484
|
-
static
|
|
547
|
+
static readonly RESIZE_BICUBIC: typeof ResizeModes.BICUBIC;
|
|
485
548
|
/**
|
|
486
|
-
*
|
|
549
|
+
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
550
|
+
* @group Deprecated
|
|
487
551
|
*/
|
|
488
|
-
static
|
|
552
|
+
static readonly RESIZE_AREA: typeof ResizeModes.AREA;
|
|
489
553
|
/**
|
|
490
|
-
*
|
|
554
|
+
* @deprecated Use {@link ResizeModes.AUTO}, `Image.RESIZE_*` will be removed in 4.0
|
|
555
|
+
* @group Deprecated
|
|
491
556
|
*/
|
|
492
|
-
static
|
|
557
|
+
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
493
558
|
/**
|
|
494
559
|
* Resizes the image by the given factor
|
|
495
560
|
* @param factor The factor to resize the image with
|
|
@@ -499,12 +564,12 @@ export declare class Image {
|
|
|
499
564
|
/**
|
|
500
565
|
* Resizes the image by the given factor
|
|
501
566
|
* @param factor The factor to resize the image with
|
|
502
|
-
* @param [mode=
|
|
567
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
503
568
|
*/
|
|
504
569
|
scale(factor: number, mode?: ResizeMode): this;
|
|
505
570
|
/**
|
|
506
571
|
* Resizes the image to the given dimensions.
|
|
507
|
-
* Use {@link
|
|
572
|
+
* Use {@link ResizeModes.AUTO} as either width or height to automatically preserve the aspect ratio.
|
|
508
573
|
* @param width The new width
|
|
509
574
|
* @param height The new height
|
|
510
575
|
* @param options See {@link ResizeOptions}
|
|
@@ -513,10 +578,10 @@ export declare class Image {
|
|
|
513
578
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
514
579
|
/**
|
|
515
580
|
* Resizes the image to the given dimensions.
|
|
516
|
-
* Use {@link
|
|
581
|
+
* Use {@link ResizeModes.AUTO} as either width or height to automatically preserve the aspect ratio.
|
|
517
582
|
* @param width The new width
|
|
518
583
|
* @param height The new height
|
|
519
|
-
* @param [mode=
|
|
584
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
520
585
|
* @returns The resized image
|
|
521
586
|
*/
|
|
522
587
|
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
@@ -534,7 +599,7 @@ export declare class Image {
|
|
|
534
599
|
* Can return an image with one axis smaller than the given bounding box.
|
|
535
600
|
* @param width The width of the bounding box
|
|
536
601
|
* @param height The height of the bounding box
|
|
537
|
-
* @param [mode=
|
|
602
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
538
603
|
* @returns The resized image
|
|
539
604
|
*/
|
|
540
605
|
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
@@ -552,7 +617,7 @@ export declare class Image {
|
|
|
552
617
|
* Always returns the exact dimensions of the bounding box.
|
|
553
618
|
* @param width The width of the bounding box
|
|
554
619
|
* @param height The height of the bounding box
|
|
555
|
-
* @param [mode=
|
|
620
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
556
621
|
* @returns The resized image
|
|
557
622
|
*/
|
|
558
623
|
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
@@ -570,7 +635,7 @@ export declare class Image {
|
|
|
570
635
|
* Always returns the exact dimensions of the bounding box.
|
|
571
636
|
* @param width The width of the bounding box
|
|
572
637
|
* @param height The height of the bounding box
|
|
573
|
-
* @param [mode=
|
|
638
|
+
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
574
639
|
* @returns The resized image
|
|
575
640
|
*/
|
|
576
641
|
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
@@ -631,75 +696,87 @@ export declare class Image {
|
|
|
631
696
|
*/
|
|
632
697
|
cropCircle(max?: boolean, feathering?: number): this;
|
|
633
698
|
/**
|
|
634
|
-
* Sets the
|
|
635
|
-
*
|
|
699
|
+
* Sets the RGB of every pixel to the given color, keeping each pixel's own alpha. Turns an image into a silhouette
|
|
700
|
+
* or tints it: `image.recolor(0xffffffff)` makes every pixel white, keeping its transparency
|
|
701
|
+
* @param color The color to use, its alpha is ignored
|
|
702
|
+
*/
|
|
703
|
+
recolor(color: Color): this;
|
|
704
|
+
/**
|
|
705
|
+
* Scales the opacity of the image
|
|
706
|
+
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
636
707
|
* @param options See {@link AdjustOptions}
|
|
637
708
|
*/
|
|
638
709
|
opacity(opacity: number, options?: AdjustOptions): this;
|
|
639
710
|
/**
|
|
640
|
-
*
|
|
641
|
-
* @param opacity The
|
|
642
|
-
* @param absolute Whether to
|
|
711
|
+
* Scales the opacity of the image
|
|
712
|
+
* @param opacity The factor to multiply the opacity with (0..1 lowers it, >1 raises it, results are clamped)
|
|
713
|
+
* @param absolute Whether to set the opacity (true) instead of scaling it (false)
|
|
714
|
+
* @deprecated Use {@link Image.opacity} to scale; for a fixed alpha, `absolute` is removed in 4.0
|
|
643
715
|
*/
|
|
644
716
|
opacity(opacity: number, absolute?: boolean): this;
|
|
645
717
|
/**
|
|
646
|
-
* Scales
|
|
647
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
718
|
+
* Scales the red channel
|
|
719
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
648
720
|
* @param options See {@link AdjustOptions}
|
|
649
721
|
*/
|
|
650
722
|
red(factor: number, options?: AdjustOptions): this;
|
|
651
723
|
/**
|
|
652
|
-
* Scales
|
|
653
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
654
|
-
* @param absolute Whether to
|
|
724
|
+
* Scales the red channel
|
|
725
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
726
|
+
* @param absolute Whether to set every pixel's red channel to `factor` * 255 (true) instead of scaling it (false)
|
|
727
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
655
728
|
*/
|
|
656
729
|
red(factor: number, absolute?: boolean): this;
|
|
657
730
|
/**
|
|
658
|
-
* Scales
|
|
659
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
731
|
+
* Scales the green channel
|
|
732
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
660
733
|
* @param options See {@link AdjustOptions}
|
|
661
734
|
*/
|
|
662
735
|
green(factor: number, options?: AdjustOptions): this;
|
|
663
736
|
/**
|
|
664
|
-
* Scales
|
|
665
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
666
|
-
* @param absolute Whether to
|
|
737
|
+
* Scales the green channel
|
|
738
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
739
|
+
* @param absolute Whether to set every pixel's green channel to `factor` * 255 (true) instead of scaling it (false)
|
|
740
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
667
741
|
*/
|
|
668
742
|
green(factor: number, absolute?: boolean): this;
|
|
669
743
|
/**
|
|
670
|
-
* Scales
|
|
671
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
744
|
+
* Scales the blue channel
|
|
745
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
672
746
|
* @param options See {@link AdjustOptions}
|
|
673
747
|
*/
|
|
674
748
|
blue(factor: number, options?: AdjustOptions): this;
|
|
675
749
|
/**
|
|
676
|
-
* Scales
|
|
677
|
-
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
678
|
-
* @param absolute Whether to
|
|
750
|
+
* Scales the blue channel
|
|
751
|
+
* @param factor The factor to multiply the channel with (>= 0, results are clamped)
|
|
752
|
+
* @param absolute Whether to set every pixel's blue channel to `factor` * 255 (true) instead of scaling it (false)
|
|
753
|
+
* @deprecated Use {@link Image.recolor} to set a fixed color; `absolute` is removed in 4.0
|
|
679
754
|
*/
|
|
680
755
|
blue(factor: number, absolute?: boolean): this;
|
|
681
756
|
/**
|
|
682
|
-
*
|
|
683
|
-
* @param value The
|
|
757
|
+
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
758
|
+
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
684
759
|
* @param options See {@link AdjustOptions}
|
|
685
760
|
*/
|
|
686
761
|
lightness(value: number, options?: AdjustOptions): this;
|
|
687
762
|
/**
|
|
688
|
-
*
|
|
689
|
-
* @param value The
|
|
690
|
-
* @param absolute Whether to
|
|
763
|
+
* Scales the lightness of the image (HSL), keeping its hue and saturation
|
|
764
|
+
* @param value The factor to multiply the lightness with (>= 0, results are clamped)
|
|
765
|
+
* @param absolute Whether to set the lightness (true) instead of scaling it (false)
|
|
766
|
+
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
691
767
|
*/
|
|
692
768
|
lightness(value: number, absolute?: boolean): this;
|
|
693
769
|
/**
|
|
694
|
-
*
|
|
695
|
-
* @param value The
|
|
770
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
771
|
+
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
696
772
|
* @param options See {@link AdjustOptions}
|
|
697
773
|
*/
|
|
698
774
|
saturation(value: number, options?: AdjustOptions): this;
|
|
699
775
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @param value The
|
|
702
|
-
* @param absolute Whether to
|
|
776
|
+
* Scales the saturation of the image (HSL), keeping its hue and lightness. 0 makes it greyscale
|
|
777
|
+
* @param value The factor to multiply the saturation with (>= 0, results are clamped)
|
|
778
|
+
* @param absolute Whether to set the saturation (true) instead of scaling it (false)
|
|
779
|
+
* @deprecated `absolute` is removed in 4.0: scale with a factor, or use {@link Image.recolor} for a fixed color
|
|
703
780
|
*/
|
|
704
781
|
saturation(value: number, absolute?: boolean): this;
|
|
705
782
|
/**
|
|
@@ -821,12 +898,6 @@ export declare class Image {
|
|
|
821
898
|
* @param direction The direction to flip
|
|
822
899
|
*/
|
|
823
900
|
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
901
|
/**
|
|
831
902
|
* Rounds the images corners, with antialiased edges
|
|
832
903
|
* @param options See {@link RoundCornersOptions}
|
|
@@ -869,6 +940,7 @@ export declare class Image {
|
|
|
869
940
|
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
870
941
|
/**
|
|
871
942
|
* Encodes the image into a PNG, an alias of {@link Image.encode}
|
|
943
|
+
* @param options See {@link PNGEncodeOptions}
|
|
872
944
|
*/
|
|
873
945
|
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
874
946
|
/**
|
|
@@ -945,17 +1017,20 @@ export declare class Image {
|
|
|
945
1017
|
*/
|
|
946
1018
|
static decode(input: BinaryData, options?: DecodeOptions): Promise<Image>;
|
|
947
1019
|
/**
|
|
948
|
-
*
|
|
1020
|
+
* @deprecated Use {@link SVGScaleModes.SCALE}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1021
|
+
* @group Deprecated
|
|
949
1022
|
*/
|
|
950
|
-
static
|
|
1023
|
+
static readonly SVG_MODE_SCALE: typeof SVGScaleModes.SCALE;
|
|
951
1024
|
/**
|
|
952
|
-
*
|
|
1025
|
+
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1026
|
+
* @group Deprecated
|
|
953
1027
|
*/
|
|
954
|
-
static
|
|
1028
|
+
static readonly SVG_MODE_WIDTH: typeof SVGScaleModes.WIDTH;
|
|
955
1029
|
/**
|
|
956
|
-
*
|
|
1030
|
+
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1031
|
+
* @group Deprecated
|
|
957
1032
|
*/
|
|
958
|
-
static
|
|
1033
|
+
static readonly SVG_MODE_HEIGHT: typeof SVGScaleModes.HEIGHT;
|
|
959
1034
|
/**
|
|
960
1035
|
* Creates a new image from the given SVG
|
|
961
1036
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
@@ -970,7 +1045,7 @@ export declare class Image {
|
|
|
970
1045
|
* Creates a new image from the given SVG
|
|
971
1046
|
* @param svg The SVG content
|
|
972
1047
|
* @param size The size to use
|
|
973
|
-
* @param mode The SVG resizing mode to use (one of {@link
|
|
1048
|
+
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
974
1049
|
* @return The rendered SVG graphic
|
|
975
1050
|
*/
|
|
976
1051
|
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|