imagescript 3.17.0 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +5 -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 +162 -34
- package/dist/image.js +69 -31
- 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/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} */
|
|
@@ -198,6 +217,22 @@ export interface TextOptions extends TextStyle {
|
|
|
198
217
|
/** The text layout. Default: `new TextLayout()` */
|
|
199
218
|
layout?: TextLayout;
|
|
200
219
|
}
|
|
220
|
+
/** Options of {@link Image.renderText}: the font and size, the text color and layout, and its style (see {@link TextStyle}) */
|
|
221
|
+
export interface RenderTextOptions extends TextStyle {
|
|
222
|
+
/**
|
|
223
|
+
* TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every character comes
|
|
224
|
+
* from the first font that has it (e.g. `[text, emoji]`), the first one sets the line height. Color glyphs (COLR
|
|
225
|
+
* layers and paints, CBDT and sbix bitmaps, as in emoji fonts) keep their colors. Text in any script is shaped
|
|
226
|
+
* like browsers do (right to left and bidirectional text, Arabic joining, Indic conjuncts, marks)
|
|
227
|
+
*/
|
|
228
|
+
font: BinaryData | BinaryData[];
|
|
229
|
+
/** Font size in pixels (per em) */
|
|
230
|
+
size: number;
|
|
231
|
+
/** The text color. Default: `0xffffffff` */
|
|
232
|
+
color?: Color;
|
|
233
|
+
/** The text layout, as {@link TextLayoutOptions} or a {@link TextLayout}. Default: the defaults of `TextLayout` */
|
|
234
|
+
layout?: TextLayoutOptions | TextLayout;
|
|
235
|
+
}
|
|
201
236
|
/** Options of {@link Image.decode} */
|
|
202
237
|
export interface DecodeOptions {
|
|
203
238
|
/** Whether to rotate/mirror JPEGs, TIFFs, PNGs and WebPs as their orientation tag (Exif or XMP) says. Default: `true` */
|
|
@@ -333,7 +368,16 @@ export interface TextStyle {
|
|
|
333
368
|
}
|
|
334
369
|
/** Options of {@link Image.cropCircle} */
|
|
335
370
|
export interface CropCircleOptions {
|
|
336
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* The circle's size: `'contain'` fits it inside the image (the smaller dimension is its diameter, no hard edges),
|
|
373
|
+
* `'cover'` covers the image (the larger dimension is its diameter, the corners of a rectangular image stay
|
|
374
|
+
* transparent on the shorter side). Default: `'contain'`
|
|
375
|
+
*/
|
|
376
|
+
size?: 'contain' | 'cover';
|
|
377
|
+
/**
|
|
378
|
+
* Whether to use the larger dimension for the size. Default: `false`
|
|
379
|
+
* @deprecated Use `size: 'cover'` (`true`) or `size: 'contain'` (`false`), `max` will be removed in 4.0
|
|
380
|
+
*/
|
|
337
381
|
max?: boolean;
|
|
338
382
|
/** Share of the radius (0..1) over which the edge fades out. Default: `0` */
|
|
339
383
|
feathering?: number;
|
|
@@ -361,6 +405,11 @@ export interface RotateOptions {
|
|
|
361
405
|
}
|
|
362
406
|
/** Options of {@link Image.trim} */
|
|
363
407
|
export interface TrimOptions {
|
|
408
|
+
/**
|
|
409
|
+
* The border color, by default the color of the top left pixel. Fully transparent pixels count as the same color
|
|
410
|
+
* whatever their RGB values
|
|
411
|
+
*/
|
|
412
|
+
color?: Color;
|
|
364
413
|
/**
|
|
365
414
|
* How far (0-1) a pixel's channels may be from the color for it to be trimmed, e.g. for JPEG artifacts or
|
|
366
415
|
* antialiasing. Default: `0`
|
|
@@ -369,6 +418,8 @@ export interface TrimOptions {
|
|
|
369
418
|
}
|
|
370
419
|
/** Options of {@link Image.colorToAlpha} */
|
|
371
420
|
export interface ColorToAlphaOptions {
|
|
421
|
+
/** The color to remove, by default the color of the top left pixel (e.g. a background) */
|
|
422
|
+
color?: Color;
|
|
372
423
|
/** Pixels at most this far from the color (0-1) become fully transparent. Default: 0 */
|
|
373
424
|
transparencyThreshold?: number;
|
|
374
425
|
/** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
|
|
@@ -421,14 +472,28 @@ export declare class Image {
|
|
|
421
472
|
* The images height
|
|
422
473
|
*/
|
|
423
474
|
get height(): number;
|
|
475
|
+
/**
|
|
476
|
+
* Yields an [x, y] array for every pixel in the image (0-based), row by row
|
|
477
|
+
* @yields The coordinates of the pixel ([x, y])
|
|
478
|
+
*/
|
|
479
|
+
coordinates(): Generator<[x: number, y: number], void, undefined>;
|
|
480
|
+
/**
|
|
481
|
+
* Yields an [x, y, color] array for every pixel in the image (0-based), row by row
|
|
482
|
+
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
483
|
+
*/
|
|
484
|
+
pixels(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
424
485
|
/**
|
|
425
486
|
* Yields an [x, y] array for every pixel in the image (0-based)
|
|
426
487
|
* @yields The coordinates of the pixel ([x, y])
|
|
488
|
+
* @deprecated Use {@link Image.coordinates}, iterating over the image will be removed in 4.0
|
|
489
|
+
* @group Deprecated
|
|
427
490
|
*/
|
|
428
491
|
[Symbol.iterator](): Generator<[x: number, y: number], void, undefined>;
|
|
429
492
|
/**
|
|
430
493
|
* Yields an [x, y, color] array for every pixel in the image (0-based)
|
|
431
494
|
* @yields The coordinates and color of the pixel ([x, y, color])
|
|
495
|
+
* @deprecated Use {@link Image.pixels}, `iterateWithColors()` will be removed in 4.0
|
|
496
|
+
* @group Deprecated
|
|
432
497
|
*/
|
|
433
498
|
iterateWithColors(): Generator<[x: number, y: number, color: Color], void, undefined>;
|
|
434
499
|
/**
|
|
@@ -534,24 +599,25 @@ export declare class Image {
|
|
|
534
599
|
* @deprecated Use {@link ResizeModes.NEAREST_NEIGHBOR}, `Image.RESIZE_*` will be removed in 4.0
|
|
535
600
|
* @group Deprecated
|
|
536
601
|
*/
|
|
537
|
-
static readonly RESIZE_NEAREST_NEIGHBOR
|
|
602
|
+
static readonly RESIZE_NEAREST_NEIGHBOR = "RESIZE_NEAREST_NEIGHBOR";
|
|
538
603
|
/**
|
|
539
604
|
* @deprecated Use {@link ResizeModes.BILINEAR}, `Image.RESIZE_*` will be removed in 4.0
|
|
540
605
|
* @group Deprecated
|
|
541
606
|
*/
|
|
542
|
-
static readonly RESIZE_BILINEAR
|
|
607
|
+
static readonly RESIZE_BILINEAR = "RESIZE_BILINEAR";
|
|
543
608
|
/**
|
|
544
609
|
* @deprecated Use {@link ResizeModes.BICUBIC}, `Image.RESIZE_*` will be removed in 4.0
|
|
545
610
|
* @group Deprecated
|
|
546
611
|
*/
|
|
547
|
-
static readonly RESIZE_BICUBIC
|
|
612
|
+
static readonly RESIZE_BICUBIC = "RESIZE_BICUBIC";
|
|
548
613
|
/**
|
|
549
614
|
* @deprecated Use {@link ResizeModes.AREA}, `Image.RESIZE_*` will be removed in 4.0
|
|
550
615
|
* @group Deprecated
|
|
551
616
|
*/
|
|
552
|
-
static readonly RESIZE_AREA
|
|
617
|
+
static readonly RESIZE_AREA = "RESIZE_AREA";
|
|
553
618
|
/**
|
|
554
|
-
* @deprecated
|
|
619
|
+
* @deprecated Pass only the width or the height instead, `image.resize({ width: 256 })`. `Image.RESIZE_*` will
|
|
620
|
+
* be removed in 4.0
|
|
555
621
|
* @group Deprecated
|
|
556
622
|
*/
|
|
557
623
|
static readonly RESIZE_AUTO: typeof ResizeModes.AUTO;
|
|
@@ -565,11 +631,12 @@ export declare class Image {
|
|
|
565
631
|
* Resizes the image by the given factor
|
|
566
632
|
* @param factor The factor to resize the image with
|
|
567
633
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
634
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
568
635
|
*/
|
|
569
636
|
scale(factor: number, mode?: ResizeMode): this;
|
|
570
637
|
/**
|
|
571
638
|
* Resizes the image to the given dimensions.
|
|
572
|
-
*
|
|
639
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
573
640
|
* @param width The new width
|
|
574
641
|
* @param height The new height
|
|
575
642
|
* @param options See {@link ResizeOptions}
|
|
@@ -578,13 +645,20 @@ export declare class Image {
|
|
|
578
645
|
resize(width: number, height: number, options?: ResizeOptions): this;
|
|
579
646
|
/**
|
|
580
647
|
* Resizes the image to the given dimensions.
|
|
581
|
-
*
|
|
648
|
+
* Pass {@link ResizeToOptions} with only a width or a height to keep the aspect ratio.
|
|
582
649
|
* @param width The new width
|
|
583
650
|
* @param height The new height
|
|
584
651
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
585
652
|
* @returns The resized image
|
|
653
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
586
654
|
*/
|
|
587
655
|
resize(width: number, height: number, mode?: ResizeMode): this;
|
|
656
|
+
/**
|
|
657
|
+
* Resizes the image: to the given width or height (the other side keeps the aspect ratio), or to both
|
|
658
|
+
* @param options The size and how to resize, see {@link ResizeToOptions}
|
|
659
|
+
* @returns The resized image
|
|
660
|
+
*/
|
|
661
|
+
resize(options: ResizeToOptions): this;
|
|
588
662
|
/**
|
|
589
663
|
* Resizes the image so it is contained in the given bounding box.
|
|
590
664
|
* Can return an image with one axis smaller than the given bounding box.
|
|
@@ -601,6 +675,7 @@ export declare class Image {
|
|
|
601
675
|
* @param height The height of the bounding box
|
|
602
676
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
603
677
|
* @returns The resized image
|
|
678
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
604
679
|
*/
|
|
605
680
|
contain(width: number, height: number, mode?: ResizeMode): this;
|
|
606
681
|
/**
|
|
@@ -619,6 +694,7 @@ export declare class Image {
|
|
|
619
694
|
* @param height The height of the bounding box
|
|
620
695
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
621
696
|
* @returns The resized image
|
|
697
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
622
698
|
*/
|
|
623
699
|
fit(width: number, height: number, mode?: ResizeMode): this;
|
|
624
700
|
/**
|
|
@@ -637,6 +713,7 @@ export declare class Image {
|
|
|
637
713
|
* @param height The height of the bounding box
|
|
638
714
|
* @param [mode=ResizeModes.BILINEAR] The resizing mode to use
|
|
639
715
|
* @returns The resized image
|
|
716
|
+
* @deprecated Pass {@link ResizeOptions} with `mode` instead, the positional mode will be removed in 4.0
|
|
640
717
|
*/
|
|
641
718
|
cover(width: number, height: number, mode?: ResizeMode): this;
|
|
642
719
|
/**
|
|
@@ -658,6 +735,13 @@ export declare class Image {
|
|
|
658
735
|
* @param height The region's height
|
|
659
736
|
*/
|
|
660
737
|
region(x: number, y: number, width: number, height: number): Image;
|
|
738
|
+
/**
|
|
739
|
+
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
740
|
+
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
741
|
+
* unchanged
|
|
742
|
+
* @param options See {@link TrimOptions}
|
|
743
|
+
*/
|
|
744
|
+
trim(options?: TrimOptions): this;
|
|
661
745
|
/**
|
|
662
746
|
* Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
|
|
663
747
|
* Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
|
|
@@ -665,6 +749,7 @@ export declare class Image {
|
|
|
665
749
|
* @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
|
|
666
750
|
* same color whatever their RGB values
|
|
667
751
|
* @param options See {@link TrimOptions}
|
|
752
|
+
* @deprecated Pass {@link TrimOptions} instead, the positional arguments will be removed in 4.0
|
|
668
753
|
*/
|
|
669
754
|
trim(color?: Color, options?: TrimOptions): this;
|
|
670
755
|
/**
|
|
@@ -693,6 +778,8 @@ export declare class Image {
|
|
|
693
778
|
* Crops the image into a circle with an antialiased edge
|
|
694
779
|
* @param max Whether to use the larger dimension for the size. Default: `false`
|
|
695
780
|
* @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
|
|
781
|
+
* @deprecated Pass {@link CropCircleOptions} instead, `cropCircle({ size: 'cover' })`. The arguments will be
|
|
782
|
+
* removed in 4.0
|
|
696
783
|
*/
|
|
697
784
|
cropCircle(max?: boolean, feathering?: number): this;
|
|
698
785
|
/**
|
|
@@ -791,6 +878,7 @@ export declare class Image {
|
|
|
791
878
|
* @param [x=0] The x position to place the image at
|
|
792
879
|
* @param [y=0] The y position to place the image at
|
|
793
880
|
* @param options Opacity and blend mode, see {@link CompositeOptions}
|
|
881
|
+
* @deprecated Pass {@link CompositeOptions} instead, the positional arguments will be removed in 4.0
|
|
794
882
|
*/
|
|
795
883
|
composite(source: Image, x?: number, y?: number, options?: CompositeOptions): this;
|
|
796
884
|
/**
|
|
@@ -825,6 +913,7 @@ export declare class Image {
|
|
|
825
913
|
* Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
|
|
826
914
|
* @param [amount=1] How strongly to sharpen (0 does nothing)
|
|
827
915
|
* @param [radius=1] The radius of the blur the image is compared with (larger values sharpen coarser details)
|
|
916
|
+
* @deprecated Pass {@link SharpenOptions} instead, the positional arguments will be removed in 4.0
|
|
828
917
|
*/
|
|
829
918
|
sharpen(amount?: number, radius?: number): this;
|
|
830
919
|
/**
|
|
@@ -850,6 +939,15 @@ export declare class Image {
|
|
|
850
939
|
* Applies a sepia tone
|
|
851
940
|
*/
|
|
852
941
|
sepia(): this;
|
|
942
|
+
/**
|
|
943
|
+
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
944
|
+
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
945
|
+
* semi-transparent instead of keeping a fringe of it.
|
|
946
|
+
* The color is removed everywhere in the image, not only from a connected background: removing a white
|
|
947
|
+
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
948
|
+
* @param options See {@link ColorToAlphaOptions}
|
|
949
|
+
*/
|
|
950
|
+
colorToAlpha(options?: ColorToAlphaOptions): this;
|
|
853
951
|
/**
|
|
854
952
|
* Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
|
|
855
953
|
* transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
|
|
@@ -858,6 +956,7 @@ export declare class Image {
|
|
|
858
956
|
* background also makes white areas inside the subject (e.g. eyes in a logo) transparent
|
|
859
957
|
* @param color The color to remove, by default the color of the top left pixel (e.g. a background)
|
|
860
958
|
* @param options See {@link ColorToAlphaOptions}
|
|
959
|
+
* @deprecated Pass {@link ColorToAlphaOptions} instead, the positional arguments will be removed in 4.0
|
|
861
960
|
*/
|
|
862
961
|
colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
|
|
863
962
|
/**
|
|
@@ -879,6 +978,7 @@ export declare class Image {
|
|
|
879
978
|
* @param ignoreWhite Whether to ignore light colors (all channels above 255 minus the threshold). Default: `true`
|
|
880
979
|
* @param bwThreshold The black/white threshold (0-64, in steps of 4 channel values). Default: `15`
|
|
881
980
|
* @return The image's dominant color (fully opaque)
|
|
981
|
+
* @deprecated Pass {@link DominantColorOptions} instead, the positional arguments will be removed in 4.0
|
|
882
982
|
*/
|
|
883
983
|
dominantColor(ignoreBlack?: boolean, ignoreWhite?: boolean, bwThreshold?: number): Color;
|
|
884
984
|
/**
|
|
@@ -891,6 +991,7 @@ export declare class Image {
|
|
|
891
991
|
* Rotates the image counterclockwise by the given amount of degrees
|
|
892
992
|
* @param angle The angle to rotate the image for (in degrees)
|
|
893
993
|
* @param resize Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true`
|
|
994
|
+
* @deprecated Pass {@link RotateOptions} instead, the positional arguments will be removed in 4.0
|
|
894
995
|
*/
|
|
895
996
|
rotate(angle: number, resize?: boolean): this;
|
|
896
997
|
/**
|
|
@@ -906,6 +1007,7 @@ export declare class Image {
|
|
|
906
1007
|
/**
|
|
907
1008
|
* Rounds the images corners, with antialiased edges
|
|
908
1009
|
* @param [radius=min(width,height)/4] The radius of the corners
|
|
1010
|
+
* @deprecated Pass {@link RoundCornersOptions} instead, the positional arguments will be removed in 4.0
|
|
909
1011
|
*/
|
|
910
1012
|
roundCorners(radius?: number): this;
|
|
911
1013
|
/**
|
|
@@ -916,6 +1018,7 @@ export declare class Image {
|
|
|
916
1018
|
/**
|
|
917
1019
|
* Applies a fisheye (barrel distortion) effect
|
|
918
1020
|
* @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
|
|
1021
|
+
* @deprecated Pass {@link FisheyeOptions} instead, the positional arguments will be removed in 4.0
|
|
919
1022
|
*/
|
|
920
1023
|
fisheye(strength?: number): this;
|
|
921
1024
|
/**
|
|
@@ -924,36 +1027,47 @@ export declare class Image {
|
|
|
924
1027
|
* @param options See {@link PNGEncodeOptions}
|
|
925
1028
|
* @return The encoded data
|
|
926
1029
|
*/
|
|
927
|
-
|
|
1030
|
+
encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
928
1031
|
/**
|
|
929
1032
|
* Encodes the image into a PNG
|
|
930
1033
|
* @param compression The compression level (0-9). Default: `4`
|
|
931
1034
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
932
1035
|
* @return The encoded data
|
|
1036
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
933
1037
|
*/
|
|
934
|
-
|
|
1038
|
+
encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
935
1039
|
/**
|
|
936
1040
|
* Encodes the image into a PNG with compression level 4
|
|
937
1041
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
938
1042
|
* @return The encoded data
|
|
1043
|
+
* @deprecated Pass {@link PNGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
939
1044
|
*/
|
|
940
|
-
|
|
1045
|
+
encodePNG(metadata?: Metadata): Promise<Uint8Array>;
|
|
941
1046
|
/**
|
|
942
|
-
* Encodes the image into a PNG
|
|
1047
|
+
* Encodes the image into a PNG
|
|
943
1048
|
* @param options See {@link PNGEncodeOptions}
|
|
1049
|
+
* @return The encoded data
|
|
1050
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1051
|
+
* @group Deprecated
|
|
944
1052
|
*/
|
|
945
|
-
|
|
1053
|
+
encode(options?: PNGEncodeOptions): Promise<Uint8Array>;
|
|
946
1054
|
/**
|
|
947
|
-
* Encodes the image into a PNG
|
|
1055
|
+
* Encodes the image into a PNG
|
|
948
1056
|
* @param compression The compression level (0-9). Default: `4`
|
|
949
1057
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1058
|
+
* @return The encoded data
|
|
1059
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1060
|
+
* @group Deprecated
|
|
950
1061
|
*/
|
|
951
|
-
|
|
1062
|
+
encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
|
|
952
1063
|
/**
|
|
953
|
-
* Encodes the image into a PNG
|
|
1064
|
+
* Encodes the image into a PNG with compression level 4
|
|
954
1065
|
* @param metadata Metadata to include, see {@link Metadata}
|
|
1066
|
+
* @return The encoded data
|
|
1067
|
+
* @deprecated Use {@link Image.encodePNG}, `encode()` will be removed in 4.0
|
|
1068
|
+
* @group Deprecated
|
|
955
1069
|
*/
|
|
956
|
-
|
|
1070
|
+
encode(metadata?: Metadata): Promise<Uint8Array>;
|
|
957
1071
|
/**
|
|
958
1072
|
* Encodes the image into a JPEG
|
|
959
1073
|
* @param options See {@link JPEGEncodeOptions}
|
|
@@ -962,6 +1076,7 @@ export declare class Image {
|
|
|
962
1076
|
/**
|
|
963
1077
|
* Encodes the image into a JPEG
|
|
964
1078
|
* @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
|
|
1079
|
+
* @deprecated Pass {@link JPEGEncodeOptions} instead, the positional arguments will be removed in 4.0
|
|
965
1080
|
*/
|
|
966
1081
|
encodeJPEG(quality?: number): Promise<Uint8Array>;
|
|
967
1082
|
/**
|
|
@@ -1020,17 +1135,17 @@ export declare class Image {
|
|
|
1020
1135
|
* @deprecated Use {@link SVGScaleModes.SCALE}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1021
1136
|
* @group Deprecated
|
|
1022
1137
|
*/
|
|
1023
|
-
static readonly SVG_MODE_SCALE
|
|
1138
|
+
static readonly SVG_MODE_SCALE = 1;
|
|
1024
1139
|
/**
|
|
1025
1140
|
* @deprecated Use {@link SVGScaleModes.WIDTH}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1026
1141
|
* @group Deprecated
|
|
1027
1142
|
*/
|
|
1028
|
-
static readonly SVG_MODE_WIDTH
|
|
1143
|
+
static readonly SVG_MODE_WIDTH = 2;
|
|
1029
1144
|
/**
|
|
1030
1145
|
* @deprecated Use {@link SVGScaleModes.HEIGHT}, `Image.SVG_MODE_*` will be removed in 4.0
|
|
1031
1146
|
* @group Deprecated
|
|
1032
1147
|
*/
|
|
1033
|
-
static readonly SVG_MODE_HEIGHT
|
|
1148
|
+
static readonly SVG_MODE_HEIGHT = 3;
|
|
1034
1149
|
/**
|
|
1035
1150
|
* Creates a new image from the given SVG
|
|
1036
1151
|
* Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, patterns, strokes, markers, clip paths,
|
|
@@ -1047,8 +1162,17 @@ export declare class Image {
|
|
|
1047
1162
|
* @param size The size to use
|
|
1048
1163
|
* @param mode The SVG resizing mode to use (one of {@link SVGScaleModes.SCALE}, {@link SVGScaleModes.WIDTH}, {@link SVGScaleModes.HEIGHT})
|
|
1049
1164
|
* @return The rendered SVG graphic
|
|
1165
|
+
* @deprecated Pass {@link SVGOptions} instead, the positional arguments will be removed in 4.0
|
|
1050
1166
|
*/
|
|
1051
1167
|
static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Creates a new image containing the rendered text.
|
|
1170
|
+
* @param text Text to render
|
|
1171
|
+
* @param options The font and size, color, layout and style, see {@link RenderTextOptions}; the image grows by the
|
|
1172
|
+
* outline width on every side
|
|
1173
|
+
* @return The rendered text
|
|
1174
|
+
*/
|
|
1175
|
+
static renderText(text: string, options: RenderTextOptions): Promise<Image>;
|
|
1052
1176
|
/**
|
|
1053
1177
|
* Creates a new image containing the rendered text.
|
|
1054
1178
|
* @param font TrueType (ttf/ttc), OpenType (otf) or WOFF font buffer to use, or several by priority: every
|
|
@@ -1061,6 +1185,8 @@ export declare class Image {
|
|
|
1061
1185
|
* @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
|
|
1062
1186
|
* side
|
|
1063
1187
|
* @return The rendered text
|
|
1188
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1189
|
+
* This signature will be removed in 4.0
|
|
1064
1190
|
*/
|
|
1065
1191
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, options?: TextOptions): Promise<Image>;
|
|
1066
1192
|
/**
|
|
@@ -1076,6 +1202,8 @@ export declare class Image {
|
|
|
1076
1202
|
* @param [layout] The text layout to use
|
|
1077
1203
|
* @param style Outline, see {@link TextStyle}; the image grows by the outline width on every side
|
|
1078
1204
|
* @return The rendered text
|
|
1205
|
+
* @deprecated Pass the text first and everything else as options, `Image.renderText(text, { font, size })`.
|
|
1206
|
+
* This signature will be removed in 4.0
|
|
1079
1207
|
*/
|
|
1080
1208
|
static renderText(font: BinaryData | BinaryData[], size: number, text: string, color?: Color, layout?: TextLayout, style?: TextStyle): Promise<Image>;
|
|
1081
1209
|
}
|