@depup/sharp 0.34.5-depup.0 → 0.35.4-depup.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 +16 -109
- package/changes.json +5 -0
- package/{lib/channel.js → dist/channel.cjs} +1 -1
- package/dist/channel.mjs +177 -0
- package/{lib/colour.js → dist/colour.cjs} +11 -7
- package/dist/colour.mjs +199 -0
- package/{lib/composite.js → dist/composite.cjs} +8 -7
- package/dist/composite.mjs +213 -0
- package/{lib/constructor.js → dist/constructor.cjs} +42 -30
- 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/{lib/input.js → dist/input.cjs} +47 -37
- package/dist/input.mjs +819 -0
- package/{lib/is.js → dist/is.cjs} +1 -1
- package/dist/is.mjs +143 -0
- package/{lib/libvips.js → dist/libvips.cjs} +35 -30
- package/dist/libvips.mjs +212 -0
- package/{lib/operation.js → dist/operation.cjs} +37 -51
- package/dist/operation.mjs +1002 -0
- package/{lib/output.js → dist/output.cjs} +166 -47
- package/dist/output.mjs +1785 -0
- package/{lib/resize.js → dist/resize.cjs} +54 -32
- package/dist/resize.mjs +617 -0
- package/dist/sharp.cjs +174 -0
- package/dist/sharp.mjs +174 -0
- package/{lib/utility.js → dist/utility.cjs} +18 -8
- package/dist/utility.mjs +301 -0
- package/install/build.js +3 -3
- package/lib/index.d.ts +111 -83
- package/package.json +95 -54
- package/src/binding.gyp +19 -14
- package/src/common.cc +77 -21
- package/src/common.h +23 -4
- package/src/metadata.cc +66 -8
- package/src/metadata.h +6 -1
- package/src/operations.cc +25 -8
- package/src/operations.h +1 -1
- package/src/pipeline.cc +203 -69
- package/src/pipeline.h +15 -1
- package/src/stats.cc +6 -6
- package/src/utilities.cc +7 -6
- package/install/check.js +0 -14
- package/lib/index.js +0 -16
- package/lib/sharp.js +0 -121
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
|
|
|
@@ -234,7 +235,7 @@ declare namespace sharp {
|
|
|
234
235
|
* @param tint Parsed by the color module.
|
|
235
236
|
* @returns A sharp instance that can be used to chain operations
|
|
236
237
|
*/
|
|
237
|
-
tint(tint:
|
|
238
|
+
tint(tint: ColorLike): Sharp;
|
|
238
239
|
|
|
239
240
|
/**
|
|
240
241
|
* Convert to 8-bit greyscale; 256 shades of grey.
|
|
@@ -259,7 +260,6 @@ declare namespace sharp {
|
|
|
259
260
|
* Set the pipeline colourspace.
|
|
260
261
|
* The input image will be converted to the provided colourspace at the start of the pipeline.
|
|
261
262
|
* All operations will use this colourspace before converting to the output colourspace, as defined by toColourspace.
|
|
262
|
-
* This feature is experimental and has not yet been fully-tested with all operations.
|
|
263
263
|
*
|
|
264
264
|
* @param colourspace pipeline colourspace e.g. rgb16, scrgb, lab, grey16 ...
|
|
265
265
|
* @throws {Error} Invalid parameters
|
|
@@ -470,21 +470,6 @@ declare namespace sharp {
|
|
|
470
470
|
*/
|
|
471
471
|
sharpen(options?: SharpenOptions): Sharp;
|
|
472
472
|
|
|
473
|
-
/**
|
|
474
|
-
* Sharpen the image.
|
|
475
|
-
* When used without parameters, performs a fast, mild sharpen of the output image.
|
|
476
|
-
* When a sigma is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.
|
|
477
|
-
* Fine-grained control over the level of sharpening in "flat" (m1) and "jagged" (m2) areas is available.
|
|
478
|
-
* @param sigma the sigma of the Gaussian mask, where sigma = 1 + radius / 2.
|
|
479
|
-
* @param flat the level of sharpening to apply to "flat" areas. (optional, default 1.0)
|
|
480
|
-
* @param jagged the level of sharpening to apply to "jagged" areas. (optional, default 2.0)
|
|
481
|
-
* @throws {Error} Invalid parameters
|
|
482
|
-
* @returns A sharp instance that can be used to chain operations
|
|
483
|
-
*
|
|
484
|
-
* @deprecated Use the object parameter `sharpen({sigma, m1, m2, x1, y2, y3})` instead
|
|
485
|
-
*/
|
|
486
|
-
sharpen(sigma?: number, flat?: number, jagged?: number): Sharp;
|
|
487
|
-
|
|
488
473
|
/**
|
|
489
474
|
* Apply median filter. When used without parameters the default window is 3x3.
|
|
490
475
|
* @param size square mask size: size x size (optional, default 3)
|
|
@@ -673,25 +658,42 @@ declare namespace sharp {
|
|
|
673
658
|
* @param callback Callback function called on completion with three arguments (err, buffer, info).
|
|
674
659
|
* @returns A sharp instance that can be used to chain operations
|
|
675
660
|
*/
|
|
676
|
-
toBuffer(callback: (err: Error, buffer: Buffer
|
|
661
|
+
toBuffer(callback: (err: Error, buffer: Buffer<ArrayBuffer>, info: OutputInfo) => void): Sharp;
|
|
677
662
|
|
|
678
663
|
/**
|
|
679
664
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
680
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.
|
|
681
667
|
* @param options resolve options
|
|
682
668
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
683
669
|
* @returns A promise that resolves with the Buffer data.
|
|
684
670
|
*/
|
|
685
|
-
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer
|
|
671
|
+
toBuffer(options?: { resolveWithObject: false }): Promise<Buffer<ArrayBuffer>>;
|
|
686
672
|
|
|
687
673
|
/**
|
|
688
674
|
* Write output to a Buffer. JPEG, PNG, WebP, AVIF, TIFF, GIF and RAW output are supported.
|
|
689
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.
|
|
690
677
|
* @param options resolve options
|
|
691
678
|
* @param options.resolveWithObject Resolve the Promise with an Object containing data and info properties instead of resolving only with data.
|
|
692
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
|
|
693
680
|
*/
|
|
694
|
-
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;
|
|
695
697
|
|
|
696
698
|
/**
|
|
697
699
|
* Keep all EXIF metadata from the input image in the output image.
|
|
@@ -849,7 +851,7 @@ declare namespace sharp {
|
|
|
849
851
|
* @returns A sharp instance that can be used to chain operations
|
|
850
852
|
*/
|
|
851
853
|
toFormat(
|
|
852
|
-
format: keyof FormatEnum | AvailableFormatInfo,
|
|
854
|
+
format: keyof FormatEnum | AvailableFormatInfo | "avif",
|
|
853
855
|
options?:
|
|
854
856
|
| OutputOptions
|
|
855
857
|
| JpegOptions
|
|
@@ -903,7 +905,7 @@ declare namespace sharp {
|
|
|
903
905
|
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
|
904
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.
|
|
905
907
|
*
|
|
906
|
-
* The
|
|
908
|
+
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
|
907
909
|
* discarding the edge with the lowest score based on the selected strategy.
|
|
908
910
|
* - entropy: focus on the region with the highest Shannon entropy.
|
|
909
911
|
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
|
@@ -989,28 +991,27 @@ declare namespace sharp {
|
|
|
989
991
|
autoOrient?: boolean | undefined;
|
|
990
992
|
/**
|
|
991
993
|
* 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.
|
|
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')
|
|
993
996
|
*/
|
|
994
997
|
failOn?: FailOnOptions | undefined;
|
|
995
|
-
/**
|
|
996
|
-
* By default halt processing and raise an error when loading invalid images.
|
|
997
|
-
* Set this flag to false if you'd rather apply a "best effort" to decode images,
|
|
998
|
-
* even if the data is corrupt or invalid. (optional, default true)
|
|
999
|
-
*
|
|
1000
|
-
* @deprecated Use `failOn` instead
|
|
1001
|
-
*/
|
|
1002
|
-
failOnError?: boolean | undefined;
|
|
1003
998
|
/**
|
|
1004
999
|
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
|
1005
1000
|
* Assumes image dimensions contained in the input metadata can be trusted.
|
|
1006
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)
|
|
1007
1002
|
*/
|
|
1008
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;
|
|
1009
1010
|
/** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */
|
|
1010
1011
|
unlimited?: boolean | undefined;
|
|
1011
1012
|
/** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
|
|
1012
1013
|
sequentialRead?: boolean | undefined;
|
|
1013
|
-
/**
|
|
1014
|
+
/** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */
|
|
1014
1015
|
density?: number | undefined;
|
|
1015
1016
|
/** Should the embedded ICC profile, if any, be ignored. */
|
|
1016
1017
|
ignoreIcc?: boolean | undefined;
|
|
@@ -1028,11 +1029,11 @@ declare namespace sharp {
|
|
|
1028
1029
|
openSlide?: OpenSlideInputOptions | undefined;
|
|
1029
1030
|
/** JPEG 2000 specific input options */
|
|
1030
1031
|
jp2?: Jp2InputOptions | undefined;
|
|
1031
|
-
/**
|
|
1032
|
+
/** @deprecated Use {@link SharpOptions.tiff} instead */
|
|
1032
1033
|
subifd?: number | undefined;
|
|
1033
|
-
/**
|
|
1034
|
-
pdfBackground?:
|
|
1035
|
-
/**
|
|
1034
|
+
/** @deprecated Use {@link SharpOptions.pdf} instead */
|
|
1035
|
+
pdfBackground?: ColorLike | undefined;
|
|
1036
|
+
/** @deprecated Use {@link SharpOptions.openSlide} instead */
|
|
1036
1037
|
level?: number | undefined;
|
|
1037
1038
|
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
|
|
1038
1039
|
animated?: boolean | undefined;
|
|
@@ -1090,7 +1091,7 @@ declare namespace sharp {
|
|
|
1090
1091
|
/** Number of bands, 3 for RGB, 4 for RGBA */
|
|
1091
1092
|
channels: CreateChannels;
|
|
1092
1093
|
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
|
|
1093
|
-
background:
|
|
1094
|
+
background: ColorLike;
|
|
1094
1095
|
/** Describes a noise to be created. */
|
|
1095
1096
|
noise?: Noise | undefined;
|
|
1096
1097
|
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
@@ -1137,7 +1138,7 @@ declare namespace sharp {
|
|
|
1137
1138
|
/** Space between images, in pixels. */
|
|
1138
1139
|
shim?: number | undefined;
|
|
1139
1140
|
/** Background colour. */
|
|
1140
|
-
background?:
|
|
1141
|
+
background?: ColorLike | undefined;
|
|
1141
1142
|
/** Horizontal alignment. */
|
|
1142
1143
|
halign?: HorizontalAlignment | undefined;
|
|
1143
1144
|
/** Vertical alignment. */
|
|
@@ -1158,7 +1159,7 @@ declare namespace sharp {
|
|
|
1158
1159
|
|
|
1159
1160
|
interface PdfInputOptions {
|
|
1160
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. */
|
|
1161
|
-
background?:
|
|
1162
|
+
background?: ColorLike | undefined;
|
|
1162
1163
|
}
|
|
1163
1164
|
|
|
1164
1165
|
interface OpenSlideInputOptions {
|
|
@@ -1184,8 +1185,27 @@ declare namespace sharp {
|
|
|
1184
1185
|
|
|
1185
1186
|
type HeifCompression = 'av1' | 'hevc';
|
|
1186
1187
|
|
|
1188
|
+
type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';
|
|
1189
|
+
|
|
1187
1190
|
type Unit = 'inch' | 'cm';
|
|
1188
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
|
+
|
|
1189
1209
|
interface WriteableMetadata {
|
|
1190
1210
|
/** Number of pixels per inch (DPI) */
|
|
1191
1211
|
density?: number | undefined;
|
|
@@ -1277,6 +1297,10 @@ declare namespace sharp {
|
|
|
1277
1297
|
formatMagick?: string | undefined;
|
|
1278
1298
|
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
|
1279
1299
|
comments?: CommentsMetadata[] | undefined;
|
|
1300
|
+
/** HDR gain map, if present */
|
|
1301
|
+
gainMap?: GainMapMetadata | undefined;
|
|
1302
|
+
/** Media Type (MIME Type) */
|
|
1303
|
+
mediaType?: MediaType | undefined;
|
|
1280
1304
|
}
|
|
1281
1305
|
|
|
1282
1306
|
interface LevelMetadata {
|
|
@@ -1289,16 +1313,21 @@ declare namespace sharp {
|
|
|
1289
1313
|
text: string;
|
|
1290
1314
|
}
|
|
1291
1315
|
|
|
1316
|
+
interface GainMapMetadata {
|
|
1317
|
+
/** JPEG image */
|
|
1318
|
+
image: Buffer;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1292
1321
|
interface Stats {
|
|
1293
1322
|
/** Array of channel statistics for each channel in the image. */
|
|
1294
1323
|
channels: ChannelStats[];
|
|
1295
1324
|
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
|
1296
1325
|
isOpaque: boolean;
|
|
1297
|
-
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any
|
|
1326
|
+
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
|
|
1298
1327
|
entropy: number;
|
|
1299
|
-
/** 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 */
|
|
1300
1329
|
sharpness: number;
|
|
1301
|
-
/** 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 */
|
|
1302
1331
|
dominant: { r: number; g: number; b: number };
|
|
1303
1332
|
}
|
|
1304
1333
|
|
|
@@ -1404,11 +1433,13 @@ declare namespace sharp {
|
|
|
1404
1433
|
/** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
|
|
1405
1434
|
effort?: number | undefined;
|
|
1406
1435
|
/** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
|
|
1407
|
-
minSize?: boolean;
|
|
1436
|
+
minSize?: boolean | undefined;
|
|
1408
1437
|
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
|
|
1409
|
-
mixed?: boolean;
|
|
1438
|
+
mixed?: boolean | undefined;
|
|
1410
1439
|
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
|
|
1411
1440
|
preset?: keyof PresetEnum | undefined;
|
|
1441
|
+
/** Preserve the colour data in transparent pixels (optional, default false) */
|
|
1442
|
+
exact?: boolean | undefined;
|
|
1412
1443
|
}
|
|
1413
1444
|
|
|
1414
1445
|
interface AvifOptions extends OutputOptions {
|
|
@@ -1422,6 +1453,8 @@ declare namespace sharp {
|
|
|
1422
1453
|
chromaSubsampling?: string | undefined;
|
|
1423
1454
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1424
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;
|
|
1425
1458
|
}
|
|
1426
1459
|
|
|
1427
1460
|
interface HeifOptions extends OutputOptions {
|
|
@@ -1437,6 +1470,8 @@ declare namespace sharp {
|
|
|
1437
1470
|
chromaSubsampling?: string | undefined;
|
|
1438
1471
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1439
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;
|
|
1440
1475
|
}
|
|
1441
1476
|
|
|
1442
1477
|
interface GifOptions extends OutputOptions, AnimationOptions {
|
|
@@ -1475,14 +1510,14 @@ declare namespace sharp {
|
|
|
1475
1510
|
tile?: boolean | undefined;
|
|
1476
1511
|
/** Horizontal tile size (optional, default 256) */
|
|
1477
1512
|
tileWidth?: number | undefined;
|
|
1478
|
-
/** Vertical tile size (optional, default 256) */
|
|
1513
|
+
/** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
|
|
1479
1514
|
tileHeight?: number | undefined;
|
|
1480
|
-
/** 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) */
|
|
1481
1516
|
xres?: number | undefined;
|
|
1482
|
-
/** 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) */
|
|
1483
1518
|
yres?: number | undefined;
|
|
1484
|
-
/** Reduce bitdepth to 1, 2 or 4 bit (optional
|
|
1485
|
-
bitdepth?: 1 | 2 | 4 |
|
|
1519
|
+
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1520
|
+
bitdepth?: 1 | 2 | 4 | undefined;
|
|
1486
1521
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
|
1487
1522
|
miniswhite?: boolean | undefined;
|
|
1488
1523
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
|
@@ -1512,7 +1547,7 @@ declare namespace sharp {
|
|
|
1512
1547
|
|
|
1513
1548
|
interface RotateOptions {
|
|
1514
1549
|
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
|
|
1515
|
-
background?:
|
|
1550
|
+
background?: ColorLike | undefined;
|
|
1516
1551
|
}
|
|
1517
1552
|
|
|
1518
1553
|
type Precision = 'integer' | 'float' | 'approximate';
|
|
@@ -1528,7 +1563,7 @@ declare namespace sharp {
|
|
|
1528
1563
|
|
|
1529
1564
|
interface FlattenOptions {
|
|
1530
1565
|
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
|
|
1531
|
-
background?:
|
|
1566
|
+
background?: ColorLike | undefined;
|
|
1532
1567
|
}
|
|
1533
1568
|
|
|
1534
1569
|
interface NegateOptions {
|
|
@@ -1553,7 +1588,7 @@ declare namespace sharp {
|
|
|
1553
1588
|
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
|
|
1554
1589
|
position?: number | string | undefined;
|
|
1555
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}) */
|
|
1556
|
-
background?:
|
|
1591
|
+
background?: ColorLike | undefined;
|
|
1557
1592
|
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
|
|
1558
1593
|
kernel?: keyof KernelEnum | undefined;
|
|
1559
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) */
|
|
@@ -1565,13 +1600,13 @@ declare namespace sharp {
|
|
|
1565
1600
|
}
|
|
1566
1601
|
|
|
1567
1602
|
interface Region {
|
|
1568
|
-
/** zero-indexed offset from left edge */
|
|
1603
|
+
/** zero-indexed offset from left edge, an integer between 0 and 100000000 */
|
|
1569
1604
|
left: number;
|
|
1570
|
-
/** zero-indexed offset from top edge */
|
|
1605
|
+
/** zero-indexed offset from top edge, an integer between 0 and 100000000 */
|
|
1571
1606
|
top: number;
|
|
1572
|
-
/** dimension of extracted image */
|
|
1607
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1573
1608
|
width: number;
|
|
1574
|
-
/** dimension of extracted image */
|
|
1609
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1575
1610
|
height: number;
|
|
1576
1611
|
}
|
|
1577
1612
|
|
|
@@ -1587,27 +1622,29 @@ declare namespace sharp {
|
|
|
1587
1622
|
type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
|
|
1588
1623
|
|
|
1589
1624
|
interface ExtendOptions {
|
|
1590
|
-
/** 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) */
|
|
1591
1626
|
top?: number | undefined;
|
|
1592
|
-
/** 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) */
|
|
1593
1628
|
left?: number | undefined;
|
|
1594
|
-
/** 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) */
|
|
1595
1630
|
bottom?: number | undefined;
|
|
1596
|
-
/** 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) */
|
|
1597
1632
|
right?: number | undefined;
|
|
1598
1633
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1599
|
-
background?:
|
|
1634
|
+
background?: ColorLike | undefined;
|
|
1600
1635
|
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
|
|
1601
1636
|
extendWith?: ExtendWith | undefined;
|
|
1602
1637
|
}
|
|
1603
1638
|
|
|
1604
1639
|
interface TrimOptions {
|
|
1605
1640
|
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
|
|
1606
|
-
background?:
|
|
1641
|
+
background?: ColorLike | undefined;
|
|
1607
1642
|
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
|
|
1608
1643
|
threshold?: number | undefined;
|
|
1609
1644
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1610
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;
|
|
1611
1648
|
}
|
|
1612
1649
|
|
|
1613
1650
|
interface RawOptions {
|
|
@@ -1617,15 +1654,8 @@ declare namespace sharp {
|
|
|
1617
1654
|
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
|
1618
1655
|
type Channels = 1 | 2 | 3 | 4;
|
|
1619
1656
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
g?: number | undefined;
|
|
1623
|
-
b?: number | undefined;
|
|
1624
|
-
alpha?: number | undefined;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
type Colour = string | RGBA;
|
|
1628
|
-
type Color = Colour;
|
|
1657
|
+
type Colour = ColorLike;
|
|
1658
|
+
type Color = ColorLike;
|
|
1629
1659
|
|
|
1630
1660
|
interface Kernel {
|
|
1631
1661
|
/** width of the kernel in pixels. */
|
|
@@ -1641,11 +1671,11 @@ declare namespace sharp {
|
|
|
1641
1671
|
}
|
|
1642
1672
|
|
|
1643
1673
|
interface ClaheOptions {
|
|
1644
|
-
/** width of the region */
|
|
1674
|
+
/** width of the region. Valid values are integers in the range 1-65536. */
|
|
1645
1675
|
width: number;
|
|
1646
|
-
/** height of the region */
|
|
1676
|
+
/** height of the region. Valid values are integers in the range 1-65536. */
|
|
1647
1677
|
height: number;
|
|
1648
|
-
/** 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) */
|
|
1649
1679
|
maxSlope?: number | undefined;
|
|
1650
1680
|
}
|
|
1651
1681
|
|
|
@@ -1663,9 +1693,9 @@ declare namespace sharp {
|
|
|
1663
1693
|
blend?: Blend | undefined;
|
|
1664
1694
|
/** gravity at which to place the overlay. (optional, default 'centre') */
|
|
1665
1695
|
gravity?: Gravity | undefined;
|
|
1666
|
-
/** the pixel offset from the top edge. */
|
|
1696
|
+
/** the pixel offset from the top edge, an integer between -100000000 and 100000000. */
|
|
1667
1697
|
top?: number | undefined;
|
|
1668
|
-
/** the pixel offset from the left edge. */
|
|
1698
|
+
/** the pixel offset from the left edge, an integer between -100000000 and 100000000. */
|
|
1669
1699
|
left?: number | undefined;
|
|
1670
1700
|
/** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
|
|
1671
1701
|
tile?: boolean | undefined;
|
|
@@ -1691,7 +1721,7 @@ declare namespace sharp {
|
|
|
1691
1721
|
/** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
|
|
1692
1722
|
angle?: number | undefined;
|
|
1693
1723
|
/** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
|
|
1694
|
-
background?:
|
|
1724
|
+
background?: ColorLike | undefined;
|
|
1695
1725
|
/** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
|
|
1696
1726
|
depth?: string | undefined;
|
|
1697
1727
|
/** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
|
|
@@ -1755,6 +1785,8 @@ declare namespace sharp {
|
|
|
1755
1785
|
channels: Channels;
|
|
1756
1786
|
/** indicating if premultiplication was used */
|
|
1757
1787
|
premultiplied: boolean;
|
|
1788
|
+
/** Indicates if the output image has an alpha channel */
|
|
1789
|
+
hasAlpha: boolean;
|
|
1758
1790
|
/** Only defined when using a crop strategy */
|
|
1759
1791
|
cropOffsetLeft?: number | undefined;
|
|
1760
1792
|
/** Only defined when using a crop strategy */
|
|
@@ -1913,16 +1945,13 @@ declare namespace sharp {
|
|
|
1913
1945
|
}
|
|
1914
1946
|
|
|
1915
1947
|
interface FormatEnum {
|
|
1916
|
-
avif: AvailableFormatInfo;
|
|
1917
1948
|
dcraw: AvailableFormatInfo;
|
|
1918
1949
|
dz: AvailableFormatInfo;
|
|
1919
1950
|
exr: AvailableFormatInfo;
|
|
1920
1951
|
fits: AvailableFormatInfo;
|
|
1921
1952
|
gif: AvailableFormatInfo;
|
|
1922
1953
|
heif: AvailableFormatInfo;
|
|
1923
|
-
input: AvailableFormatInfo;
|
|
1924
1954
|
jpeg: AvailableFormatInfo;
|
|
1925
|
-
jpg: AvailableFormatInfo;
|
|
1926
1955
|
jp2: AvailableFormatInfo;
|
|
1927
1956
|
jxl: AvailableFormatInfo;
|
|
1928
1957
|
magick: AvailableFormatInfo;
|
|
@@ -1934,8 +1963,7 @@ declare namespace sharp {
|
|
|
1934
1963
|
raw: AvailableFormatInfo;
|
|
1935
1964
|
svg: AvailableFormatInfo;
|
|
1936
1965
|
tiff: AvailableFormatInfo;
|
|
1937
|
-
|
|
1938
|
-
v: AvailableFormatInfo;
|
|
1966
|
+
vips: AvailableFormatInfo;
|
|
1939
1967
|
webp: AvailableFormatInfo;
|
|
1940
1968
|
}
|
|
1941
1969
|
|