sharp 0.33.5 → 0.35.3
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 +12 -18
- package/dist/channel.cjs +177 -0
- package/{lib/channel.js → dist/channel.mjs} +11 -8
- package/dist/colour.cjs +199 -0
- package/{lib/colour.js → dist/colour.mjs} +42 -23
- package/dist/composite.cjs +213 -0
- package/{lib/composite.js → dist/composite.mjs} +14 -11
- package/{lib/constructor.js → dist/constructor.cjs} +102 -43
- package/dist/constructor.mjs +511 -0
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +1999 -0
- package/dist/index.d.mts +2046 -0
- package/dist/index.mjs +25 -0
- package/dist/input.cjs +814 -0
- package/{lib/input.js → dist/input.mjs} +232 -76
- package/{lib/is.js → dist/is.cjs} +19 -45
- package/dist/is.mjs +143 -0
- package/{lib/libvips.js → dist/libvips.cjs} +52 -43
- package/dist/libvips.mjs +212 -0
- package/dist/operation.cjs +998 -0
- package/{lib/operation.js → dist/operation.mjs} +131 -91
- package/{lib/output.js → dist/output.cjs} +262 -61
- package/dist/output.mjs +1788 -0
- package/dist/resize.cjs +617 -0
- package/{lib/resize.js → dist/resize.mjs} +65 -35
- package/dist/sharp.cjs +174 -0
- package/dist/sharp.mjs +174 -0
- package/{lib/utility.js → dist/utility.cjs} +30 -25
- package/dist/utility.mjs +301 -0
- package/install/build.js +38 -0
- package/lib/index.d.ts +387 -142
- package/package.json +90 -85
- package/src/binding.gyp +49 -26
- package/src/common.cc +203 -111
- package/src/common.h +68 -40
- package/src/metadata.cc +106 -22
- package/src/metadata.h +15 -5
- package/src/operations.cc +62 -21
- package/src/operations.h +15 -3
- package/src/pipeline.cc +391 -201
- package/src/pipeline.h +36 -7
- package/src/sharp.cc +11 -8
- package/src/stats.cc +16 -13
- package/src/stats.h +6 -3
- package/src/utilities.cc +35 -15
- package/src/utilities.h +5 -2
- package/install/check.js +0 -41
- package/lib/index.js +0 -16
- package/lib/sharp.js +0 -114
package/lib/index.d.ts
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
|
|
28
28
|
/// <reference types="node" />
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
declare type Duplex = import('node:stream').Duplex;
|
|
31
|
+
declare type ColorLike = import('@img/colour').ColorLike;
|
|
31
32
|
|
|
32
33
|
//#region Constructor functions
|
|
33
34
|
|
|
@@ -40,19 +41,7 @@ import { Duplex } from 'stream';
|
|
|
40
41
|
*/
|
|
41
42
|
declare function sharp(options?: sharp.SharpOptions): sharp.Sharp;
|
|
42
43
|
declare function sharp(
|
|
43
|
-
input?:
|
|
44
|
-
| Buffer
|
|
45
|
-
| ArrayBuffer
|
|
46
|
-
| Uint8Array
|
|
47
|
-
| Uint8ClampedArray
|
|
48
|
-
| Int8Array
|
|
49
|
-
| Uint16Array
|
|
50
|
-
| Int16Array
|
|
51
|
-
| Uint32Array
|
|
52
|
-
| Int32Array
|
|
53
|
-
| Float32Array
|
|
54
|
-
| Float64Array
|
|
55
|
-
| string,
|
|
44
|
+
input?: sharp.SharpInput | Array<sharp.SharpInput>,
|
|
56
45
|
options?: sharp.SharpOptions,
|
|
57
46
|
): sharp.Sharp;
|
|
58
47
|
|
|
@@ -62,33 +51,35 @@ declare namespace sharp {
|
|
|
62
51
|
|
|
63
52
|
/** An Object containing the version numbers of sharp, libvips and its dependencies. */
|
|
64
53
|
const versions: {
|
|
65
|
-
|
|
54
|
+
aom?: string | undefined;
|
|
55
|
+
archive?: string | undefined;
|
|
66
56
|
cairo?: string | undefined;
|
|
67
|
-
|
|
57
|
+
cgif?: string | undefined;
|
|
68
58
|
exif?: string | undefined;
|
|
69
59
|
expat?: string | undefined;
|
|
70
60
|
ffi?: string | undefined;
|
|
71
61
|
fontconfig?: string | undefined;
|
|
72
62
|
freetype?: string | undefined;
|
|
73
|
-
|
|
74
|
-
gif?: string | undefined;
|
|
63
|
+
fribidi?: string | undefined;
|
|
75
64
|
glib?: string | undefined;
|
|
76
|
-
gsf?: string | undefined;
|
|
77
65
|
harfbuzz?: string | undefined;
|
|
78
|
-
|
|
66
|
+
heif?: string | undefined;
|
|
67
|
+
highway?: string | undefined;
|
|
68
|
+
imagequant?: string | undefined;
|
|
79
69
|
lcms?: string | undefined;
|
|
80
|
-
|
|
70
|
+
mozjpeg?: string | undefined;
|
|
81
71
|
pango?: string | undefined;
|
|
82
72
|
pixman?: string | undefined;
|
|
83
73
|
png?: string | undefined;
|
|
84
|
-
|
|
85
|
-
|
|
74
|
+
"proxy-libintl"?: string | undefined;
|
|
75
|
+
rsvg?: string | undefined;
|
|
76
|
+
sharp: string;
|
|
77
|
+
spng?: string | undefined;
|
|
86
78
|
tiff?: string | undefined;
|
|
79
|
+
vips: string;
|
|
87
80
|
webp?: string | undefined;
|
|
88
|
-
avif?: string | undefined;
|
|
89
|
-
heif?: string | undefined;
|
|
90
81
|
xml?: string | undefined;
|
|
91
|
-
zlib?: string | undefined;
|
|
82
|
+
"zlib-ng"?: string | undefined;
|
|
92
83
|
};
|
|
93
84
|
|
|
94
85
|
/** An Object containing the available interpolators and their proper values */
|
|
@@ -244,14 +235,14 @@ declare namespace sharp {
|
|
|
244
235
|
* @param tint Parsed by the color module.
|
|
245
236
|
* @returns A sharp instance that can be used to chain operations
|
|
246
237
|
*/
|
|
247
|
-
tint(tint:
|
|
238
|
+
tint(tint: ColorLike): Sharp;
|
|
248
239
|
|
|
249
240
|
/**
|
|
250
241
|
* Convert to 8-bit greyscale; 256 shades of grey.
|
|
251
242
|
* This is a linear operation.
|
|
252
243
|
* If the input image is in a non-linear colour space such as sRGB, use gamma() with greyscale() for the best results.
|
|
253
|
-
* By default the output image will be web-friendly sRGB and contain three (identical)
|
|
254
|
-
* This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one
|
|
244
|
+
* By default the output image will be web-friendly sRGB and contain three (identical) colour channels.
|
|
245
|
+
* This may be overridden by other sharp operations such as toColourspace('b-w'), which will produce an output image containing one colour channel.
|
|
255
246
|
* An alpha channel may be present, and will be unchanged by the operation.
|
|
256
247
|
* @param greyscale true to enable and false to disable (defaults to true)
|
|
257
248
|
* @returns A sharp instance that can be used to chain operations
|
|
@@ -269,7 +260,6 @@ declare namespace sharp {
|
|
|
269
260
|
* Set the pipeline colourspace.
|
|
270
261
|
* The input image will be converted to the provided colourspace at the start of the pipeline.
|
|
271
262
|
* All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
|
|
272
|
-
* This feature is experimental and has not yet been fully-tested with all operations.
|
|
273
263
|
*
|
|
274
264
|
* @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
|
|
275
265
|
* @throws {Error} Invalid parameters
|
|
@@ -364,24 +354,72 @@ declare namespace sharp {
|
|
|
364
354
|
//#region Operation functions
|
|
365
355
|
|
|
366
356
|
/**
|
|
367
|
-
* Rotate the output image by either an explicit angle
|
|
357
|
+
* Rotate the output image by either an explicit angle
|
|
358
|
+
* or auto-orient based on the EXIF `Orientation` tag.
|
|
368
359
|
*
|
|
369
|
-
* If an angle is provided, it is converted to a valid positive degree rotation.
|
|
360
|
+
* If an angle is provided, it is converted to a valid positive degree rotation.
|
|
361
|
+
* For example, `-450` will produce a 270 degree rotation.
|
|
370
362
|
*
|
|
371
|
-
* When rotating by an angle other than a multiple of 90,
|
|
363
|
+
* When rotating by an angle other than a multiple of 90,
|
|
364
|
+
* the background colour can be provided with the `background` option.
|
|
372
365
|
*
|
|
373
|
-
* If no angle is provided, it is determined from the EXIF data.
|
|
366
|
+
* If no angle is provided, it is determined from the EXIF data.
|
|
367
|
+
* Mirroring is supported and may infer the use of a flip operation.
|
|
374
368
|
*
|
|
375
|
-
* The use of rotate
|
|
369
|
+
* The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if any.
|
|
376
370
|
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
371
|
+
* Only one rotation can occur per pipeline (aside from an initial call without
|
|
372
|
+
* arguments to orient via EXIF data). Previous calls to `rotate` in the same
|
|
373
|
+
* pipeline will be ignored.
|
|
374
|
+
*
|
|
375
|
+
* Multi-page images can only be rotated by 180 degrees.
|
|
376
|
+
*
|
|
377
|
+
* Method order is important when rotating, resizing and/or extracting regions,
|
|
378
|
+
* for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* const pipeline = sharp()
|
|
382
|
+
* .rotate()
|
|
383
|
+
* .resize(null, 200)
|
|
384
|
+
* .toBuffer(function (err, outputBuffer, info) {
|
|
385
|
+
* // outputBuffer contains 200px high JPEG image data,
|
|
386
|
+
* // auto-rotated using EXIF Orientation tag
|
|
387
|
+
* // info.width and info.height contain the dimensions of the resized image
|
|
388
|
+
* });
|
|
389
|
+
* readableStream.pipe(pipeline);
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* const rotateThenResize = await sharp(input)
|
|
393
|
+
* .rotate(90)
|
|
394
|
+
* .resize({ width: 16, height: 8, fit: 'fill' })
|
|
395
|
+
* .toBuffer();
|
|
396
|
+
* const resizeThenRotate = await sharp(input)
|
|
397
|
+
* .resize({ width: 16, height: 8, fit: 'fill' })
|
|
398
|
+
* .rotate(90)
|
|
399
|
+
* .toBuffer();
|
|
400
|
+
*
|
|
401
|
+
* @param {number} [angle=auto] angle of rotation.
|
|
402
|
+
* @param {Object} [options] - if present, is an Object with optional attributes.
|
|
403
|
+
* @param {string|Object} [options.background="#000000"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
|
|
404
|
+
* @returns {Sharp}
|
|
380
405
|
* @throws {Error} Invalid parameters
|
|
381
|
-
* @returns A sharp instance that can be used to chain operations
|
|
382
406
|
*/
|
|
383
407
|
rotate(angle?: number, options?: RotateOptions): Sharp;
|
|
384
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Alias for calling `rotate()` with no arguments, which orients the image based
|
|
411
|
+
* on EXIF orientsion.
|
|
412
|
+
*
|
|
413
|
+
* This operation is aliased to emphasize its purpose, helping to remove any
|
|
414
|
+
* confusion between rotation and orientation.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* const output = await sharp(input).autoOrient().toBuffer();
|
|
418
|
+
*
|
|
419
|
+
* @returns {Sharp}
|
|
420
|
+
*/
|
|
421
|
+
autoOrient(): Sharp
|
|
422
|
+
|
|
385
423
|
/**
|
|
386
424
|
* Flip the image about the vertical Y axis. This always occurs after rotation, if any.
|
|
387
425
|
* The use of flip implies the removal of the EXIF Orientation tag, if any.
|
|
@@ -401,7 +439,7 @@ declare namespace sharp {
|
|
|
401
439
|
/**
|
|
402
440
|
* Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.
|
|
403
441
|
* You must provide an array of length 4 or a 2x2 affine transformation matrix.
|
|
404
|
-
* By default, new pixels are filled with a black background. You can provide a background
|
|
442
|
+
* By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.
|
|
405
443
|
* A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.
|
|
406
444
|
*
|
|
407
445
|
* In the case of a 2x2 matrix, the transform is:
|
|
@@ -432,21 +470,6 @@ declare namespace sharp {
|
|
|
432
470
|
*/
|
|
433
471
|
sharpen(options?: SharpenOptions): Sharp;
|
|
434
472
|
|
|
435
|
-
/**
|
|
436
|
-
* Sharpen the image.
|
|
437
|
-
* When used without parameters, performs a fast, mild sharpen of the output image.
|
|
438
|
-
* When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
|
|
439
|
-
* Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
|
|
440
|
-
* @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
|
|
441
|
-
* @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
|
|
442
|
-
* @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
|
|
443
|
-
* @throws {Error} Invalid parameters
|
|
444
|
-
* @returns A sharp instance that can be used to chain operations
|
|
445
|
-
*
|
|
446
|
-
* @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
|
|
447
|
-
*/
|
|
448
|
-
sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
|
|
449
|
-
|
|
450
473
|
/**
|
|
451
474
|
* Apply median filter. When used without parameters the default window is 3x3.
|
|
452
475
|
* @param size square mask size: size x size (optional, default 3)
|
|
@@ -466,6 +489,22 @@ declare namespace sharp {
|
|
|
466
489
|
*/
|
|
467
490
|
blur(sigma?: number | boolean | BlurOptions): Sharp;
|
|
468
491
|
|
|
492
|
+
/**
|
|
493
|
+
* Expand foreground objects using the dilate morphological operator.
|
|
494
|
+
* @param {Number} [width=1] dilation width in pixels.
|
|
495
|
+
* @throws {Error} Invalid parameters
|
|
496
|
+
* @returns A sharp instance that can be used to chain operations
|
|
497
|
+
*/
|
|
498
|
+
dilate(width?: number): Sharp;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Shrink foreground objects using the erode morphological operator.
|
|
502
|
+
* @param {Number} [width=1] erosion width in pixels.
|
|
503
|
+
* @throws {Error} Invalid parameters
|
|
504
|
+
* @returns A sharp instance that can be used to chain operations
|
|
505
|
+
*/
|
|
506
|
+
erode(width?: number): Sharp;
|
|
507
|
+
|
|
469
508
|
/**
|
|
470
509
|
* Merge alpha transparency channel, if any, with background.
|
|
471
510
|
* @param flatten true to enable and false to disable (defaults to true)
|
|
@@ -619,25 +658,42 @@ declare namespace sharp {
|
|
|
619
658
|
* @param callback Callback function called on completion with three arguments (err, buffer, info).
|
|
620
659
|
* @returns A sharp instance that can be used to chain operations
|
|
621
660
|
*/
|
|
622
|
-
toBuffer(callback: (err: Error, buffer: Buffer
|
|
661
|
+
toBuffer(callback: (err: Error, buffer: Buffer<ArrayBuffer>, info: OutputInfo) => void): Sharp;
|
|
623
662
|
|
|
624
663
|
/**
|
|
625
664
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
626
665
|
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
666
|
+
* The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.
|
|
627
667
|
* @param options resolve options
|
|
628
668
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
629
669
|
* @returns A promise that resolves with the Buffer data.
|
|
630
670
|
*/
|
|
631
|
-
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer
|
|
671
|
+
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer<ArrayBuffer>>;
|
|
632
672
|
|
|
633
673
|
/**
|
|
634
674
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
635
675
|
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
676
|
+
* The underlying `ArrayBuffer` may be marked as non-transferable by some JavaScript runtimes.
|
|
636
677
|
* @param options resolve options
|
|
637
678
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
638
679
|
* @returns A promise that resolves with an object containing the Buffer data and an info object containing the output image format, size (bytes), width, height and channels
|
|
639
680
|
*/
|
|
640
|
-
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer
|
|
681
|
+
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer<ArrayBuffer>; info: OutputInfo }>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Write output to a Uint8Array backed by a transferable ArrayBuffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
685
|
+
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
686
|
+
* @returns A promise that resolves with an object containing the Uint8Array data and an info object containing the output image format, size (bytes), width, height and channels
|
|
687
|
+
*/
|
|
688
|
+
toUint8Array(): Promise<{ data: Uint8Array; info: OutputInfo }>;
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Set output density (DPI) in EXIF metadata.
|
|
692
|
+
* @param density Density in dots per inch (DPI).
|
|
693
|
+
* @returns A sharp instance that can be used to chain operations
|
|
694
|
+
* @throws {Error} Invalid parameters
|
|
695
|
+
*/
|
|
696
|
+
withDensity(density: number): Sharp;
|
|
641
697
|
|
|
642
698
|
/**
|
|
643
699
|
* Keep all EXIF metadata from the input image in the output image.
|
|
@@ -676,6 +732,20 @@ declare namespace sharp {
|
|
|
676
732
|
*/
|
|
677
733
|
withIccProfile(icc: string, options?: WithIccProfileOptions): Sharp;
|
|
678
734
|
|
|
735
|
+
/**
|
|
736
|
+
* Keep all XMP metadata from the input image in the output image.
|
|
737
|
+
* @returns A sharp instance that can be used to chain operations
|
|
738
|
+
*/
|
|
739
|
+
keepXmp(): Sharp;
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Set XMP metadata in the output image.
|
|
743
|
+
* @param {string} xmp - String containing XMP metadata to be embedded in the output image.
|
|
744
|
+
* @returns A sharp instance that can be used to chain operations
|
|
745
|
+
* @throws {Error} Invalid parameters
|
|
746
|
+
*/
|
|
747
|
+
withXmp(xmp: string): Sharp;
|
|
748
|
+
|
|
679
749
|
/**
|
|
680
750
|
* Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
|
681
751
|
* The default behaviour, when withMetadata is not used, is to strip all metadata and convert to the device-independent sRGB colour space.
|
|
@@ -781,7 +851,7 @@ declare namespace sharp {
|
|
|
781
851
|
* @returns A sharp instance that can be used to chain operations
|
|
782
852
|
*/
|
|
783
853
|
toFormat(
|
|
784
|
-
format: keyof FormatEnum | AvailableFormatInfo,
|
|
854
|
+
format: keyof FormatEnum | AvailableFormatInfo | "avif",
|
|
785
855
|
options?:
|
|
786
856
|
| OutputOptions
|
|
787
857
|
| JpegOptions
|
|
@@ -792,6 +862,7 @@ declare namespace sharp {
|
|
|
792
862
|
| JxlOptions
|
|
793
863
|
| GifOptions
|
|
794
864
|
| Jp2Options
|
|
865
|
+
| RawOptions
|
|
795
866
|
| TiffOptions,
|
|
796
867
|
): Sharp;
|
|
797
868
|
|
|
@@ -799,8 +870,6 @@ declare namespace sharp {
|
|
|
799
870
|
* Use tile-based deep zoom (image pyramid) output.
|
|
800
871
|
* Set the format and options for tile images via the toFormat, jpeg, png or webp functions.
|
|
801
872
|
* Use a .zip or .szi file extension with toFile to write to a compressed archive file format.
|
|
802
|
-
*
|
|
803
|
-
* Warning: multiple sharp instances concurrently producing tile output can expose a possible race condition in some versions of libgsf.
|
|
804
873
|
* @param tile tile options
|
|
805
874
|
* @throws {Error} Invalid options
|
|
806
875
|
* @returns A sharp instance that can be used to chain operations
|
|
@@ -836,7 +905,7 @@ declare namespace sharp {
|
|
|
836
905
|
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
|
837
906
|
* - sharp.strategy: cover only, dynamically crop using either the entropy or attention strategy. Some of these values are based on the object-position CSS property.
|
|
838
907
|
*
|
|
839
|
-
* The
|
|
908
|
+
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
|
840
909
|
* discarding the edge with the lowest score based on the selected strategy.
|
|
841
910
|
* - entropy: focus on the region with the highest Shannon entropy.
|
|
842
911
|
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
|
@@ -899,31 +968,50 @@ declare namespace sharp {
|
|
|
899
968
|
//#endregion
|
|
900
969
|
}
|
|
901
970
|
|
|
971
|
+
type SharpInput = Buffer
|
|
972
|
+
| ArrayBuffer
|
|
973
|
+
| Uint8Array
|
|
974
|
+
| Uint8ClampedArray
|
|
975
|
+
| Int8Array
|
|
976
|
+
| Uint16Array
|
|
977
|
+
| Int16Array
|
|
978
|
+
| Uint32Array
|
|
979
|
+
| Int32Array
|
|
980
|
+
| Float32Array
|
|
981
|
+
| Float64Array
|
|
982
|
+
| string;
|
|
983
|
+
|
|
902
984
|
interface SharpOptions {
|
|
903
985
|
/**
|
|
904
|
-
*
|
|
905
|
-
*
|
|
986
|
+
* Auto-orient based on the EXIF `Orientation` tag, if present.
|
|
987
|
+
* Mirroring is supported and may infer the use of a flip operation.
|
|
988
|
+
*
|
|
989
|
+
* Using this option will remove the EXIF `Orientation` tag, if any.
|
|
906
990
|
*/
|
|
907
|
-
|
|
991
|
+
autoOrient?: boolean | undefined;
|
|
908
992
|
/**
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* @deprecated Use `failOn` instead
|
|
993
|
+
* When to abort processing of invalid pixel data, one of (in order of sensitivity):
|
|
994
|
+
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort.
|
|
995
|
+
* Use the default 'warning' level with untrusted input. (optional, default 'warning')
|
|
914
996
|
*/
|
|
915
|
-
|
|
997
|
+
failOn?: FailOnOptions | undefined;
|
|
916
998
|
/**
|
|
917
999
|
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
|
918
1000
|
* Assumes image dimensions contained in the input metadata can be trusted.
|
|
919
1001
|
* An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF). (optional, default 268402689)
|
|
920
1002
|
*/
|
|
921
1003
|
limitInputPixels?: number | boolean | undefined;
|
|
1004
|
+
/**
|
|
1005
|
+
* Do not process input images where the number of channels exceeds this limit.
|
|
1006
|
+
* Assumes image metadata can be trusted.
|
|
1007
|
+
* An integral Number of channels, zero or false to remove limit, true to use default limit of 5. (optional, default 5)
|
|
1008
|
+
*/
|
|
1009
|
+
limitInputChannels?: number | boolean | undefined;
|
|
922
1010
|
/** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */
|
|
923
1011
|
unlimited?: boolean | undefined;
|
|
924
1012
|
/** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
|
|
925
1013
|
sequentialRead?: boolean | undefined;
|
|
926
|
-
/**
|
|
1014
|
+
/** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */
|
|
927
1015
|
density?: number | undefined;
|
|
928
1016
|
/** Should the embedded ICC profile, if any, be ignored. */
|
|
929
1017
|
ignoreIcc?: boolean | undefined;
|
|
@@ -931,9 +1019,21 @@ declare namespace sharp {
|
|
|
931
1019
|
pages?: number | undefined;
|
|
932
1020
|
/** Page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based. (optional, default 0) */
|
|
933
1021
|
page?: number | undefined;
|
|
934
|
-
/**
|
|
1022
|
+
/** TIFF specific input options */
|
|
1023
|
+
tiff?: TiffInputOptions | undefined;
|
|
1024
|
+
/** SVG specific input options */
|
|
1025
|
+
svg?: SvgInputOptions | undefined;
|
|
1026
|
+
/** PDF specific input options */
|
|
1027
|
+
pdf?: PdfInputOptions | undefined;
|
|
1028
|
+
/** OpenSlide specific input options */
|
|
1029
|
+
openSlide?: OpenSlideInputOptions | undefined;
|
|
1030
|
+
/** JPEG 2000 specific input options */
|
|
1031
|
+
jp2?: Jp2InputOptions | undefined;
|
|
1032
|
+
/** @deprecated Use {@link SharpOptions.tiff} instead */
|
|
935
1033
|
subifd?: number | undefined;
|
|
936
|
-
/**
|
|
1034
|
+
/** @deprecated Use {@link SharpOptions.pdf} instead */
|
|
1035
|
+
pdfBackground?: ColorLike | undefined;
|
|
1036
|
+
/** @deprecated Use {@link SharpOptions.openSlide} instead */
|
|
937
1037
|
level?: number | undefined;
|
|
938
1038
|
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
|
|
939
1039
|
animated?: boolean | undefined;
|
|
@@ -943,6 +1043,8 @@ declare namespace sharp {
|
|
|
943
1043
|
create?: Create | undefined;
|
|
944
1044
|
/** Describes a new text image to be created. */
|
|
945
1045
|
text?: CreateText | undefined;
|
|
1046
|
+
/** Describes how array of input images should be joined. */
|
|
1047
|
+
join?: Join | undefined;
|
|
946
1048
|
}
|
|
947
1049
|
|
|
948
1050
|
interface CacheOptions {
|
|
@@ -969,25 +1071,32 @@ declare namespace sharp {
|
|
|
969
1071
|
interface Raw {
|
|
970
1072
|
width: number;
|
|
971
1073
|
height: number;
|
|
972
|
-
channels:
|
|
1074
|
+
channels: Channels;
|
|
973
1075
|
}
|
|
974
1076
|
|
|
975
1077
|
interface CreateRaw extends Raw {
|
|
976
1078
|
/** Specifies that the raw input has already been premultiplied, set to true to avoid sharp premultiplying the image. (optional, default false) */
|
|
977
1079
|
premultiplied?: boolean | undefined;
|
|
1080
|
+
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
1081
|
+
pageHeight?: number | undefined;
|
|
978
1082
|
}
|
|
979
1083
|
|
|
1084
|
+
type CreateChannels = 3 | 4;
|
|
1085
|
+
|
|
980
1086
|
interface Create {
|
|
981
1087
|
/** Number of pixels wide. */
|
|
982
1088
|
width: number;
|
|
983
1089
|
/** Number of pixels high. */
|
|
984
1090
|
height: number;
|
|
985
|
-
/** Number of bands
|
|
986
|
-
channels:
|
|
1091
|
+
/** Number of bands, 3 for RGB, 4 for RGBA */
|
|
1092
|
+
channels: CreateChannels;
|
|
987
1093
|
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
|
|
988
|
-
background:
|
|
1094
|
+
background: ColorLike;
|
|
989
1095
|
/** Describes a noise to be created. */
|
|
990
1096
|
noise?: Noise | undefined;
|
|
1097
|
+
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
1098
|
+
pageHeight?: number | undefined;
|
|
1099
|
+
|
|
991
1100
|
}
|
|
992
1101
|
|
|
993
1102
|
interface CreateText {
|
|
@@ -1021,6 +1130,48 @@ declare namespace sharp {
|
|
|
1021
1130
|
wrap?: TextWrap;
|
|
1022
1131
|
}
|
|
1023
1132
|
|
|
1133
|
+
interface Join {
|
|
1134
|
+
/** Number of images per row. */
|
|
1135
|
+
across?: number | undefined;
|
|
1136
|
+
/** Treat input as frames of an animated image. */
|
|
1137
|
+
animated?: boolean | undefined;
|
|
1138
|
+
/** Space between images, in pixels. */
|
|
1139
|
+
shim?: number | undefined;
|
|
1140
|
+
/** Background colour. */
|
|
1141
|
+
background?: ColorLike | undefined;
|
|
1142
|
+
/** Horizontal alignment. */
|
|
1143
|
+
halign?: HorizontalAlignment | undefined;
|
|
1144
|
+
/** Vertical alignment. */
|
|
1145
|
+
valign?: VerticalAlignment | undefined;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
interface TiffInputOptions {
|
|
1149
|
+
/** Sub Image File Directory to extract, defaults to main image. Use -1 for all subifds. */
|
|
1150
|
+
subifd?: number | undefined;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
interface SvgInputOptions {
|
|
1154
|
+
/** Custom CSS for SVG input, applied with a User Origin during the CSS cascade. */
|
|
1155
|
+
stylesheet?: string | undefined;
|
|
1156
|
+
/** Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA. */
|
|
1157
|
+
highBitdepth?: boolean | undefined;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
interface PdfInputOptions {
|
|
1161
|
+
/** Background colour to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. */
|
|
1162
|
+
background?: ColorLike | undefined;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
interface OpenSlideInputOptions {
|
|
1166
|
+
/** Level to extract from a multi-level input, zero based. (optional, default 0) */
|
|
1167
|
+
level?: number | undefined;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
interface Jp2InputOptions {
|
|
1171
|
+
/** Set to `true` to load JPEG 2000 images using [oneshot mode](https://github.com/libvips/libvips/issues/4205) */
|
|
1172
|
+
oneshot?: boolean | undefined;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1024
1175
|
interface ExifDir {
|
|
1025
1176
|
[k: string]: string;
|
|
1026
1177
|
}
|
|
@@ -1032,6 +1183,29 @@ declare namespace sharp {
|
|
|
1032
1183
|
'IFD3'?: ExifDir;
|
|
1033
1184
|
}
|
|
1034
1185
|
|
|
1186
|
+
type HeifCompression = 'av1' | 'hevc';
|
|
1187
|
+
|
|
1188
|
+
type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';
|
|
1189
|
+
|
|
1190
|
+
type Unit = 'inch' | 'cm';
|
|
1191
|
+
|
|
1192
|
+
type MediaType =
|
|
1193
|
+
'application/pdf' |
|
|
1194
|
+
'image/avif' |
|
|
1195
|
+
'image/fits' |
|
|
1196
|
+
'image/gif' |
|
|
1197
|
+
'image/heic' |
|
|
1198
|
+
'image/jp2' |
|
|
1199
|
+
'image/jpeg' |
|
|
1200
|
+
'image/jxl' |
|
|
1201
|
+
'image/png' |
|
|
1202
|
+
'image/svg+xml' |
|
|
1203
|
+
'image/tiff' |
|
|
1204
|
+
'image/vnd.radiance' |
|
|
1205
|
+
'image/webp' |
|
|
1206
|
+
'image/x-exr' |
|
|
1207
|
+
'image/x-portable-pixmap';
|
|
1208
|
+
|
|
1035
1209
|
interface WriteableMetadata {
|
|
1036
1210
|
/** Number of pixels per inch (DPI) */
|
|
1037
1211
|
density?: number | undefined;
|
|
@@ -1053,25 +1227,36 @@ declare namespace sharp {
|
|
|
1053
1227
|
/** Number value of the EXIF Orientation header, if present */
|
|
1054
1228
|
orientation?: number | undefined;
|
|
1055
1229
|
/** Name of decoder used to decompress image data e.g. jpeg, png, webp, gif, svg */
|
|
1056
|
-
format
|
|
1230
|
+
format: keyof FormatEnum;
|
|
1057
1231
|
/** Total size of image in bytes, for Stream and Buffer input only */
|
|
1058
1232
|
size?: number | undefined;
|
|
1059
1233
|
/** Number of pixels wide (EXIF orientation is not taken into consideration) */
|
|
1060
|
-
width
|
|
1234
|
+
width: number;
|
|
1061
1235
|
/** Number of pixels high (EXIF orientation is not taken into consideration) */
|
|
1062
|
-
height
|
|
1236
|
+
height: number;
|
|
1237
|
+
/** Any changed metadata after the image orientation is applied. */
|
|
1238
|
+
autoOrient: {
|
|
1239
|
+
/** Number of pixels wide (EXIF orientation is taken into consideration) */
|
|
1240
|
+
width: number;
|
|
1241
|
+
/** Number of pixels high (EXIF orientation is taken into consideration) */
|
|
1242
|
+
height: number;
|
|
1243
|
+
};
|
|
1063
1244
|
/** Name of colour space interpretation */
|
|
1064
|
-
space
|
|
1245
|
+
space: keyof ColourspaceEnum;
|
|
1065
1246
|
/** Number of bands e.g. 3 for sRGB, 4 for CMYK */
|
|
1066
|
-
channels
|
|
1247
|
+
channels: Channels;
|
|
1067
1248
|
/** Name of pixel depth format e.g. uchar, char, ushort, float ... */
|
|
1068
|
-
depth
|
|
1249
|
+
depth: keyof DepthEnum;
|
|
1069
1250
|
/** Number of pixels per inch (DPI), if present */
|
|
1070
1251
|
density?: number | undefined;
|
|
1071
1252
|
/** String containing JPEG chroma subsampling, 4:2:0 or 4:4:4 for RGB, 4:2:0:4 or 4:4:4:4 for CMYK */
|
|
1072
1253
|
chromaSubsampling?: string | undefined;
|
|
1073
1254
|
/** Boolean indicating whether the image is interlaced using a progressive scan */
|
|
1074
|
-
isProgressive
|
|
1255
|
+
isProgressive: boolean;
|
|
1256
|
+
/** Boolean indicating whether the image is palette-based (GIF, PNG). */
|
|
1257
|
+
isPalette: boolean;
|
|
1258
|
+
/** Number of bits per sample for each channel (GIF, PNG). */
|
|
1259
|
+
bitsPerSample?: number | undefined;
|
|
1075
1260
|
/** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
|
|
1076
1261
|
pages?: number | undefined;
|
|
1077
1262
|
/** Number of pixels high each page in a multi-page image will be. */
|
|
@@ -1083,9 +1268,9 @@ declare namespace sharp {
|
|
|
1083
1268
|
/** Number of the primary page in a HEIF image */
|
|
1084
1269
|
pagePrimary?: number | undefined;
|
|
1085
1270
|
/** Boolean indicating the presence of an embedded ICC profile */
|
|
1086
|
-
hasProfile
|
|
1271
|
+
hasProfile: boolean;
|
|
1087
1272
|
/** Boolean indicating the presence of an alpha transparency channel */
|
|
1088
|
-
hasAlpha
|
|
1273
|
+
hasAlpha: boolean;
|
|
1089
1274
|
/** Buffer containing raw EXIF data, if present */
|
|
1090
1275
|
exif?: Buffer | undefined;
|
|
1091
1276
|
/** Buffer containing raw ICC profile data, if present */
|
|
@@ -1094,22 +1279,28 @@ declare namespace sharp {
|
|
|
1094
1279
|
iptc?: Buffer | undefined;
|
|
1095
1280
|
/** Buffer containing raw XMP data, if present */
|
|
1096
1281
|
xmp?: Buffer | undefined;
|
|
1282
|
+
/** String containing XMP data, if valid UTF-8 */
|
|
1283
|
+
xmpAsString?: string | undefined;
|
|
1097
1284
|
/** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
|
|
1098
1285
|
tifftagPhotoshop?: Buffer | undefined;
|
|
1099
1286
|
/** The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC) */
|
|
1100
|
-
compression?:
|
|
1101
|
-
/** Default background colour, if present, for PNG (bKGD) and GIF images
|
|
1102
|
-
background?: { r: number; g: number; b: number } | number;
|
|
1287
|
+
compression?: HeifCompression | undefined;
|
|
1288
|
+
/** Default background colour, if present, for PNG (bKGD) and GIF images */
|
|
1289
|
+
background?: { r: number; g: number; b: number } | { gray: number };
|
|
1103
1290
|
/** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
|
|
1104
1291
|
levels?: LevelMetadata[] | undefined;
|
|
1105
1292
|
/** Number of Sub Image File Directories in an OME-TIFF image */
|
|
1106
1293
|
subifds?: number | undefined;
|
|
1107
1294
|
/** The unit of resolution (density) */
|
|
1108
|
-
resolutionUnit?:
|
|
1295
|
+
resolutionUnit?: Unit | undefined;
|
|
1109
1296
|
/** String containing format for images loaded via *magick */
|
|
1110
1297
|
formatMagick?: string | undefined;
|
|
1111
1298
|
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
|
1112
1299
|
comments?: CommentsMetadata[] | undefined;
|
|
1300
|
+
/** HDR gain map, if present */
|
|
1301
|
+
gainMap?: GainMapMetadata | undefined;
|
|
1302
|
+
/** Media Type (MIME Type) */
|
|
1303
|
+
mediaType?: MediaType | undefined;
|
|
1113
1304
|
}
|
|
1114
1305
|
|
|
1115
1306
|
interface LevelMetadata {
|
|
@@ -1122,16 +1313,21 @@ declare namespace sharp {
|
|
|
1122
1313
|
text: string;
|
|
1123
1314
|
}
|
|
1124
1315
|
|
|
1316
|
+
interface GainMapMetadata {
|
|
1317
|
+
/** JPEG image */
|
|
1318
|
+
image: Buffer;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1125
1321
|
interface Stats {
|
|
1126
1322
|
/** Array of channel statistics for each channel in the image. */
|
|
1127
1323
|
channels: ChannelStats[];
|
|
1128
1324
|
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
|
1129
1325
|
isOpaque: boolean;
|
|
1130
|
-
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any
|
|
1326
|
+
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
|
|
1131
1327
|
entropy: number;
|
|
1132
|
-
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any
|
|
1328
|
+
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
|
|
1133
1329
|
sharpness: number;
|
|
1134
|
-
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram
|
|
1330
|
+
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
|
|
1135
1331
|
dominant: { r: number; g: number; b: number };
|
|
1136
1332
|
}
|
|
1137
1333
|
|
|
@@ -1232,14 +1428,18 @@ declare namespace sharp {
|
|
|
1232
1428
|
nearLossless?: boolean | undefined;
|
|
1233
1429
|
/** Use high quality chroma subsampling (optional, default false) */
|
|
1234
1430
|
smartSubsample?: boolean | undefined;
|
|
1431
|
+
/** Auto-adjust the deblocking filter, slow but can improve low contrast edges (optional, default false) */
|
|
1432
|
+
smartDeblock?: boolean | undefined;
|
|
1235
1433
|
/** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
|
|
1236
1434
|
effort?: number | undefined;
|
|
1237
1435
|
/** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
|
|
1238
|
-
minSize?: boolean;
|
|
1436
|
+
minSize?: boolean | undefined;
|
|
1239
1437
|
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
|
|
1240
|
-
mixed?: boolean;
|
|
1438
|
+
mixed?: boolean | undefined;
|
|
1241
1439
|
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
|
|
1242
1440
|
preset?: keyof PresetEnum | undefined;
|
|
1441
|
+
/** Preserve the colour data in transparent pixels (optional, default false) */
|
|
1442
|
+
exact?: boolean | undefined;
|
|
1243
1443
|
}
|
|
1244
1444
|
|
|
1245
1445
|
interface AvifOptions extends OutputOptions {
|
|
@@ -1253,13 +1453,15 @@ declare namespace sharp {
|
|
|
1253
1453
|
chromaSubsampling?: string | undefined;
|
|
1254
1454
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1255
1455
|
bitdepth?: 8 | 10 | 12 | undefined;
|
|
1456
|
+
/** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
|
|
1457
|
+
tune?: HeifTune | undefined;
|
|
1256
1458
|
}
|
|
1257
1459
|
|
|
1258
1460
|
interface HeifOptions extends OutputOptions {
|
|
1259
1461
|
/** quality, integer 1-100 (optional, default 50) */
|
|
1260
1462
|
quality?: number | undefined;
|
|
1261
1463
|
/** compression format: av1, hevc (optional, default 'av1') */
|
|
1262
|
-
compression?:
|
|
1464
|
+
compression?: HeifCompression | undefined;
|
|
1263
1465
|
/** use lossless compression (optional, default false) */
|
|
1264
1466
|
lossless?: boolean | undefined;
|
|
1265
1467
|
/** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
|
|
@@ -1268,6 +1470,8 @@ declare namespace sharp {
|
|
|
1268
1470
|
chromaSubsampling?: string | undefined;
|
|
1269
1471
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1270
1472
|
bitdepth?: 8 | 10 | 12 | undefined;
|
|
1473
|
+
/** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
|
|
1474
|
+
tune?: HeifTune | undefined;
|
|
1271
1475
|
}
|
|
1272
1476
|
|
|
1273
1477
|
interface GifOptions extends OutputOptions, AnimationOptions {
|
|
@@ -1284,9 +1488,11 @@ declare namespace sharp {
|
|
|
1284
1488
|
/** Level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most) (optional, default 1.0) */
|
|
1285
1489
|
dither?: number | undefined;
|
|
1286
1490
|
/** Maximum inter-frame error for transparency, between 0 (lossless) and 32 (optional, default 0) */
|
|
1287
|
-
interFrameMaxError?: number;
|
|
1491
|
+
interFrameMaxError?: number | undefined;
|
|
1288
1492
|
/** Maximum inter-palette error for palette reuse, between 0 and 256 (optional, default 3) */
|
|
1289
|
-
interPaletteMaxError?: number;
|
|
1493
|
+
interPaletteMaxError?: number | undefined;
|
|
1494
|
+
/** Keep duplicate frames in the output instead of combining them (optional, default false) */
|
|
1495
|
+
keepDuplicateFrames?: boolean | undefined;
|
|
1290
1496
|
}
|
|
1291
1497
|
|
|
1292
1498
|
interface TiffOptions extends OutputOptions {
|
|
@@ -1294,6 +1500,8 @@ declare namespace sharp {
|
|
|
1294
1500
|
quality?: number | undefined;
|
|
1295
1501
|
/** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
|
|
1296
1502
|
compression?: string | undefined;
|
|
1503
|
+
/** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
|
|
1504
|
+
bigtiff?: boolean | undefined;
|
|
1297
1505
|
/** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
|
|
1298
1506
|
predictor?: string | undefined;
|
|
1299
1507
|
/** Write an image pyramid (optional, default false) */
|
|
@@ -1302,18 +1510,18 @@ declare namespace sharp {
|
|
|
1302
1510
|
tile?: boolean | undefined;
|
|
1303
1511
|
/** Horizontal tile size (optional, default 256) */
|
|
1304
1512
|
tileWidth?: number | undefined;
|
|
1305
|
-
/** Vertical tile size (optional, default 256) */
|
|
1513
|
+
/** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
|
|
1306
1514
|
tileHeight?: number | undefined;
|
|
1307
|
-
/** Horizontal resolution in pixels/mm (optional, default 1.0) */
|
|
1515
|
+
/** Horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1308
1516
|
xres?: number | undefined;
|
|
1309
|
-
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
|
1517
|
+
/** Vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1310
1518
|
yres?: number | undefined;
|
|
1311
|
-
/** Reduce bitdepth to 1, 2 or 4 bit (optional
|
|
1312
|
-
bitdepth?: 1 | 2 | 4 |
|
|
1519
|
+
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1520
|
+
bitdepth?: 1 | 2 | 4 | undefined;
|
|
1313
1521
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
|
1314
1522
|
miniswhite?: boolean | undefined;
|
|
1315
1523
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
|
1316
|
-
resolutionUnit?:
|
|
1524
|
+
resolutionUnit?: Unit | undefined;
|
|
1317
1525
|
}
|
|
1318
1526
|
|
|
1319
1527
|
interface PngOptions extends OutputOptions {
|
|
@@ -1339,7 +1547,7 @@ declare namespace sharp {
|
|
|
1339
1547
|
|
|
1340
1548
|
interface RotateOptions {
|
|
1341
1549
|
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
|
|
1342
|
-
background?:
|
|
1550
|
+
background?: ColorLike | undefined;
|
|
1343
1551
|
}
|
|
1344
1552
|
|
|
1345
1553
|
type Precision = 'integer' | 'float' | 'approximate';
|
|
@@ -1355,7 +1563,7 @@ declare namespace sharp {
|
|
|
1355
1563
|
|
|
1356
1564
|
interface FlattenOptions {
|
|
1357
1565
|
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
|
|
1358
|
-
background?:
|
|
1566
|
+
background?: ColorLike | undefined;
|
|
1359
1567
|
}
|
|
1360
1568
|
|
|
1361
1569
|
interface NegateOptions {
|
|
@@ -1380,7 +1588,7 @@ declare namespace sharp {
|
|
|
1380
1588
|
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
|
|
1381
1589
|
position?: number | string | undefined;
|
|
1382
1590
|
/** Background colour when using a fit of contain, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1383
|
-
background?:
|
|
1591
|
+
background?: ColorLike | undefined;
|
|
1384
1592
|
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
|
|
1385
1593
|
kernel?: keyof KernelEnum | undefined;
|
|
1386
1594
|
/** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
|
|
@@ -1392,19 +1600,19 @@ declare namespace sharp {
|
|
|
1392
1600
|
}
|
|
1393
1601
|
|
|
1394
1602
|
interface Region {
|
|
1395
|
-
/** zero-indexed offset from left edge */
|
|
1603
|
+
/** zero-indexed offset from left edge, an integer between 0 and 100000000 */
|
|
1396
1604
|
left: number;
|
|
1397
|
-
/** zero-indexed offset from top edge */
|
|
1605
|
+
/** zero-indexed offset from top edge, an integer between 0 and 100000000 */
|
|
1398
1606
|
top: number;
|
|
1399
|
-
/** dimension of extracted image */
|
|
1607
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1400
1608
|
width: number;
|
|
1401
|
-
/** dimension of extracted image */
|
|
1609
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1402
1610
|
height: number;
|
|
1403
1611
|
}
|
|
1404
1612
|
|
|
1405
1613
|
interface Noise {
|
|
1406
1614
|
/** type of generated noise, currently only gaussian is supported. */
|
|
1407
|
-
type
|
|
1615
|
+
type: 'gaussian';
|
|
1408
1616
|
/** mean of pixels in generated noise. */
|
|
1409
1617
|
mean?: number | undefined;
|
|
1410
1618
|
/** standard deviation of pixels in generated noise. */
|
|
@@ -1414,44 +1622,40 @@ declare namespace sharp {
|
|
|
1414
1622
|
type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
|
|
1415
1623
|
|
|
1416
1624
|
interface ExtendOptions {
|
|
1417
|
-
/** single pixel count to top edge (optional, default 0) */
|
|
1625
|
+
/** single pixel count to top edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1418
1626
|
top?: number | undefined;
|
|
1419
|
-
/** single pixel count to left edge (optional, default 0) */
|
|
1627
|
+
/** single pixel count to left edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1420
1628
|
left?: number | undefined;
|
|
1421
|
-
/** single pixel count to bottom edge (optional, default 0) */
|
|
1629
|
+
/** single pixel count to bottom edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1422
1630
|
bottom?: number | undefined;
|
|
1423
|
-
/** single pixel count to right edge (optional, default 0) */
|
|
1631
|
+
/** single pixel count to right edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1424
1632
|
right?: number | undefined;
|
|
1425
1633
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1426
|
-
background?:
|
|
1634
|
+
background?: ColorLike | undefined;
|
|
1427
1635
|
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
|
|
1428
1636
|
extendWith?: ExtendWith | undefined;
|
|
1429
1637
|
}
|
|
1430
1638
|
|
|
1431
1639
|
interface TrimOptions {
|
|
1432
1640
|
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
|
|
1433
|
-
background?:
|
|
1641
|
+
background?: ColorLike | undefined;
|
|
1434
1642
|
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
|
|
1435
1643
|
threshold?: number | undefined;
|
|
1436
1644
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1437
1645
|
lineArt?: boolean | undefined;
|
|
1646
|
+
/** Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. (optional, default 0) */
|
|
1647
|
+
margin?: number | undefined;
|
|
1438
1648
|
}
|
|
1439
1649
|
|
|
1440
1650
|
interface RawOptions {
|
|
1441
|
-
depth?:
|
|
1651
|
+
depth?: keyof DepthEnum;
|
|
1442
1652
|
}
|
|
1443
1653
|
|
|
1444
|
-
/** 3 for sRGB, 4 for CMYK */
|
|
1445
|
-
type Channels = 3 | 4;
|
|
1446
|
-
|
|
1447
|
-
interface RGBA {
|
|
1448
|
-
r?: number | undefined;
|
|
1449
|
-
g?: number | undefined;
|
|
1450
|
-
b?: number | undefined;
|
|
1451
|
-
alpha?: number | undefined;
|
|
1452
|
-
}
|
|
1654
|
+
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
|
1655
|
+
type Channels = 1 | 2 | 3 | 4;
|
|
1453
1656
|
|
|
1454
|
-
type
|
|
1657
|
+
type Colour = ColorLike;
|
|
1658
|
+
type Color = ColorLike;
|
|
1455
1659
|
|
|
1456
1660
|
interface Kernel {
|
|
1457
1661
|
/** width of the kernel in pixels. */
|
|
@@ -1467,11 +1671,11 @@ declare namespace sharp {
|
|
|
1467
1671
|
}
|
|
1468
1672
|
|
|
1469
1673
|
interface ClaheOptions {
|
|
1470
|
-
/** width of the region */
|
|
1674
|
+
/** width of the region. Valid values are integers in the range 1-65536. */
|
|
1471
1675
|
width: number;
|
|
1472
|
-
/** height of the region */
|
|
1676
|
+
/** height of the region. Valid values are integers in the range 1-65536. */
|
|
1473
1677
|
height: number;
|
|
1474
|
-
/** max slope of the cumulative contrast. A value of 0 disables contrast limiting. Valid values are integers in the range 0-100 (
|
|
1678
|
+
/** max slope of the cumulative contrast. A value of 0 disables contrast limiting. Valid values are integers in the range 0-100. (optional, default 3) */
|
|
1475
1679
|
maxSlope?: number | undefined;
|
|
1476
1680
|
}
|
|
1477
1681
|
|
|
@@ -1505,6 +1709,8 @@ declare namespace sharp {
|
|
|
1505
1709
|
failOn?: FailOnOptions | undefined;
|
|
1506
1710
|
/** see sharp() constructor, (optional, default 268402689) */
|
|
1507
1711
|
limitInputPixels?: number | boolean | undefined;
|
|
1712
|
+
/** see sharp() constructor, (optional, default false) */
|
|
1713
|
+
autoOrient?: boolean | undefined;
|
|
1508
1714
|
}
|
|
1509
1715
|
|
|
1510
1716
|
interface TileOptions {
|
|
@@ -1515,7 +1721,7 @@ declare namespace sharp {
|
|
|
1515
1721
|
/** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
|
|
1516
1722
|
angle?: number | undefined;
|
|
1517
1723
|
/** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
|
|
1518
|
-
background?:
|
|
1724
|
+
background?: ColorLike | undefined;
|
|
1519
1725
|
/** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
|
|
1520
1726
|
depth?: string | undefined;
|
|
1521
1727
|
/** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
|
|
@@ -1576,9 +1782,11 @@ declare namespace sharp {
|
|
|
1576
1782
|
size: number;
|
|
1577
1783
|
width: number;
|
|
1578
1784
|
height: number;
|
|
1579
|
-
channels:
|
|
1785
|
+
channels: Channels;
|
|
1580
1786
|
/** indicating if premultiplication was used */
|
|
1581
1787
|
premultiplied: boolean;
|
|
1788
|
+
/** Indicates if the output image has an alpha channel */
|
|
1789
|
+
hasAlpha: boolean;
|
|
1582
1790
|
/** Only defined when using a crop strategy */
|
|
1583
1791
|
cropOffsetLeft?: number | undefined;
|
|
1584
1792
|
/** Only defined when using a crop strategy */
|
|
@@ -1592,6 +1800,10 @@ declare namespace sharp {
|
|
|
1592
1800
|
/** When using the attention crop strategy, the focal point of the cropped region */
|
|
1593
1801
|
attentionX?: number | undefined;
|
|
1594
1802
|
attentionY?: number | undefined;
|
|
1803
|
+
/** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
|
|
1804
|
+
pages?: number | undefined;
|
|
1805
|
+
/** Number of pixels high each page in a multi-page image will be. */
|
|
1806
|
+
pageHeight?: number | undefined;
|
|
1595
1807
|
}
|
|
1596
1808
|
|
|
1597
1809
|
interface AvailableFormatInfo {
|
|
@@ -1611,9 +1823,12 @@ declare namespace sharp {
|
|
|
1611
1823
|
interface KernelEnum {
|
|
1612
1824
|
nearest: 'nearest';
|
|
1613
1825
|
cubic: 'cubic';
|
|
1826
|
+
linear: 'linear';
|
|
1614
1827
|
mitchell: 'mitchell';
|
|
1615
1828
|
lanczos2: 'lanczos2';
|
|
1616
1829
|
lanczos3: 'lanczos3';
|
|
1830
|
+
mks2013: 'mks2013';
|
|
1831
|
+
mks2021: 'mks2021';
|
|
1617
1832
|
}
|
|
1618
1833
|
|
|
1619
1834
|
interface PresetEnum {
|
|
@@ -1632,11 +1847,38 @@ declare namespace sharp {
|
|
|
1632
1847
|
}
|
|
1633
1848
|
|
|
1634
1849
|
interface ColourspaceEnum {
|
|
1635
|
-
multiband: string;
|
|
1636
1850
|
'b-w': string;
|
|
1637
|
-
|
|
1851
|
+
cmc: string;
|
|
1638
1852
|
cmyk: string;
|
|
1853
|
+
fourier: string;
|
|
1854
|
+
grey16: string;
|
|
1855
|
+
histogram: string;
|
|
1856
|
+
hsv: string;
|
|
1857
|
+
lab: string;
|
|
1858
|
+
labq: string;
|
|
1859
|
+
labs: string;
|
|
1860
|
+
lch: string;
|
|
1861
|
+
matrix: string;
|
|
1862
|
+
multiband: string;
|
|
1863
|
+
rgb: string;
|
|
1864
|
+
rgb16: string;
|
|
1865
|
+
scrgb: string;
|
|
1639
1866
|
srgb: string;
|
|
1867
|
+
xyz: string;
|
|
1868
|
+
yxy: string;
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
interface DepthEnum {
|
|
1872
|
+
char: string;
|
|
1873
|
+
complex: string;
|
|
1874
|
+
double: string;
|
|
1875
|
+
dpcomplex: string;
|
|
1876
|
+
float: string;
|
|
1877
|
+
int: string;
|
|
1878
|
+
short: string;
|
|
1879
|
+
uchar: string;
|
|
1880
|
+
uint: string;
|
|
1881
|
+
ushort: string;
|
|
1640
1882
|
}
|
|
1641
1883
|
|
|
1642
1884
|
type FailOnOptions = 'none' | 'truncated' | 'error' | 'warning';
|
|
@@ -1645,6 +1887,10 @@ declare namespace sharp {
|
|
|
1645
1887
|
|
|
1646
1888
|
type TextWrap = 'word' | 'char' | 'word-char' | 'none';
|
|
1647
1889
|
|
|
1890
|
+
type HorizontalAlignment = 'left' | 'centre' | 'center' | 'right';
|
|
1891
|
+
|
|
1892
|
+
type VerticalAlignment = 'top' | 'centre' | 'center' | 'bottom';
|
|
1893
|
+
|
|
1648
1894
|
type TileContainer = 'fs' | 'zip';
|
|
1649
1895
|
|
|
1650
1896
|
type TileLayout = 'dz' | 'iiif' | 'iiif3' | 'zoomify' | 'google';
|
|
@@ -1699,14 +1945,13 @@ declare namespace sharp {
|
|
|
1699
1945
|
}
|
|
1700
1946
|
|
|
1701
1947
|
interface FormatEnum {
|
|
1702
|
-
|
|
1948
|
+
dcraw: AvailableFormatInfo;
|
|
1703
1949
|
dz: AvailableFormatInfo;
|
|
1950
|
+
exr: AvailableFormatInfo;
|
|
1704
1951
|
fits: AvailableFormatInfo;
|
|
1705
1952
|
gif: AvailableFormatInfo;
|
|
1706
1953
|
heif: AvailableFormatInfo;
|
|
1707
|
-
input: AvailableFormatInfo;
|
|
1708
1954
|
jpeg: AvailableFormatInfo;
|
|
1709
|
-
jpg: AvailableFormatInfo;
|
|
1710
1955
|
jp2: AvailableFormatInfo;
|
|
1711
1956
|
jxl: AvailableFormatInfo;
|
|
1712
1957
|
magick: AvailableFormatInfo;
|
|
@@ -1714,11 +1959,11 @@ declare namespace sharp {
|
|
|
1714
1959
|
pdf: AvailableFormatInfo;
|
|
1715
1960
|
png: AvailableFormatInfo;
|
|
1716
1961
|
ppm: AvailableFormatInfo;
|
|
1962
|
+
rad: AvailableFormatInfo;
|
|
1717
1963
|
raw: AvailableFormatInfo;
|
|
1718
1964
|
svg: AvailableFormatInfo;
|
|
1719
1965
|
tiff: AvailableFormatInfo;
|
|
1720
|
-
|
|
1721
|
-
v: AvailableFormatInfo;
|
|
1966
|
+
vips: AvailableFormatInfo;
|
|
1722
1967
|
webp: AvailableFormatInfo;
|
|
1723
1968
|
}
|
|
1724
1969
|
|