sharp 0.33.5 → 0.35.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 +12 -18
- package/dist/channel.cjs +177 -0
- package/{lib/channel.js → dist/channel.mjs} +11 -8
- package/dist/colour.cjs +195 -0
- package/{lib/colour.js → dist/colour.mjs} +38 -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.mjs +25 -0
- package/dist/input.cjs +814 -0
- package/{lib/input.js → dist/input.mjs} +224 -68
- 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 +987 -0
- package/{lib/operation.js → dist/operation.mjs} +108 -79
- package/{lib/output.js → dist/output.cjs} +243 -36
- package/dist/output.mjs +1794 -0
- package/dist/resize.cjs +613 -0
- package/{lib/resize.js → dist/resize.mjs} +38 -12
- package/dist/sharp.cjs +164 -0
- package/dist/sharp.mjs +164 -0
- package/{lib/utility.js → dist/utility.cjs} +23 -24
- package/dist/utility.mjs +295 -0
- package/install/build.js +38 -0
- package/lib/index.d.ts +347 -125
- package/package.json +75 -84
- 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 +374 -183
- package/src/pipeline.h +34 -7
- package/src/sharp.cc +11 -8
- package/src/stats.cc +16 -13
- package/src/stats.h +6 -3
- package/src/utilities.cc +32 -12
- 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
|
-
import { Duplex } from 'stream';
|
|
30
|
+
import type { Duplex } from 'node:stream';
|
|
31
|
+
import { ColorLike } from '@img/colour';
|
|
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)
|
|
@@ -639,6 +678,21 @@ declare namespace sharp {
|
|
|
639
678
|
*/
|
|
640
679
|
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer; info: OutputInfo }>;
|
|
641
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Write output to a Uint8Array backed by a transferable ArrayBuffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
683
|
+
* By default, the format will match the input image, except SVG input which becomes PNG output.
|
|
684
|
+
* @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
|
|
685
|
+
*/
|
|
686
|
+
toUint8Array(): Promise<{ data: Uint8Array; info: OutputInfo }>;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Set output density (DPI) in EXIF metadata.
|
|
690
|
+
* @param density Density in dots per inch (DPI).
|
|
691
|
+
* @returns A sharp instance that can be used to chain operations
|
|
692
|
+
* @throws {Error} Invalid parameters
|
|
693
|
+
*/
|
|
694
|
+
withDensity(density: number): Sharp;
|
|
695
|
+
|
|
642
696
|
/**
|
|
643
697
|
* Keep all EXIF metadata from the input image in the output image.
|
|
644
698
|
* EXIF metadata is unsupported for TIFF output.
|
|
@@ -676,6 +730,20 @@ declare namespace sharp {
|
|
|
676
730
|
*/
|
|
677
731
|
withIccProfile(icc: string, options?: WithIccProfileOptions): Sharp;
|
|
678
732
|
|
|
733
|
+
/**
|
|
734
|
+
* Keep all XMP metadata from the input image in the output image.
|
|
735
|
+
* @returns A sharp instance that can be used to chain operations
|
|
736
|
+
*/
|
|
737
|
+
keepXmp(): Sharp;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Set XMP metadata in the output image.
|
|
741
|
+
* @param {string} xmp - String containing XMP metadata to be embedded in the output image.
|
|
742
|
+
* @returns A sharp instance that can be used to chain operations
|
|
743
|
+
* @throws {Error} Invalid parameters
|
|
744
|
+
*/
|
|
745
|
+
withXmp(xmp: string): Sharp;
|
|
746
|
+
|
|
679
747
|
/**
|
|
680
748
|
* Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
|
|
681
749
|
* The default behaviour, when withMetadata is not used, is to strip all metadata and convert to the device-independent sRGB colour space.
|
|
@@ -781,7 +849,7 @@ declare namespace sharp {
|
|
|
781
849
|
* @returns A sharp instance that can be used to chain operations
|
|
782
850
|
*/
|
|
783
851
|
toFormat(
|
|
784
|
-
format: keyof FormatEnum | AvailableFormatInfo,
|
|
852
|
+
format: keyof FormatEnum | AvailableFormatInfo | "avif",
|
|
785
853
|
options?:
|
|
786
854
|
| OutputOptions
|
|
787
855
|
| JpegOptions
|
|
@@ -792,6 +860,7 @@ declare namespace sharp {
|
|
|
792
860
|
| JxlOptions
|
|
793
861
|
| GifOptions
|
|
794
862
|
| Jp2Options
|
|
863
|
+
| RawOptions
|
|
795
864
|
| TiffOptions,
|
|
796
865
|
): Sharp;
|
|
797
866
|
|
|
@@ -799,8 +868,6 @@ declare namespace sharp {
|
|
|
799
868
|
* Use tile-based deep zoom (image pyramid) output.
|
|
800
869
|
* Set the format and options for tile images via the toFormat, jpeg, png or webp functions.
|
|
801
870
|
* 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
871
|
* @param tile tile options
|
|
805
872
|
* @throws {Error} Invalid options
|
|
806
873
|
* @returns A sharp instance that can be used to chain operations
|
|
@@ -836,7 +903,7 @@ declare namespace sharp {
|
|
|
836
903
|
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
|
837
904
|
* - 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
905
|
*
|
|
839
|
-
* The
|
|
906
|
+
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
|
840
907
|
* discarding the edge with the lowest score based on the selected strategy.
|
|
841
908
|
* - entropy: focus on the region with the highest Shannon entropy.
|
|
842
909
|
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
|
@@ -899,31 +966,50 @@ declare namespace sharp {
|
|
|
899
966
|
//#endregion
|
|
900
967
|
}
|
|
901
968
|
|
|
969
|
+
type SharpInput = Buffer
|
|
970
|
+
| ArrayBuffer
|
|
971
|
+
| Uint8Array
|
|
972
|
+
| Uint8ClampedArray
|
|
973
|
+
| Int8Array
|
|
974
|
+
| Uint16Array
|
|
975
|
+
| Int16Array
|
|
976
|
+
| Uint32Array
|
|
977
|
+
| Int32Array
|
|
978
|
+
| Float32Array
|
|
979
|
+
| Float64Array
|
|
980
|
+
| string;
|
|
981
|
+
|
|
902
982
|
interface SharpOptions {
|
|
903
983
|
/**
|
|
904
|
-
*
|
|
905
|
-
*
|
|
984
|
+
* Auto-orient based on the EXIF `Orientation` tag, if present.
|
|
985
|
+
* Mirroring is supported and may infer the use of a flip operation.
|
|
986
|
+
*
|
|
987
|
+
* Using this option will remove the EXIF `Orientation` tag, if any.
|
|
906
988
|
*/
|
|
907
|
-
|
|
989
|
+
autoOrient?: boolean | undefined;
|
|
908
990
|
/**
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* @deprecated Use `failOn` instead
|
|
991
|
+
* When to abort processing of invalid pixel data, one of (in order of sensitivity):
|
|
992
|
+
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort.
|
|
993
|
+
* Use the default 'warning' level with untrusted input. (optional, default 'warning')
|
|
914
994
|
*/
|
|
915
|
-
|
|
995
|
+
failOn?: FailOnOptions | undefined;
|
|
916
996
|
/**
|
|
917
997
|
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
|
918
998
|
* Assumes image dimensions contained in the input metadata can be trusted.
|
|
919
999
|
* 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
1000
|
*/
|
|
921
1001
|
limitInputPixels?: number | boolean | undefined;
|
|
1002
|
+
/**
|
|
1003
|
+
* Do not process input images where the number of channels exceeds this limit.
|
|
1004
|
+
* Assumes image metadata can be trusted.
|
|
1005
|
+
* An integral Number of channels, zero or false to remove limit, true to use default limit of 5. (optional, default 5)
|
|
1006
|
+
*/
|
|
1007
|
+
limitInputChannels?: number | boolean | undefined;
|
|
922
1008
|
/** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */
|
|
923
1009
|
unlimited?: boolean | undefined;
|
|
924
1010
|
/** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
|
|
925
1011
|
sequentialRead?: boolean | undefined;
|
|
926
|
-
/**
|
|
1012
|
+
/** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */
|
|
927
1013
|
density?: number | undefined;
|
|
928
1014
|
/** Should the embedded ICC profile, if any, be ignored. */
|
|
929
1015
|
ignoreIcc?: boolean | undefined;
|
|
@@ -931,9 +1017,21 @@ declare namespace sharp {
|
|
|
931
1017
|
pages?: number | undefined;
|
|
932
1018
|
/** Page number to start extracting from for multi-page input (GIF, TIFF, PDF), zero based. (optional, default 0) */
|
|
933
1019
|
page?: number | undefined;
|
|
934
|
-
/**
|
|
1020
|
+
/** TIFF specific input options */
|
|
1021
|
+
tiff?: TiffInputOptions | undefined;
|
|
1022
|
+
/** SVG specific input options */
|
|
1023
|
+
svg?: SvgInputOptions | undefined;
|
|
1024
|
+
/** PDF specific input options */
|
|
1025
|
+
pdf?: PdfInputOptions | undefined;
|
|
1026
|
+
/** OpenSlide specific input options */
|
|
1027
|
+
openSlide?: OpenSlideInputOptions | undefined;
|
|
1028
|
+
/** JPEG 2000 specific input options */
|
|
1029
|
+
jp2?: Jp2InputOptions | undefined;
|
|
1030
|
+
/** @deprecated Use {@link SharpOptions.tiff} instead */
|
|
935
1031
|
subifd?: number | undefined;
|
|
936
|
-
/**
|
|
1032
|
+
/** @deprecated Use {@link SharpOptions.pdf} instead */
|
|
1033
|
+
pdfBackground?: ColorLike | undefined;
|
|
1034
|
+
/** @deprecated Use {@link SharpOptions.openSlide} instead */
|
|
937
1035
|
level?: number | undefined;
|
|
938
1036
|
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
|
|
939
1037
|
animated?: boolean | undefined;
|
|
@@ -943,6 +1041,8 @@ declare namespace sharp {
|
|
|
943
1041
|
create?: Create | undefined;
|
|
944
1042
|
/** Describes a new text image to be created. */
|
|
945
1043
|
text?: CreateText | undefined;
|
|
1044
|
+
/** Describes how array of input images should be joined. */
|
|
1045
|
+
join?: Join | undefined;
|
|
946
1046
|
}
|
|
947
1047
|
|
|
948
1048
|
interface CacheOptions {
|
|
@@ -969,25 +1069,32 @@ declare namespace sharp {
|
|
|
969
1069
|
interface Raw {
|
|
970
1070
|
width: number;
|
|
971
1071
|
height: number;
|
|
972
|
-
channels:
|
|
1072
|
+
channels: Channels;
|
|
973
1073
|
}
|
|
974
1074
|
|
|
975
1075
|
interface CreateRaw extends Raw {
|
|
976
1076
|
/** Specifies that the raw input has already been premultiplied, set to true to avoid sharp premultiplying the image. (optional, default false) */
|
|
977
1077
|
premultiplied?: boolean | undefined;
|
|
1078
|
+
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
1079
|
+
pageHeight?: number | undefined;
|
|
978
1080
|
}
|
|
979
1081
|
|
|
1082
|
+
type CreateChannels = 3 | 4;
|
|
1083
|
+
|
|
980
1084
|
interface Create {
|
|
981
1085
|
/** Number of pixels wide. */
|
|
982
1086
|
width: number;
|
|
983
1087
|
/** Number of pixels high. */
|
|
984
1088
|
height: number;
|
|
985
|
-
/** Number of bands
|
|
986
|
-
channels:
|
|
1089
|
+
/** Number of bands, 3 for RGB, 4 for RGBA */
|
|
1090
|
+
channels: CreateChannels;
|
|
987
1091
|
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
|
|
988
|
-
background:
|
|
1092
|
+
background: ColorLike;
|
|
989
1093
|
/** Describes a noise to be created. */
|
|
990
1094
|
noise?: Noise | undefined;
|
|
1095
|
+
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
1096
|
+
pageHeight?: number | undefined;
|
|
1097
|
+
|
|
991
1098
|
}
|
|
992
1099
|
|
|
993
1100
|
interface CreateText {
|
|
@@ -1021,6 +1128,48 @@ declare namespace sharp {
|
|
|
1021
1128
|
wrap?: TextWrap;
|
|
1022
1129
|
}
|
|
1023
1130
|
|
|
1131
|
+
interface Join {
|
|
1132
|
+
/** Number of images per row. */
|
|
1133
|
+
across?: number | undefined;
|
|
1134
|
+
/** Treat input as frames of an animated image. */
|
|
1135
|
+
animated?: boolean | undefined;
|
|
1136
|
+
/** Space between images, in pixels. */
|
|
1137
|
+
shim?: number | undefined;
|
|
1138
|
+
/** Background colour. */
|
|
1139
|
+
background?: ColorLike | undefined;
|
|
1140
|
+
/** Horizontal alignment. */
|
|
1141
|
+
halign?: HorizontalAlignment | undefined;
|
|
1142
|
+
/** Vertical alignment. */
|
|
1143
|
+
valign?: VerticalAlignment | undefined;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
interface TiffInputOptions {
|
|
1147
|
+
/** Sub Image File Directory to extract, defaults to main image. Use -1 for all subifds. */
|
|
1148
|
+
subifd?: number | undefined;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
interface SvgInputOptions {
|
|
1152
|
+
/** Custom CSS for SVG input, applied with a User Origin during the CSS cascade. */
|
|
1153
|
+
stylesheet?: string | undefined;
|
|
1154
|
+
/** Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA. */
|
|
1155
|
+
highBitdepth?: boolean | undefined;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
interface PdfInputOptions {
|
|
1159
|
+
/** 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. */
|
|
1160
|
+
background?: ColorLike | undefined;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
interface OpenSlideInputOptions {
|
|
1164
|
+
/** Level to extract from a multi-level input, zero based. (optional, default 0) */
|
|
1165
|
+
level?: number | undefined;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
interface Jp2InputOptions {
|
|
1169
|
+
/** Set to `true` to load JPEG 2000 images using [oneshot mode](https://github.com/libvips/libvips/issues/4205) */
|
|
1170
|
+
oneshot?: boolean | undefined;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1024
1173
|
interface ExifDir {
|
|
1025
1174
|
[k: string]: string;
|
|
1026
1175
|
}
|
|
@@ -1032,6 +1181,12 @@ declare namespace sharp {
|
|
|
1032
1181
|
'IFD3'?: ExifDir;
|
|
1033
1182
|
}
|
|
1034
1183
|
|
|
1184
|
+
type HeifCompression = 'av1' | 'hevc';
|
|
1185
|
+
|
|
1186
|
+
type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';
|
|
1187
|
+
|
|
1188
|
+
type Unit = 'inch' | 'cm';
|
|
1189
|
+
|
|
1035
1190
|
interface WriteableMetadata {
|
|
1036
1191
|
/** Number of pixels per inch (DPI) */
|
|
1037
1192
|
density?: number | undefined;
|
|
@@ -1053,25 +1208,36 @@ declare namespace sharp {
|
|
|
1053
1208
|
/** Number value of the EXIF Orientation header, if present */
|
|
1054
1209
|
orientation?: number | undefined;
|
|
1055
1210
|
/** Name of decoder used to decompress image data e.g. jpeg, png, webp, gif, svg */
|
|
1056
|
-
format
|
|
1211
|
+
format: keyof FormatEnum;
|
|
1057
1212
|
/** Total size of image in bytes, for Stream and Buffer input only */
|
|
1058
1213
|
size?: number | undefined;
|
|
1059
1214
|
/** Number of pixels wide (EXIF orientation is not taken into consideration) */
|
|
1060
|
-
width
|
|
1215
|
+
width: number;
|
|
1061
1216
|
/** Number of pixels high (EXIF orientation is not taken into consideration) */
|
|
1062
|
-
height
|
|
1217
|
+
height: number;
|
|
1218
|
+
/** Any changed metadata after the image orientation is applied. */
|
|
1219
|
+
autoOrient: {
|
|
1220
|
+
/** Number of pixels wide (EXIF orientation is taken into consideration) */
|
|
1221
|
+
width: number;
|
|
1222
|
+
/** Number of pixels high (EXIF orientation is taken into consideration) */
|
|
1223
|
+
height: number;
|
|
1224
|
+
};
|
|
1063
1225
|
/** Name of colour space interpretation */
|
|
1064
|
-
space
|
|
1226
|
+
space: keyof ColourspaceEnum;
|
|
1065
1227
|
/** Number of bands e.g. 3 for sRGB, 4 for CMYK */
|
|
1066
|
-
channels
|
|
1228
|
+
channels: Channels;
|
|
1067
1229
|
/** Name of pixel depth format e.g. uchar, char, ushort, float ... */
|
|
1068
|
-
depth
|
|
1230
|
+
depth: keyof DepthEnum;
|
|
1069
1231
|
/** Number of pixels per inch (DPI), if present */
|
|
1070
1232
|
density?: number | undefined;
|
|
1071
1233
|
/** 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
1234
|
chromaSubsampling?: string | undefined;
|
|
1073
1235
|
/** Boolean indicating whether the image is interlaced using a progressive scan */
|
|
1074
|
-
isProgressive
|
|
1236
|
+
isProgressive: boolean;
|
|
1237
|
+
/** Boolean indicating whether the image is palette-based (GIF, PNG). */
|
|
1238
|
+
isPalette: boolean;
|
|
1239
|
+
/** Number of bits per sample for each channel (GIF, PNG). */
|
|
1240
|
+
bitsPerSample?: number | undefined;
|
|
1075
1241
|
/** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
|
|
1076
1242
|
pages?: number | undefined;
|
|
1077
1243
|
/** Number of pixels high each page in a multi-page image will be. */
|
|
@@ -1083,9 +1249,9 @@ declare namespace sharp {
|
|
|
1083
1249
|
/** Number of the primary page in a HEIF image */
|
|
1084
1250
|
pagePrimary?: number | undefined;
|
|
1085
1251
|
/** Boolean indicating the presence of an embedded ICC profile */
|
|
1086
|
-
hasProfile
|
|
1252
|
+
hasProfile: boolean;
|
|
1087
1253
|
/** Boolean indicating the presence of an alpha transparency channel */
|
|
1088
|
-
hasAlpha
|
|
1254
|
+
hasAlpha: boolean;
|
|
1089
1255
|
/** Buffer containing raw EXIF data, if present */
|
|
1090
1256
|
exif?: Buffer | undefined;
|
|
1091
1257
|
/** Buffer containing raw ICC profile data, if present */
|
|
@@ -1094,22 +1260,26 @@ declare namespace sharp {
|
|
|
1094
1260
|
iptc?: Buffer | undefined;
|
|
1095
1261
|
/** Buffer containing raw XMP data, if present */
|
|
1096
1262
|
xmp?: Buffer | undefined;
|
|
1263
|
+
/** String containing XMP data, if valid UTF-8 */
|
|
1264
|
+
xmpAsString?: string | undefined;
|
|
1097
1265
|
/** Buffer containing raw TIFFTAG_PHOTOSHOP data, if present */
|
|
1098
1266
|
tifftagPhotoshop?: Buffer | undefined;
|
|
1099
1267
|
/** 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;
|
|
1268
|
+
compression?: HeifCompression | undefined;
|
|
1269
|
+
/** Default background colour, if present, for PNG (bKGD) and GIF images */
|
|
1270
|
+
background?: { r: number; g: number; b: number } | { gray: number };
|
|
1103
1271
|
/** Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide */
|
|
1104
1272
|
levels?: LevelMetadata[] | undefined;
|
|
1105
1273
|
/** Number of Sub Image File Directories in an OME-TIFF image */
|
|
1106
1274
|
subifds?: number | undefined;
|
|
1107
1275
|
/** The unit of resolution (density) */
|
|
1108
|
-
resolutionUnit?:
|
|
1276
|
+
resolutionUnit?: Unit | undefined;
|
|
1109
1277
|
/** String containing format for images loaded via *magick */
|
|
1110
1278
|
formatMagick?: string | undefined;
|
|
1111
1279
|
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
|
1112
1280
|
comments?: CommentsMetadata[] | undefined;
|
|
1281
|
+
/** HDR gain map, if present */
|
|
1282
|
+
gainMap?: GainMapMetadata | undefined;
|
|
1113
1283
|
}
|
|
1114
1284
|
|
|
1115
1285
|
interface LevelMetadata {
|
|
@@ -1122,16 +1292,21 @@ declare namespace sharp {
|
|
|
1122
1292
|
text: string;
|
|
1123
1293
|
}
|
|
1124
1294
|
|
|
1295
|
+
interface GainMapMetadata {
|
|
1296
|
+
/** JPEG image */
|
|
1297
|
+
image: Buffer;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1125
1300
|
interface Stats {
|
|
1126
1301
|
/** Array of channel statistics for each channel in the image. */
|
|
1127
1302
|
channels: ChannelStats[];
|
|
1128
1303
|
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
|
1129
1304
|
isOpaque: boolean;
|
|
1130
|
-
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any
|
|
1305
|
+
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
|
|
1131
1306
|
entropy: number;
|
|
1132
|
-
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any
|
|
1307
|
+
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
|
|
1133
1308
|
sharpness: number;
|
|
1134
|
-
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram
|
|
1309
|
+
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
|
|
1135
1310
|
dominant: { r: number; g: number; b: number };
|
|
1136
1311
|
}
|
|
1137
1312
|
|
|
@@ -1232,14 +1407,18 @@ declare namespace sharp {
|
|
|
1232
1407
|
nearLossless?: boolean | undefined;
|
|
1233
1408
|
/** Use high quality chroma subsampling (optional, default false) */
|
|
1234
1409
|
smartSubsample?: boolean | undefined;
|
|
1410
|
+
/** Auto-adjust the deblocking filter, slow but can improve low contrast edges (optional, default false) */
|
|
1411
|
+
smartDeblock?: boolean | undefined;
|
|
1235
1412
|
/** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
|
|
1236
1413
|
effort?: number | undefined;
|
|
1237
1414
|
/** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
|
|
1238
|
-
minSize?: boolean;
|
|
1415
|
+
minSize?: boolean | undefined;
|
|
1239
1416
|
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
|
|
1240
|
-
mixed?: boolean;
|
|
1417
|
+
mixed?: boolean | undefined;
|
|
1241
1418
|
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
|
|
1242
1419
|
preset?: keyof PresetEnum | undefined;
|
|
1420
|
+
/** Preserve the colour data in transparent pixels (optional, default false) */
|
|
1421
|
+
exact?: boolean | undefined;
|
|
1243
1422
|
}
|
|
1244
1423
|
|
|
1245
1424
|
interface AvifOptions extends OutputOptions {
|
|
@@ -1253,13 +1432,15 @@ declare namespace sharp {
|
|
|
1253
1432
|
chromaSubsampling?: string | undefined;
|
|
1254
1433
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1255
1434
|
bitdepth?: 8 | 10 | 12 | undefined;
|
|
1435
|
+
/** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
|
|
1436
|
+
tune?: HeifTune | undefined;
|
|
1256
1437
|
}
|
|
1257
1438
|
|
|
1258
1439
|
interface HeifOptions extends OutputOptions {
|
|
1259
1440
|
/** quality, integer 1-100 (optional, default 50) */
|
|
1260
1441
|
quality?: number | undefined;
|
|
1261
1442
|
/** compression format: av1, hevc (optional, default 'av1') */
|
|
1262
|
-
compression?:
|
|
1443
|
+
compression?: HeifCompression | undefined;
|
|
1263
1444
|
/** use lossless compression (optional, default false) */
|
|
1264
1445
|
lossless?: boolean | undefined;
|
|
1265
1446
|
/** Level of CPU effort to reduce file size, between 0 (fastest) and 9 (slowest) (optional, default 4) */
|
|
@@ -1268,6 +1449,8 @@ declare namespace sharp {
|
|
|
1268
1449
|
chromaSubsampling?: string | undefined;
|
|
1269
1450
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1270
1451
|
bitdepth?: 8 | 10 | 12 | undefined;
|
|
1452
|
+
/** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
|
|
1453
|
+
tune?: HeifTune | undefined;
|
|
1271
1454
|
}
|
|
1272
1455
|
|
|
1273
1456
|
interface GifOptions extends OutputOptions, AnimationOptions {
|
|
@@ -1284,9 +1467,11 @@ declare namespace sharp {
|
|
|
1284
1467
|
/** Level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most) (optional, default 1.0) */
|
|
1285
1468
|
dither?: number | undefined;
|
|
1286
1469
|
/** Maximum inter-frame error for transparency, between 0 (lossless) and 32 (optional, default 0) */
|
|
1287
|
-
interFrameMaxError?: number;
|
|
1470
|
+
interFrameMaxError?: number | undefined;
|
|
1288
1471
|
/** Maximum inter-palette error for palette reuse, between 0 and 256 (optional, default 3) */
|
|
1289
|
-
interPaletteMaxError?: number;
|
|
1472
|
+
interPaletteMaxError?: number | undefined;
|
|
1473
|
+
/** Keep duplicate frames in the output instead of combining them (optional, default false) */
|
|
1474
|
+
keepDuplicateFrames?: boolean | undefined;
|
|
1290
1475
|
}
|
|
1291
1476
|
|
|
1292
1477
|
interface TiffOptions extends OutputOptions {
|
|
@@ -1294,6 +1479,8 @@ declare namespace sharp {
|
|
|
1294
1479
|
quality?: number | undefined;
|
|
1295
1480
|
/** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
|
|
1296
1481
|
compression?: string | undefined;
|
|
1482
|
+
/** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
|
|
1483
|
+
bigtiff?: boolean | undefined;
|
|
1297
1484
|
/** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
|
|
1298
1485
|
predictor?: string | undefined;
|
|
1299
1486
|
/** Write an image pyramid (optional, default false) */
|
|
@@ -1308,12 +1495,12 @@ declare namespace sharp {
|
|
|
1308
1495
|
xres?: number | undefined;
|
|
1309
1496
|
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
|
1310
1497
|
yres?: number | undefined;
|
|
1311
|
-
/** Reduce bitdepth to 1, 2 or 4 bit (optional
|
|
1312
|
-
bitdepth?: 1 | 2 | 4 |
|
|
1498
|
+
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1499
|
+
bitdepth?: 1 | 2 | 4 | undefined;
|
|
1313
1500
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
|
1314
1501
|
miniswhite?: boolean | undefined;
|
|
1315
1502
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
|
1316
|
-
resolutionUnit?:
|
|
1503
|
+
resolutionUnit?: Unit | undefined;
|
|
1317
1504
|
}
|
|
1318
1505
|
|
|
1319
1506
|
interface PngOptions extends OutputOptions {
|
|
@@ -1339,7 +1526,7 @@ declare namespace sharp {
|
|
|
1339
1526
|
|
|
1340
1527
|
interface RotateOptions {
|
|
1341
1528
|
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
|
|
1342
|
-
background?:
|
|
1529
|
+
background?: ColorLike | undefined;
|
|
1343
1530
|
}
|
|
1344
1531
|
|
|
1345
1532
|
type Precision = 'integer' | 'float' | 'approximate';
|
|
@@ -1355,7 +1542,7 @@ declare namespace sharp {
|
|
|
1355
1542
|
|
|
1356
1543
|
interface FlattenOptions {
|
|
1357
1544
|
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
|
|
1358
|
-
background?:
|
|
1545
|
+
background?: ColorLike | undefined;
|
|
1359
1546
|
}
|
|
1360
1547
|
|
|
1361
1548
|
interface NegateOptions {
|
|
@@ -1380,7 +1567,7 @@ declare namespace sharp {
|
|
|
1380
1567
|
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
|
|
1381
1568
|
position?: number | string | undefined;
|
|
1382
1569
|
/** 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?:
|
|
1570
|
+
background?: ColorLike | undefined;
|
|
1384
1571
|
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
|
|
1385
1572
|
kernel?: keyof KernelEnum | undefined;
|
|
1386
1573
|
/** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
|
|
@@ -1404,7 +1591,7 @@ declare namespace sharp {
|
|
|
1404
1591
|
|
|
1405
1592
|
interface Noise {
|
|
1406
1593
|
/** type of generated noise, currently only gaussian is supported. */
|
|
1407
|
-
type
|
|
1594
|
+
type: 'gaussian';
|
|
1408
1595
|
/** mean of pixels in generated noise. */
|
|
1409
1596
|
mean?: number | undefined;
|
|
1410
1597
|
/** standard deviation of pixels in generated noise. */
|
|
@@ -1423,35 +1610,31 @@ declare namespace sharp {
|
|
|
1423
1610
|
/** single pixel count to right edge (optional, default 0) */
|
|
1424
1611
|
right?: number | undefined;
|
|
1425
1612
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1426
|
-
background?:
|
|
1613
|
+
background?: ColorLike | undefined;
|
|
1427
1614
|
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
|
|
1428
1615
|
extendWith?: ExtendWith | undefined;
|
|
1429
1616
|
}
|
|
1430
1617
|
|
|
1431
1618
|
interface TrimOptions {
|
|
1432
1619
|
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
|
|
1433
|
-
background?:
|
|
1620
|
+
background?: ColorLike | undefined;
|
|
1434
1621
|
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
|
|
1435
1622
|
threshold?: number | undefined;
|
|
1436
1623
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1437
1624
|
lineArt?: boolean | undefined;
|
|
1625
|
+
/** Leave a margin around trimmed content, value is in pixels. (optional, default 0) */
|
|
1626
|
+
margin?: number | undefined;
|
|
1438
1627
|
}
|
|
1439
1628
|
|
|
1440
1629
|
interface RawOptions {
|
|
1441
|
-
depth?:
|
|
1630
|
+
depth?: keyof DepthEnum;
|
|
1442
1631
|
}
|
|
1443
1632
|
|
|
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
|
-
}
|
|
1633
|
+
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
|
1634
|
+
type Channels = 1 | 2 | 3 | 4;
|
|
1453
1635
|
|
|
1454
|
-
type
|
|
1636
|
+
type Colour = ColorLike;
|
|
1637
|
+
type Color = ColorLike;
|
|
1455
1638
|
|
|
1456
1639
|
interface Kernel {
|
|
1457
1640
|
/** width of the kernel in pixels. */
|
|
@@ -1505,6 +1688,8 @@ declare namespace sharp {
|
|
|
1505
1688
|
failOn?: FailOnOptions | undefined;
|
|
1506
1689
|
/** see sharp() constructor, (optional, default 268402689) */
|
|
1507
1690
|
limitInputPixels?: number | boolean | undefined;
|
|
1691
|
+
/** see sharp() constructor, (optional, default false) */
|
|
1692
|
+
autoOrient?: boolean | undefined;
|
|
1508
1693
|
}
|
|
1509
1694
|
|
|
1510
1695
|
interface TileOptions {
|
|
@@ -1515,7 +1700,7 @@ declare namespace sharp {
|
|
|
1515
1700
|
/** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
|
|
1516
1701
|
angle?: number | undefined;
|
|
1517
1702
|
/** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
|
|
1518
|
-
background?:
|
|
1703
|
+
background?: ColorLike | undefined;
|
|
1519
1704
|
/** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
|
|
1520
1705
|
depth?: string | undefined;
|
|
1521
1706
|
/** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
|
|
@@ -1576,7 +1761,7 @@ declare namespace sharp {
|
|
|
1576
1761
|
size: number;
|
|
1577
1762
|
width: number;
|
|
1578
1763
|
height: number;
|
|
1579
|
-
channels:
|
|
1764
|
+
channels: Channels;
|
|
1580
1765
|
/** indicating if premultiplication was used */
|
|
1581
1766
|
premultiplied: boolean;
|
|
1582
1767
|
/** Only defined when using a crop strategy */
|
|
@@ -1592,6 +1777,10 @@ declare namespace sharp {
|
|
|
1592
1777
|
/** When using the attention crop strategy, the focal point of the cropped region */
|
|
1593
1778
|
attentionX?: number | undefined;
|
|
1594
1779
|
attentionY?: number | undefined;
|
|
1780
|
+
/** Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP */
|
|
1781
|
+
pages?: number | undefined;
|
|
1782
|
+
/** Number of pixels high each page in a multi-page image will be. */
|
|
1783
|
+
pageHeight?: number | undefined;
|
|
1595
1784
|
}
|
|
1596
1785
|
|
|
1597
1786
|
interface AvailableFormatInfo {
|
|
@@ -1611,9 +1800,12 @@ declare namespace sharp {
|
|
|
1611
1800
|
interface KernelEnum {
|
|
1612
1801
|
nearest: 'nearest';
|
|
1613
1802
|
cubic: 'cubic';
|
|
1803
|
+
linear: 'linear';
|
|
1614
1804
|
mitchell: 'mitchell';
|
|
1615
1805
|
lanczos2: 'lanczos2';
|
|
1616
1806
|
lanczos3: 'lanczos3';
|
|
1807
|
+
mks2013: 'mks2013';
|
|
1808
|
+
mks2021: 'mks2021';
|
|
1617
1809
|
}
|
|
1618
1810
|
|
|
1619
1811
|
interface PresetEnum {
|
|
@@ -1632,11 +1824,38 @@ declare namespace sharp {
|
|
|
1632
1824
|
}
|
|
1633
1825
|
|
|
1634
1826
|
interface ColourspaceEnum {
|
|
1635
|
-
multiband: string;
|
|
1636
1827
|
'b-w': string;
|
|
1637
|
-
|
|
1828
|
+
cmc: string;
|
|
1638
1829
|
cmyk: string;
|
|
1830
|
+
fourier: string;
|
|
1831
|
+
grey16: string;
|
|
1832
|
+
histogram: string;
|
|
1833
|
+
hsv: string;
|
|
1834
|
+
lab: string;
|
|
1835
|
+
labq: string;
|
|
1836
|
+
labs: string;
|
|
1837
|
+
lch: string;
|
|
1838
|
+
matrix: string;
|
|
1839
|
+
multiband: string;
|
|
1840
|
+
rgb: string;
|
|
1841
|
+
rgb16: string;
|
|
1842
|
+
scrgb: string;
|
|
1639
1843
|
srgb: string;
|
|
1844
|
+
xyz: string;
|
|
1845
|
+
yxy: string;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
interface DepthEnum {
|
|
1849
|
+
char: string;
|
|
1850
|
+
complex: string;
|
|
1851
|
+
double: string;
|
|
1852
|
+
dpcomplex: string;
|
|
1853
|
+
float: string;
|
|
1854
|
+
int: string;
|
|
1855
|
+
short: string;
|
|
1856
|
+
uchar: string;
|
|
1857
|
+
uint: string;
|
|
1858
|
+
ushort: string;
|
|
1640
1859
|
}
|
|
1641
1860
|
|
|
1642
1861
|
type FailOnOptions = 'none' | 'truncated' | 'error' | 'warning';
|
|
@@ -1645,6 +1864,10 @@ declare namespace sharp {
|
|
|
1645
1864
|
|
|
1646
1865
|
type TextWrap = 'word' | 'char' | 'word-char' | 'none';
|
|
1647
1866
|
|
|
1867
|
+
type HorizontalAlignment = 'left' | 'centre' | 'center' | 'right';
|
|
1868
|
+
|
|
1869
|
+
type VerticalAlignment = 'top' | 'centre' | 'center' | 'bottom';
|
|
1870
|
+
|
|
1648
1871
|
type TileContainer = 'fs' | 'zip';
|
|
1649
1872
|
|
|
1650
1873
|
type TileLayout = 'dz' | 'iiif' | 'iiif3' | 'zoomify' | 'google';
|
|
@@ -1699,14 +1922,13 @@ declare namespace sharp {
|
|
|
1699
1922
|
}
|
|
1700
1923
|
|
|
1701
1924
|
interface FormatEnum {
|
|
1702
|
-
|
|
1925
|
+
dcraw: AvailableFormatInfo;
|
|
1703
1926
|
dz: AvailableFormatInfo;
|
|
1927
|
+
exr: AvailableFormatInfo;
|
|
1704
1928
|
fits: AvailableFormatInfo;
|
|
1705
1929
|
gif: AvailableFormatInfo;
|
|
1706
1930
|
heif: AvailableFormatInfo;
|
|
1707
|
-
input: AvailableFormatInfo;
|
|
1708
1931
|
jpeg: AvailableFormatInfo;
|
|
1709
|
-
jpg: AvailableFormatInfo;
|
|
1710
1932
|
jp2: AvailableFormatInfo;
|
|
1711
1933
|
jxl: AvailableFormatInfo;
|
|
1712
1934
|
magick: AvailableFormatInfo;
|
|
@@ -1714,11 +1936,11 @@ declare namespace sharp {
|
|
|
1714
1936
|
pdf: AvailableFormatInfo;
|
|
1715
1937
|
png: AvailableFormatInfo;
|
|
1716
1938
|
ppm: AvailableFormatInfo;
|
|
1939
|
+
rad: AvailableFormatInfo;
|
|
1717
1940
|
raw: AvailableFormatInfo;
|
|
1718
1941
|
svg: AvailableFormatInfo;
|
|
1719
1942
|
tiff: AvailableFormatInfo;
|
|
1720
|
-
|
|
1721
|
-
v: AvailableFormatInfo;
|
|
1943
|
+
vips: AvailableFormatInfo;
|
|
1722
1944
|
webp: AvailableFormatInfo;
|
|
1723
1945
|
}
|
|
1724
1946
|
|