imagescript 3.0.0 → 3.2.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.
Files changed (52) hide show
  1. package/README.md +29 -9
  2. package/THIRD_PARTY_NOTICES.md +82 -0
  3. package/dist/animation.d.ts +140 -0
  4. package/dist/animation.js +197 -0
  5. package/dist/codecs/exif.js +62 -0
  6. package/dist/codecs/gif.js +32 -19
  7. package/dist/codecs/jpeg.js +13 -1
  8. package/dist/codecs/png.js +348 -62
  9. package/dist/codecs/quantize.js +2 -2
  10. package/dist/codecs/tga.js +246 -0
  11. package/dist/codecs/vp8-tables.js +17 -0
  12. package/dist/codecs/vp8.js +711 -0
  13. package/dist/codecs/vp8l.js +906 -0
  14. package/dist/codecs/webp.js +293 -0
  15. package/dist/frame.d.ts +40 -12
  16. package/dist/frame.js +20 -9
  17. package/dist/gif.d.ts +16 -26
  18. package/dist/gif.js +10 -81
  19. package/dist/image-type.d.ts +6 -1
  20. package/dist/image-type.js +17 -1
  21. package/dist/image.d.ts +262 -30
  22. package/dist/image.js +144 -45
  23. package/dist/index.d.ts +20 -6
  24. package/dist/index.js +13 -4
  25. package/dist/metadata.d.ts +35 -0
  26. package/dist/metadata.js +43 -0
  27. package/dist/render/font.js +99 -2
  28. package/dist/render/hinting.js +1236 -0
  29. package/dist/render/svg.js +39 -21
  30. package/dist/render/text.js +32 -7
  31. package/dist/util/optimize.js +264 -0
  32. package/dist/util/options.js +3 -0
  33. package/dist/util/resample.js +44 -26
  34. package/dist/util/utf8.js +4 -51
  35. package/dist/version.js +1 -1
  36. package/licenses/FTL.txt +169 -0
  37. package/package.json +10 -3
  38. package/dist/codecs/crc.d.ts +0 -9
  39. package/dist/codecs/exif.d.ts +0 -11
  40. package/dist/codecs/gif.d.ts +0 -44
  41. package/dist/codecs/jpeg.d.ts +0 -35
  42. package/dist/codecs/png.d.ts +0 -44
  43. package/dist/codecs/quantize.d.ts +0 -25
  44. package/dist/codecs/tiff.d.ts +0 -6
  45. package/dist/codecs/zlib.d.ts +0 -22
  46. package/dist/render/font.d.ts +0 -63
  47. package/dist/render/svg.d.ts +0 -11
  48. package/dist/render/text.d.ts +0 -61
  49. package/dist/util/blur.d.ts +0 -13
  50. package/dist/util/resample.d.ts +0 -12
  51. package/dist/util/utf8.d.ts +0 -5
  52. package/dist/version.d.ts +0 -1
package/dist/image.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { BinaryData } from './util/mem.js';
2
2
  import { TextLayout } from './text-layout.js';
3
+ import { Metadata } from './metadata.js';
3
4
  /** A color as a 32-bit RGBA integer (`0xRRGGBBAA`) */
4
5
  export type Color = number;
5
6
  /** Called with a pixel's (0-based) coordinates, returns its color */
@@ -12,14 +13,84 @@ export type SVGScaleMode = 1 | 2 | 3;
12
13
  export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'add';
13
14
  /** Options of {@link Image.composite} */
14
15
  export interface CompositeOptions {
16
+ /** The x position to place the source at, if the options are the second argument. Default: `0` */
17
+ x?: number;
18
+ /** The y position to place the source at, if the options are the second argument. Default: `0` */
19
+ y?: number;
15
20
  /** Opacity of the source (0..1). Default: `1` */
16
21
  opacity?: number;
17
22
  /** How the colors are mixed. Default: `'normal'` */
18
23
  mode?: BlendMode;
19
24
  }
25
+ /** Options of {@link Image.scale}, {@link Image.resize}, {@link Image.contain}, {@link Image.fit} and {@link Image.cover} */
26
+ export interface ResizeOptions {
27
+ /** The resizing mode. Default: {@link Image.RESIZE_BILINEAR} */
28
+ mode?: ResizeMode;
29
+ }
30
+ /**
31
+ * Options of {@link Image.opacity}, {@link Image.red}, {@link Image.green}, {@link Image.blue}, {@link Image.lightness}
32
+ * and {@link Image.saturation}
33
+ */
34
+ export interface AdjustOptions {
35
+ /** Whether to set the value (true) or scale the current one (false). Default: `false` */
36
+ absolute?: boolean;
37
+ }
38
+ /** Options of {@link Image.sharpen} */
39
+ export interface SharpenOptions {
40
+ /** How strongly to sharpen (0 does nothing). Default: `1` */
41
+ amount?: number;
42
+ /** The radius of the blur the image is compared with (larger values sharpen coarser details). Default: `1` */
43
+ radius?: number;
44
+ }
45
+ /** Options of {@link Image.encode} */
46
+ export interface PNGEncodeOptions {
47
+ /** The compression level (0-9). Default: `1` */
48
+ compression?: number;
49
+ /** Metadata to include, see {@link Metadata} */
50
+ metadata?: Metadata;
51
+ }
52
+ /** Options of {@link Image.encodeJPEG} */
53
+ export interface JPEGEncodeOptions {
54
+ /** The JPEG quality (1-100), chroma subsampling is disabled above 90. Default: `90` */
55
+ quality?: number;
56
+ /** Metadata to include, see {@link Metadata} */
57
+ metadata?: Metadata;
58
+ }
59
+ /** Options of {@link Image.encodeWebP} and {@link Image.encodeTGA} */
60
+ export interface EncodeOptions {
61
+ /** Metadata to include, see {@link Metadata} */
62
+ metadata?: Metadata;
63
+ }
64
+ /** Options of {@link Image.roundCorners} */
65
+ export interface RoundCornersOptions {
66
+ /** The radius of the corners. Default: a quarter of the smaller side */
67
+ radius?: number;
68
+ }
69
+ /** Options of {@link Image.fisheye} */
70
+ export interface FisheyeOptions {
71
+ /** The distortion strength (exponent of the radial mapping), higher values bulge the center more. Default: `2` */
72
+ strength?: number;
73
+ }
74
+ /** Options of {@link Image.renderSVG} */
75
+ export interface SVGOptions {
76
+ /** The scale, or the width or height in pixels, see `mode`. Default: `1` */
77
+ size?: number;
78
+ /**
79
+ * What `size` is: one of {@link Image.SVG_MODE_SCALE}, {@link Image.SVG_MODE_WIDTH}, {@link Image.SVG_MODE_HEIGHT}.
80
+ * Default: {@link Image.SVG_MODE_SCALE}
81
+ */
82
+ mode?: SVGScaleMode;
83
+ }
84
+ /** Options of {@link Image.renderText}: the text color and layout, and its style (see {@link TextStyle}) */
85
+ export interface TextOptions extends TextStyle {
86
+ /** The text color. Default: `0xffffffff` */
87
+ color?: Color;
88
+ /** The text layout. Default: `new TextLayout()` */
89
+ layout?: TextLayout;
90
+ }
20
91
  /** Options of {@link Image.decode} */
21
92
  export interface DecodeOptions {
22
- /** Whether to rotate/mirror JPEGs, TIFFs and PNGs as their orientation tag (Exif or XMP) says. Default: `true` */
93
+ /** Whether to rotate/mirror JPEGs, TIFFs, PNGs and WebPs as their orientation tag (Exif or XMP) says. Default: `true` */
23
94
  applyOrientation?: boolean;
24
95
  }
25
96
  /** Text style options of {@link Image.renderText} */
@@ -28,6 +99,12 @@ export interface TextStyle {
28
99
  strokeWidth?: number;
29
100
  /** Color of the outline. Default: `0x000000ff` */
30
101
  strokeColor?: Color;
102
+ /**
103
+ * Whether to run the hinting instructions of TrueType fonts, which align stems and edges with the pixel grid for
104
+ * crisper text at small sizes (like Windows renders text); the glyphs of hinted fonts are then placed on whole
105
+ * pixels. Fonts without instructions (and CFF/OpenType outlines) aren't affected. Default: `true`
106
+ */
107
+ hinting?: boolean;
31
108
  }
32
109
  /** Options of {@link Image.cropCircle} */
33
110
  export interface CropCircleOptions {
@@ -50,29 +127,26 @@ export interface RotateOptions {
50
127
  /** Whether to resize the image so it fits all pixels or just ignore outlying pixels. Default: `true` */
51
128
  resize?: boolean;
52
129
  }
53
- /** Text metadata written into PNGs by {@link Image.encode} */
54
- export interface PNGMetadata {
55
- /** The image's title */
56
- title?: string;
57
- /** The image's author */
58
- author?: string;
59
- /** The image's description */
60
- description?: string;
61
- /** The image's copyright info */
62
- copyright?: string;
63
- /** The image's creation time. Default: now */
64
- creationTime?: string | number | Date;
65
- /** The software used to create the image. Default: `'github.com/matmen/ImageScript vX.X.X'`, `''` leaves it out */
66
- software?: string;
67
- /** A disclaimer for the image */
68
- disclaimer?: string;
69
- /** A warning for the image */
70
- warning?: string;
71
- /** The image's source */
72
- source?: string;
73
- /** A comment for the image */
74
- comment?: string;
130
+ /** Options of {@link Image.trim} */
131
+ export interface TrimOptions {
132
+ /**
133
+ * How far (0-1) a pixel's channels may be from the color for it to be trimmed, e.g. for JPEG artifacts or
134
+ * antialiasing. Default: `0`
135
+ */
136
+ tolerance?: number;
137
+ }
138
+ /** Options of {@link Image.colorToAlpha} */
139
+ export interface ColorToAlphaOptions {
140
+ /** Pixels at most this far from the color (0-1) become fully transparent. Default: 0 */
141
+ transparencyThreshold?: number;
142
+ /** Pixels at least this far from the color (0-1) stay fully opaque. Default: 1 */
143
+ opacityThreshold?: number;
75
144
  }
145
+ /**
146
+ * Text metadata written into PNGs
147
+ * @deprecated Use {@link Metadata}, which all encoders take
148
+ */
149
+ export type PNGMetadata = Metadata;
76
150
  /**
77
151
  * An RGBA image; provides the codecs and the manipulation functions. Methods that change the image modify it in place
78
152
  * and return it, so calls can be chained
@@ -224,12 +298,27 @@ export declare class Image {
224
298
  * Used for automatically preserving an images aspect ratio when resizing.
225
299
  */
226
300
  static get RESIZE_AUTO(): -1;
301
+ /**
302
+ * Resizes the image by the given factor
303
+ * @param factor The factor to resize the image with
304
+ * @param options See {@link ResizeOptions}
305
+ */
306
+ scale(factor: number, options?: ResizeOptions): this;
227
307
  /**
228
308
  * Resizes the image by the given factor
229
309
  * @param factor The factor to resize the image with
230
310
  * @param [mode=Image.RESIZE_BILINEAR] The resizing mode to use
231
311
  */
232
312
  scale(factor: number, mode?: ResizeMode): this;
313
+ /**
314
+ * Resizes the image to the given dimensions.
315
+ * Use {@link Image.RESIZE_AUTO} as either width or height to automatically preserve the aspect ratio.
316
+ * @param width The new width
317
+ * @param height The new height
318
+ * @param options See {@link ResizeOptions}
319
+ * @returns The resized image
320
+ */
321
+ resize(width: number, height: number, options?: ResizeOptions): this;
233
322
  /**
234
323
  * Resizes the image to the given dimensions.
235
324
  * Use {@link Image.RESIZE_AUTO} as either width or height to automatically preserve the aspect ratio.
@@ -239,6 +328,15 @@ export declare class Image {
239
328
  * @returns The resized image
240
329
  */
241
330
  resize(width: number, height: number, mode?: ResizeMode): this;
331
+ /**
332
+ * Resizes the image so it is contained in the given bounding box.
333
+ * Can return an image with one axis smaller than the given bounding box.
334
+ * @param width The width of the bounding box
335
+ * @param height The height of the bounding box
336
+ * @param options See {@link ResizeOptions}
337
+ * @returns The resized image
338
+ */
339
+ contain(width: number, height: number, options?: ResizeOptions): this;
242
340
  /**
243
341
  * Resizes the image so it is contained in the given bounding box.
244
342
  * Can return an image with one axis smaller than the given bounding box.
@@ -248,6 +346,15 @@ export declare class Image {
248
346
  * @returns The resized image
249
347
  */
250
348
  contain(width: number, height: number, mode?: ResizeMode): this;
349
+ /**
350
+ * Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
351
+ * Always returns the exact dimensions of the bounding box.
352
+ * @param width The width of the bounding box
353
+ * @param height The height of the bounding box
354
+ * @param options See {@link ResizeOptions}
355
+ * @returns The resized image
356
+ */
357
+ fit(width: number, height: number, options?: ResizeOptions): this;
251
358
  /**
252
359
  * Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box.
253
360
  * Always returns the exact dimensions of the bounding box.
@@ -257,6 +364,15 @@ export declare class Image {
257
364
  * @returns The resized image
258
365
  */
259
366
  fit(width: number, height: number, mode?: ResizeMode): this;
367
+ /**
368
+ * Resizes the image so it covers the given bounding box, cropping the overflowing edges.
369
+ * Always returns the exact dimensions of the bounding box.
370
+ * @param width The width of the bounding box
371
+ * @param height The height of the bounding box
372
+ * @param options See {@link ResizeOptions}
373
+ * @returns The resized image
374
+ */
375
+ cover(width: number, height: number, options?: ResizeOptions): this;
260
376
  /**
261
377
  * Resizes the image so it covers the given bounding box, cropping the overflowing edges.
262
378
  * Always returns the exact dimensions of the bounding box.
@@ -275,6 +391,15 @@ export declare class Image {
275
391
  * @param height The new images height
276
392
  */
277
393
  crop(x: number, y: number, width: number, height: number): this;
394
+ /**
395
+ * Removes borders of one color, e.g. the empty space around rendered text or around a logo on a solid background.
396
+ * Frames keep their position: their offsets move by the trimmed amount. An image that only has the color stays
397
+ * unchanged
398
+ * @param color The border color, by default the color of the top left pixel. Fully transparent pixels count as the
399
+ * same color whatever their RGB values
400
+ * @param options See {@link TrimOptions}
401
+ */
402
+ trim(color?: Color, options?: TrimOptions): this;
278
403
  /**
279
404
  * Draws a box at the specified coordinates (0-based), clipped to the image
280
405
  * @param x The x offset
@@ -303,42 +428,84 @@ export declare class Image {
303
428
  * @param feathering Share of the radius (0..1) over which the edge fades out. Default: `0`
304
429
  */
305
430
  cropCircle(max?: boolean, feathering?: number): this;
431
+ /**
432
+ * Sets the images opacity
433
+ * @param opacity The opacity to apply (0..1)
434
+ * @param options See {@link AdjustOptions}
435
+ */
436
+ opacity(opacity: number, options?: AdjustOptions): this;
306
437
  /**
307
438
  * Sets the images opacity
308
439
  * @param opacity The opacity to apply (0..1)
309
440
  * @param absolute Whether to scale the current opacity (false) or just set the new opacity (true)
310
441
  */
311
442
  opacity(opacity: number, absolute?: boolean): this;
443
+ /**
444
+ * Scales or sets the red channel
445
+ * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
446
+ * @param options See {@link AdjustOptions}
447
+ */
448
+ red(factor: number, options?: AdjustOptions): this;
312
449
  /**
313
450
  * Scales or sets the red channel
314
451
  * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
315
452
  * @param absolute Whether to scale the current value (false) or set every pixel's red channel to `factor` * 255 (true)
316
453
  */
317
454
  red(factor: number, absolute?: boolean): this;
455
+ /**
456
+ * Scales or sets the green channel
457
+ * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
458
+ * @param options See {@link AdjustOptions}
459
+ */
460
+ green(factor: number, options?: AdjustOptions): this;
318
461
  /**
319
462
  * Scales or sets the green channel
320
463
  * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
321
464
  * @param absolute Whether to scale the current value (false) or set every pixel's green channel to `factor` * 255 (true)
322
465
  */
323
466
  green(factor: number, absolute?: boolean): this;
467
+ /**
468
+ * Scales or sets the blue channel
469
+ * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
470
+ * @param options See {@link AdjustOptions}
471
+ */
472
+ blue(factor: number, options?: AdjustOptions): this;
324
473
  /**
325
474
  * Scales or sets the blue channel
326
475
  * @param factor The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
327
476
  * @param absolute Whether to scale the current value (false) or set every pixel's blue channel to `factor` * 255 (true)
328
477
  */
329
478
  blue(factor: number, absolute?: boolean): this;
479
+ /**
480
+ * Sets the brightness of the image
481
+ * @param value The lightness to apply (0..1)
482
+ * @param options See {@link AdjustOptions}
483
+ */
484
+ lightness(value: number, options?: AdjustOptions): this;
330
485
  /**
331
486
  * Sets the brightness of the image
332
487
  * @param value The lightness to apply (0..1)
333
488
  * @param absolute Whether to scale the current lightness (false) or just set the new lightness (true)
334
489
  */
335
490
  lightness(value: number, absolute?: boolean): this;
491
+ /**
492
+ * Sets the saturation of the image
493
+ * @param value The saturation to apply (0..1)
494
+ * @param options See {@link AdjustOptions}
495
+ */
496
+ saturation(value: number, options?: AdjustOptions): this;
336
497
  /**
337
498
  * Sets the saturation of the image
338
499
  * @param value The saturation to apply (0..1)
339
500
  * @param absolute Whether to scale the current saturation (false) or just set the new saturation (true)
340
501
  */
341
502
  saturation(value: number, absolute?: boolean): this;
503
+ /**
504
+ * Composites (overlays) the source onto this image
505
+ * @param source The image to place
506
+ * @param options Position, opacity and blend mode, see {@link CompositeOptions}
507
+ */
508
+ composite(source: Image, options?: CompositeOptions): this;
342
509
  /**
343
510
  * Composites (overlays) the source onto this image at the specified coordinates
344
511
  * @param source The image to place
@@ -370,6 +537,11 @@ export declare class Image {
370
537
  * @param radius The blur radius: the gaussian's standard deviation in pixels, like CSS' blur()
371
538
  */
372
539
  blur(radius: number): this;
540
+ /**
541
+ * Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
542
+ * @param options See {@link SharpenOptions}
543
+ */
544
+ sharpen(options?: SharpenOptions): this;
373
545
  /**
374
546
  * Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
375
547
  * @param [amount=1] How strongly to sharpen (0 does nothing)
@@ -399,6 +571,16 @@ export declare class Image {
399
571
  * Applies a sepia tone
400
572
  */
401
573
  sepia(): this;
574
+ /**
575
+ * Makes a color transparent, like GIMP's "Color to Alpha": the color is removed from every pixel and replaced by
576
+ * transparency, so pixels that are partly the color (e.g. antialiased edges against a background) become
577
+ * semi-transparent instead of keeping a fringe of it.
578
+ * The color is removed everywhere in the image, not only from a connected background: removing a white
579
+ * background also makes white areas inside the subject (e.g. eyes in a logo) transparent
580
+ * @param color The color to remove, by default the color of the top left pixel (e.g. a background)
581
+ * @param options See {@link ColorToAlphaOptions}
582
+ */
583
+ colorToAlpha(color?: Color, options?: ColorToAlphaOptions): this;
402
584
  /**
403
585
  * Gets the average color of the image, weighting each pixel by its opacity
404
586
  * @returns The average color (fully opaque), black for fully transparent images
@@ -443,11 +625,21 @@ export declare class Image {
443
625
  * @return The gradient generator. The function argument is the position in the gradient (0..1).
444
626
  */
445
627
  static gradient(colors: Record<number, Color>): (position: number) => Color;
628
+ /**
629
+ * Rounds the images corners, with antialiased edges
630
+ * @param options See {@link RoundCornersOptions}
631
+ */
632
+ roundCorners(options?: RoundCornersOptions): this;
446
633
  /**
447
634
  * Rounds the images corners, with antialiased edges
448
635
  * @param [radius=min(width,height)/4] The radius of the corners
449
636
  */
450
637
  roundCorners(radius?: number): this;
638
+ /**
639
+ * Applies a fisheye (barrel distortion) effect
640
+ * @param options See {@link FisheyeOptions}
641
+ */
642
+ fisheye(options?: FisheyeOptions): this;
451
643
  /**
452
644
  * Applies a fisheye (barrel distortion) effect
453
645
  * @param [strength=2] The distortion strength (exponent of the radial mapping), higher values bulge the center more
@@ -456,29 +648,52 @@ export declare class Image {
456
648
  /**
457
649
  * Encodes the image into a PNG, with the smallest lossless color type (a palette for up to 256 colors,
458
650
  * greyscale or RGB, alpha only if needed). Uses the runtime's native zlib when available
651
+ * @param options See {@link PNGEncodeOptions}
652
+ * @return The encoded data
653
+ */
654
+ encode(options?: PNGEncodeOptions): Promise<Uint8Array>;
655
+ /**
656
+ * Encodes the image into a PNG
459
657
  * @param compression The compression level (0-9). Default: `1`
460
- * @param metadata Text metadata to include
658
+ * @param metadata Metadata to include, see {@link Metadata}
461
659
  * @return The encoded data
462
660
  */
463
- encode(compression?: number, metadata?: PNGMetadata): Promise<Uint8Array>;
661
+ encode(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
464
662
  /**
465
663
  * Encodes the image into a PNG with compression level 1
466
- * @param metadata Text metadata to include
664
+ * @param metadata Metadata to include, see {@link Metadata}
467
665
  * @return The encoded data
468
666
  */
469
- encode(metadata?: PNGMetadata): Promise<Uint8Array>;
667
+ encode(metadata?: Metadata): Promise<Uint8Array>;
470
668
  /**
471
669
  * Encodes the image into a PNG, an alias of {@link Image.encode}
472
670
  */
473
- encodePNG(compression?: number, metadata?: PNGMetadata): Promise<Uint8Array>;
474
- encodePNG(metadata?: PNGMetadata): Promise<Uint8Array>;
671
+ encodePNG(options?: PNGEncodeOptions): Promise<Uint8Array>;
672
+ encodePNG(compression?: number, metadata?: Metadata): Promise<Uint8Array>;
673
+ encodePNG(metadata?: Metadata): Promise<Uint8Array>;
674
+ /**
675
+ * Encodes the image into a JPEG
676
+ * @param options See {@link JPEGEncodeOptions}
677
+ */
678
+ encodeJPEG(options?: JPEGEncodeOptions): Promise<Uint8Array>;
475
679
  /**
476
680
  * Encodes the image into a JPEG
477
681
  * @param [quality=90] The JPEG quality to use (1-100), chroma subsampling is disabled above 90
478
682
  */
479
683
  encodeJPEG(quality?: number): Promise<Uint8Array>;
480
684
  /**
481
- * Decodes an image (PNG, JPEG or TIFF)
685
+ * Encodes the image as lossless WebP (usually 20-30% smaller than PNG, but slower to encode)
686
+ * @param options See {@link EncodeOptions}
687
+ */
688
+ encodeWebP({ metadata }?: EncodeOptions): Promise<Uint8Array>;
689
+ /**
690
+ * Encodes the image as run length encoded TGA (32 bit, or 24 bit if the image is opaque)
691
+ * @param options See {@link EncodeOptions}
692
+ */
693
+ encodeTGA({ metadata }?: EncodeOptions): Promise<Uint8Array>;
694
+ /**
695
+ * Decodes an image (PNG, JPEG, TIFF, WebP or TGA). For APNGs this is the default image; animated WebPs and GIFs
696
+ * have no single image, decode those with {@link Animation.decode}
482
697
  * @param input The binary data to decode
483
698
  * @param options See {@link DecodeOptions}. JPEGs, TIFFs and PNGs are rotated/mirrored as their orientation tag
484
699
  * (Exif, for PNGs also XMP) says by default: photos taken with a rotated camera are stored sideways
@@ -502,11 +717,28 @@ export declare class Image {
502
717
  * Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, strokes, clip paths, masks and opacity;
503
718
  * text, images, filters and patterns are not rendered
504
719
  * @param svg The SVG content
720
+ * @param options See {@link SVGOptions}
721
+ * @return The rendered SVG graphic
722
+ */
723
+ static renderSVG(svg: string | BinaryData, options?: SVGOptions): Promise<Image>;
724
+ /**
725
+ * Creates a new image from the given SVG
726
+ * @param svg The SVG content
505
727
  * @param size The size to use
506
728
  * @param mode The SVG resizing mode to use (one of {@link SVG_MODE_SCALE}, {@link SVG_MODE_WIDTH}, {@link SVG_MODE_HEIGHT})
507
729
  * @return The rendered SVG graphic
508
730
  */
509
731
  static renderSVG(svg: string | BinaryData, size?: number, mode?: SVGScaleMode): Promise<Image>;
732
+ /**
733
+ * Creates a new image containing the rendered text.
734
+ * @param font TrueType (ttf/ttc) or OpenType (otf) font buffer to use
735
+ * @param size Font size in pixels (per em)
736
+ * @param text Text to render
737
+ * @param options Color, layout and style, see {@link TextOptions}; the image grows by the outline width on every
738
+ * side
739
+ * @return The rendered text
740
+ */
741
+ static renderText(font: BinaryData, size: number, text: string, options?: TextOptions): Promise<Image>;
510
742
  /**
511
743
  * Creates a new image containing the rendered text.
512
744
  * @param font TrueType (ttf/ttc) or OpenType (otf) font buffer to use