imagescript 3.16.1 → 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/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 Image.RESIZE_BILINEAR} etc. */
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: {@link Image.SVG_MODE_SCALE}, {@link Image.SVG_MODE_WIDTH} or {@link Image.SVG_MODE_HEIGHT} */
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 Image.RESIZE_BILINEAR} */
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 Image.RESIZE_BILINEAR} and {@link Image.RESIZE_AREA},
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
- /** Whether to set the value (true) or scale the current one (false). Default: `false` */
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
- * `quality` the map's JPEG quality (default: `90`), `scale` its size as a factor of the image's (0-1, default: the
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 Image.SVG_MODE_SCALE}, {@link Image.SVG_MODE_WIDTH}, {@link Image.SVG_MODE_HEIGHT}.
139
- * Default: {@link Image.SVG_MODE_SCALE}
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
- * `quality` (1-100 like `quality`, 100 lossless; default `90`) and `scale` (its size relative to the image, default
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: `quality` (1-100, default `90`) and `scale` (its size relative to the image, default its own).
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
- /** Replaces the pixel data, the array has to hold width * height * 4 bytes */
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
- * @returns RGBA value
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
- * @returns RGBA value
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
- * @returns color
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
- * @returns color
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 {number} (0..255)
419
- * @param g {number} (0..255)
420
- * @param b {number} (0..255)
421
- * @param a {number} (0..255)
422
- * @returns The HSLA values ([H, S, L, A])
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
- * @returns The RGBA values ([R, G, B, A])
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
- * @returns The RGB values ([R, G, B])
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 RGBA value
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 https://en.wikipedia.org/wiki/Image_scaling#Nearest-neighbor_interpolation Nearest-neighbor} resizing.
534
+ * @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
535
+ * @group Deprecated
475
536
  */
476
- static get RESIZE_NEAREST_NEIGHBOR(): 'RESIZE_NEAREST_NEIGHBOR';
537
+ static readonly RESIZE_NEAREST_NEIGHBOR: typeof ResizeModes.NEAREST_NEIGHBOR;
477
538
  /**
478
- * Bilinear resizing (the default). When shrinking, the filter widens with the scale factor, so every source pixel contributes
539
+ * @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
540
+ * @group Deprecated
479
541
  */
480
- static get RESIZE_BILINEAR(): 'RESIZE_BILINEAR';
542
+ static readonly RESIZE_BILINEAR: typeof ResizeModes.BILINEAR;
481
543
  /**
482
- * Bicubic (Catmull-Rom) resizing, sharper than bilinear, especially when enlarging
544
+ * @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
545
+ * @group Deprecated
483
546
  */
484
- static get RESIZE_BICUBIC(): 'RESIZE_BICUBIC';
547
+ static readonly RESIZE_BICUBIC: typeof ResizeModes.BICUBIC;
485
548
  /**
486
- * Area averaging (box filter): every output pixel is the average of the source pixels it covers. Meant for shrinking
549
+ * @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
550
+ * @group Deprecated
487
551
  */
488
- static get RESIZE_AREA(): 'RESIZE_AREA';
552
+ static readonly RESIZE_AREA: typeof ResizeModes.AREA;
489
553
  /**
490
- * Used for automatically preserving an images aspect ratio when resizing.
554
+ * @deprecated Use {@link ResizeModes.AUTO}, `Image.RESIZE_*` will be removed in 4.0
555
+ * @group Deprecated
491
556
  */
492
- static get RESIZE_AUTO(): -1;
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=Image.RESIZE_BILINEAR] The resizing mode to use
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 Image.RESIZE_AUTO} as either width or height to automatically preserve the aspect ratio.
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 Image.RESIZE_AUTO} as either width or height to automatically preserve the aspect ratio.
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=Image.RESIZE_BILINEAR] The resizing mode to use
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=Image.RESIZE_BILINEAR] The resizing mode to use
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=Image.RESIZE_BILINEAR] The resizing mode to use
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=Image.RESIZE_BILINEAR] The resizing mode to use
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 images opacity
635
- * @param opacity The opacity to apply (0..1)
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
- * Sets the images opacity
641
- * @param opacity The opacity to apply (0..1)
642
- * @param absolute Whether to scale the current opacity (false) or just set the new opacity (true)
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 or sets the red channel
647
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
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 or sets the red channel
653
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
654
- * @param absolute Whether to scale the current value (false) or set every pixel's red channel to `factor` * 255 (true)
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 or sets the green channel
659
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
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 or sets the green channel
665
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
666
- * @param absolute Whether to scale the current value (false) or set every pixel's green channel to `factor` * 255 (true)
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 or sets the blue channel
671
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
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 or sets the blue channel
677
- * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
678
- * @param absolute Whether to scale the current value (false) or set every pixel's blue channel to `factor` * 255 (true)
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
- * Sets the brightness of the image
683
- * @param value The lightness to apply (0..1)
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
- * Sets the brightness of the image
689
- * @param value The lightness to apply (0..1)
690
- * @param absolute Whether to scale the current lightness (false) or just set the new lightness (true)
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
- * Sets the saturation of the image
695
- * @param value The saturation to apply (0..1)
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
- * Sets the saturation of the image
701
- * @param value The saturation to apply (0..1)
702
- * @param absolute Whether to scale the current saturation (false) or just set the new saturation (true)
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
- * Scale the SVG by the given amount. For use with {@link Image.renderSVG}
1020
+ * @deprecated Use {@link SVGScaleModes.SCALE}, `Image.SVG_MODE_*` will be removed in 4.0
1021
+ * @group Deprecated
949
1022
  */
950
- static get SVG_MODE_SCALE(): 1;
1023
+ static readonly SVG_MODE_SCALE: typeof SVGScaleModes.SCALE;
951
1024
  /**
952
- * Scale the SVG to fit the given width. For use with {@link Image.renderSVG}
1025
+ * @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
1026
+ * @group Deprecated
953
1027
  */
954
- static get SVG_MODE_WIDTH(): 2;
1028
+ static readonly SVG_MODE_WIDTH: typeof SVGScaleModes.WIDTH;
955
1029
  /**
956
- * Scale the SVG to fit the given height. For use with {@link Image.renderSVG}
1030
+ * @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
1031
+ * @group Deprecated
957
1032
  */
958
- static get SVG_MODE_HEIGHT(): 3;
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 SVG_MODE_SCALE}, {@link SVG_MODE_WIDTH}, {@link SVG_MODE_HEIGHT})
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>;