@revizly/sharp 0.35.0-revizly4 → 0.35.0-revizly41
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/{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} +2 -1
- package/dist/composite.mjs +213 -0
- package/{lib/constructor.js → dist/constructor.cjs} +42 -29
- package/dist/constructor.mjs +512 -0
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +2001 -0
- package/dist/index.d.mts +2048 -0
- package/dist/index.mjs +25 -0
- package/{lib/input.js → dist/input.cjs} +26 -21
- package/dist/input.mjs +814 -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} +33 -51
- package/dist/operation.mjs +998 -0
- package/{lib/output.js → dist/output.cjs} +161 -28
- package/dist/output.mjs +1799 -0
- package/{lib/resize.js → dist/resize.cjs} +46 -24
- package/dist/resize.mjs +617 -0
- package/dist/sharp.cjs +125 -0
- package/dist/sharp.mjs +125 -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 +105 -75
- package/package.json +46 -27
- package/src/binding.gyp +18 -13
- package/src/common.cc +70 -17
- package/src/common.h +22 -3
- 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 +206 -69
- package/src/pipeline.h +16 -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)
|
|
@@ -693,6 +678,21 @@ declare namespace sharp {
|
|
|
693
678
|
*/
|
|
694
679
|
toBuffer(options: { resolveWithObject: true }): Promise<{ data: Buffer; info: OutputInfo }>;
|
|
695
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
|
+
|
|
696
696
|
/**
|
|
697
697
|
* Keep all EXIF metadata from the input image in the output image.
|
|
698
698
|
* EXIF metadata is unsupported for TIFF output.
|
|
@@ -849,7 +849,7 @@ declare namespace sharp {
|
|
|
849
849
|
* @returns A sharp instance that can be used to chain operations
|
|
850
850
|
*/
|
|
851
851
|
toFormat(
|
|
852
|
-
format: keyof FormatEnum | AvailableFormatInfo,
|
|
852
|
+
format: keyof FormatEnum | AvailableFormatInfo | "avif",
|
|
853
853
|
options?:
|
|
854
854
|
| OutputOptions
|
|
855
855
|
| JpegOptions
|
|
@@ -903,7 +903,7 @@ declare namespace sharp {
|
|
|
903
903
|
* - sharp.gravity: north, northeast, east, southeast, south, southwest, west, northwest, center or centre.
|
|
904
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.
|
|
905
905
|
*
|
|
906
|
-
* The
|
|
906
|
+
* The strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
|
|
907
907
|
* discarding the edge with the lowest score based on the selected strategy.
|
|
908
908
|
* - entropy: focus on the region with the highest Shannon entropy.
|
|
909
909
|
* - attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
|
|
@@ -989,28 +989,27 @@ declare namespace sharp {
|
|
|
989
989
|
autoOrient?: boolean | undefined;
|
|
990
990
|
/**
|
|
991
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.
|
|
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')
|
|
993
994
|
*/
|
|
994
995
|
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
996
|
/**
|
|
1004
997
|
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
|
1005
998
|
* Assumes image dimensions contained in the input metadata can be trusted.
|
|
1006
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)
|
|
1007
1000
|
*/
|
|
1008
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;
|
|
1009
1008
|
/** Set this to true to remove safety features that help prevent memory exhaustion (SVG, PNG). (optional, default false) */
|
|
1010
1009
|
unlimited?: boolean | undefined;
|
|
1011
1010
|
/** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
|
|
1012
1011
|
sequentialRead?: boolean | undefined;
|
|
1013
|
-
/**
|
|
1012
|
+
/** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */
|
|
1014
1013
|
density?: number | undefined;
|
|
1015
1014
|
/** Should the embedded ICC profile, if any, be ignored. */
|
|
1016
1015
|
ignoreIcc?: boolean | undefined;
|
|
@@ -1031,7 +1030,7 @@ declare namespace sharp {
|
|
|
1031
1030
|
/** @deprecated Use {@link SharpOptions.tiff} instead */
|
|
1032
1031
|
subifd?: number | undefined;
|
|
1033
1032
|
/** @deprecated Use {@link SharpOptions.pdf} instead */
|
|
1034
|
-
pdfBackground?:
|
|
1033
|
+
pdfBackground?: ColorLike | undefined;
|
|
1035
1034
|
/** @deprecated Use {@link SharpOptions.openSlide} instead */
|
|
1036
1035
|
level?: number | undefined;
|
|
1037
1036
|
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
|
|
@@ -1090,7 +1089,7 @@ declare namespace sharp {
|
|
|
1090
1089
|
/** Number of bands, 3 for RGB, 4 for RGBA */
|
|
1091
1090
|
channels: CreateChannels;
|
|
1092
1091
|
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
|
|
1093
|
-
background:
|
|
1092
|
+
background: ColorLike;
|
|
1094
1093
|
/** Describes a noise to be created. */
|
|
1095
1094
|
noise?: Noise | undefined;
|
|
1096
1095
|
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
@@ -1137,7 +1136,7 @@ declare namespace sharp {
|
|
|
1137
1136
|
/** Space between images, in pixels. */
|
|
1138
1137
|
shim?: number | undefined;
|
|
1139
1138
|
/** Background colour. */
|
|
1140
|
-
background?:
|
|
1139
|
+
background?: ColorLike | undefined;
|
|
1141
1140
|
/** Horizontal alignment. */
|
|
1142
1141
|
halign?: HorizontalAlignment | undefined;
|
|
1143
1142
|
/** Vertical alignment. */
|
|
@@ -1158,7 +1157,7 @@ declare namespace sharp {
|
|
|
1158
1157
|
|
|
1159
1158
|
interface PdfInputOptions {
|
|
1160
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. */
|
|
1161
|
-
background?:
|
|
1160
|
+
background?: ColorLike | undefined;
|
|
1162
1161
|
}
|
|
1163
1162
|
|
|
1164
1163
|
interface OpenSlideInputOptions {
|
|
@@ -1184,8 +1183,27 @@ declare namespace sharp {
|
|
|
1184
1183
|
|
|
1185
1184
|
type HeifCompression = 'av1' | 'hevc';
|
|
1186
1185
|
|
|
1186
|
+
type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';
|
|
1187
|
+
|
|
1187
1188
|
type Unit = 'inch' | 'cm';
|
|
1188
1189
|
|
|
1190
|
+
type MediaType =
|
|
1191
|
+
'application/pdf' |
|
|
1192
|
+
'image/avif' |
|
|
1193
|
+
'image/fits' |
|
|
1194
|
+
'image/gif' |
|
|
1195
|
+
'image/heic' |
|
|
1196
|
+
'image/jp2' |
|
|
1197
|
+
'image/jpeg' |
|
|
1198
|
+
'image/jxl' |
|
|
1199
|
+
'image/png' |
|
|
1200
|
+
'image/svg+xml' |
|
|
1201
|
+
'image/tiff' |
|
|
1202
|
+
'image/vnd.radiance' |
|
|
1203
|
+
'image/webp' |
|
|
1204
|
+
'image/x-exr' |
|
|
1205
|
+
'image/x-portable-pixmap';
|
|
1206
|
+
|
|
1189
1207
|
interface WriteableMetadata {
|
|
1190
1208
|
/** Number of pixels per inch (DPI) */
|
|
1191
1209
|
density?: number | undefined;
|
|
@@ -1277,6 +1295,10 @@ declare namespace sharp {
|
|
|
1277
1295
|
formatMagick?: string | undefined;
|
|
1278
1296
|
/** Array of keyword/text pairs representing PNG text blocks, if present. */
|
|
1279
1297
|
comments?: CommentsMetadata[] | undefined;
|
|
1298
|
+
/** HDR gain map, if present */
|
|
1299
|
+
gainMap?: GainMapMetadata | undefined;
|
|
1300
|
+
/** Media Type (MIME Type) */
|
|
1301
|
+
mediaType?: MediaType | undefined;
|
|
1280
1302
|
}
|
|
1281
1303
|
|
|
1282
1304
|
interface LevelMetadata {
|
|
@@ -1289,16 +1311,21 @@ declare namespace sharp {
|
|
|
1289
1311
|
text: string;
|
|
1290
1312
|
}
|
|
1291
1313
|
|
|
1314
|
+
interface GainMapMetadata {
|
|
1315
|
+
/** JPEG image */
|
|
1316
|
+
image: Buffer;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1292
1319
|
interface Stats {
|
|
1293
1320
|
/** Array of channel statistics for each channel in the image. */
|
|
1294
1321
|
channels: ChannelStats[];
|
|
1295
1322
|
/** Value to identify if the image is opaque or transparent, based on the presence and use of alpha channel */
|
|
1296
1323
|
isOpaque: boolean;
|
|
1297
|
-
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any
|
|
1324
|
+
/** Histogram-based estimation of greyscale entropy, discarding alpha channel if any */
|
|
1298
1325
|
entropy: number;
|
|
1299
|
-
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any
|
|
1326
|
+
/** Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any */
|
|
1300
1327
|
sharpness: number;
|
|
1301
|
-
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram
|
|
1328
|
+
/** Object containing most dominant sRGB colour based on a 4096-bin 3D histogram */
|
|
1302
1329
|
dominant: { r: number; g: number; b: number };
|
|
1303
1330
|
}
|
|
1304
1331
|
|
|
@@ -1404,11 +1431,13 @@ declare namespace sharp {
|
|
|
1404
1431
|
/** Level of CPU effort to reduce file size, integer 0-6 (optional, default 4) */
|
|
1405
1432
|
effort?: number | undefined;
|
|
1406
1433
|
/** Prevent use of animation key frames to minimise file size (slow) (optional, default false) */
|
|
1407
|
-
minSize?: boolean;
|
|
1434
|
+
minSize?: boolean | undefined;
|
|
1408
1435
|
/** Allow mixture of lossy and lossless animation frames (slow) (optional, default false) */
|
|
1409
|
-
mixed?: boolean;
|
|
1436
|
+
mixed?: boolean | undefined;
|
|
1410
1437
|
/** Preset options: one of default, photo, picture, drawing, icon, text (optional, default 'default') */
|
|
1411
1438
|
preset?: keyof PresetEnum | undefined;
|
|
1439
|
+
/** Preserve the colour data in transparent pixels (optional, default false) */
|
|
1440
|
+
exact?: boolean | undefined;
|
|
1412
1441
|
}
|
|
1413
1442
|
|
|
1414
1443
|
interface AvifOptions extends OutputOptions {
|
|
@@ -1422,6 +1451,10 @@ declare namespace sharp {
|
|
|
1422
1451
|
chromaSubsampling?: string | undefined;
|
|
1423
1452
|
/** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
|
|
1424
1453
|
bitdepth?: 8 | 10 | 12 | undefined;
|
|
1454
|
+
/** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
|
|
1455
|
+
tune?: HeifTune | undefined;
|
|
1456
|
+
/** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
|
|
1457
|
+
encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
|
|
1425
1458
|
}
|
|
1426
1459
|
|
|
1427
1460
|
interface HeifOptions extends OutputOptions {
|
|
@@ -1437,6 +1470,10 @@ 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;
|
|
1475
|
+
/** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
|
|
1476
|
+
encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
|
|
1440
1477
|
}
|
|
1441
1478
|
|
|
1442
1479
|
interface GifOptions extends OutputOptions, AnimationOptions {
|
|
@@ -1475,14 +1512,14 @@ declare namespace sharp {
|
|
|
1475
1512
|
tile?: boolean | undefined;
|
|
1476
1513
|
/** Horizontal tile size (optional, default 256) */
|
|
1477
1514
|
tileWidth?: number | undefined;
|
|
1478
|
-
/** Vertical tile size (optional, default 256) */
|
|
1515
|
+
/** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
|
|
1479
1516
|
tileHeight?: number | undefined;
|
|
1480
|
-
/** Horizontal resolution in pixels/mm (optional, default 1.0) */
|
|
1517
|
+
/** Horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1481
1518
|
xres?: number | undefined;
|
|
1482
|
-
/** Vertical resolution in pixels/mm (optional, default 1.0) */
|
|
1519
|
+
/** Vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
|
|
1483
1520
|
yres?: number | undefined;
|
|
1484
|
-
/** Reduce bitdepth to 1, 2 or 4 bit (optional
|
|
1485
|
-
bitdepth?: 1 | 2 | 4 |
|
|
1521
|
+
/** Reduce bitdepth to 1, 2 or 4 bit (optional) */
|
|
1522
|
+
bitdepth?: 1 | 2 | 4 | undefined;
|
|
1486
1523
|
/** Write 1-bit images as miniswhite (optional, default false) */
|
|
1487
1524
|
miniswhite?: boolean | undefined;
|
|
1488
1525
|
/** Resolution unit options: inch, cm (optional, default 'inch') */
|
|
@@ -1512,7 +1549,7 @@ declare namespace sharp {
|
|
|
1512
1549
|
|
|
1513
1550
|
interface RotateOptions {
|
|
1514
1551
|
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
|
|
1515
|
-
background?:
|
|
1552
|
+
background?: ColorLike | undefined;
|
|
1516
1553
|
}
|
|
1517
1554
|
|
|
1518
1555
|
type Precision = 'integer' | 'float' | 'approximate';
|
|
@@ -1528,7 +1565,7 @@ declare namespace sharp {
|
|
|
1528
1565
|
|
|
1529
1566
|
interface FlattenOptions {
|
|
1530
1567
|
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
|
|
1531
|
-
background?:
|
|
1568
|
+
background?: ColorLike | undefined;
|
|
1532
1569
|
}
|
|
1533
1570
|
|
|
1534
1571
|
interface NegateOptions {
|
|
@@ -1553,7 +1590,7 @@ declare namespace sharp {
|
|
|
1553
1590
|
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
|
|
1554
1591
|
position?: number | string | undefined;
|
|
1555
1592
|
/** 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?:
|
|
1593
|
+
background?: ColorLike | undefined;
|
|
1557
1594
|
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
|
|
1558
1595
|
kernel?: keyof KernelEnum | undefined;
|
|
1559
1596
|
/** 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 +1602,13 @@ declare namespace sharp {
|
|
|
1565
1602
|
}
|
|
1566
1603
|
|
|
1567
1604
|
interface Region {
|
|
1568
|
-
/** zero-indexed offset from left edge */
|
|
1605
|
+
/** zero-indexed offset from left edge, an integer between 0 and 100000000 */
|
|
1569
1606
|
left: number;
|
|
1570
|
-
/** zero-indexed offset from top edge */
|
|
1607
|
+
/** zero-indexed offset from top edge, an integer between 0 and 100000000 */
|
|
1571
1608
|
top: number;
|
|
1572
|
-
/** dimension of extracted image */
|
|
1609
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1573
1610
|
width: number;
|
|
1574
|
-
/** dimension of extracted image */
|
|
1611
|
+
/** dimension of extracted image, an integer between 0 and 100000000 */
|
|
1575
1612
|
height: number;
|
|
1576
1613
|
}
|
|
1577
1614
|
|
|
@@ -1587,27 +1624,29 @@ declare namespace sharp {
|
|
|
1587
1624
|
type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
|
|
1588
1625
|
|
|
1589
1626
|
interface ExtendOptions {
|
|
1590
|
-
/** single pixel count to top edge (optional, default 0) */
|
|
1627
|
+
/** single pixel count to top edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1591
1628
|
top?: number | undefined;
|
|
1592
|
-
/** single pixel count to left edge (optional, default 0) */
|
|
1629
|
+
/** single pixel count to left edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1593
1630
|
left?: number | undefined;
|
|
1594
|
-
/** single pixel count to bottom edge (optional, default 0) */
|
|
1631
|
+
/** single pixel count to bottom edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1595
1632
|
bottom?: number | undefined;
|
|
1596
|
-
/** single pixel count to right edge (optional, default 0) */
|
|
1633
|
+
/** single pixel count to right edge, valid values are integers in the range 0-10000 (optional, default 0) */
|
|
1597
1634
|
right?: number | undefined;
|
|
1598
1635
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1599
|
-
background?:
|
|
1636
|
+
background?: ColorLike | undefined;
|
|
1600
1637
|
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
|
|
1601
1638
|
extendWith?: ExtendWith | undefined;
|
|
1602
1639
|
}
|
|
1603
1640
|
|
|
1604
1641
|
interface TrimOptions {
|
|
1605
1642
|
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
|
|
1606
|
-
background?:
|
|
1643
|
+
background?: ColorLike | undefined;
|
|
1607
1644
|
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
|
|
1608
1645
|
threshold?: number | undefined;
|
|
1609
1646
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
1610
1647
|
lineArt?: boolean | undefined;
|
|
1648
|
+
/** Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. (optional, default 0) */
|
|
1649
|
+
margin?: number | undefined;
|
|
1611
1650
|
}
|
|
1612
1651
|
|
|
1613
1652
|
interface RawOptions {
|
|
@@ -1617,15 +1656,8 @@ declare namespace sharp {
|
|
|
1617
1656
|
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
|
1618
1657
|
type Channels = 1 | 2 | 3 | 4;
|
|
1619
1658
|
|
|
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;
|
|
1659
|
+
type Colour = ColorLike;
|
|
1660
|
+
type Color = ColorLike;
|
|
1629
1661
|
|
|
1630
1662
|
interface Kernel {
|
|
1631
1663
|
/** width of the kernel in pixels. */
|
|
@@ -1641,11 +1673,11 @@ declare namespace sharp {
|
|
|
1641
1673
|
}
|
|
1642
1674
|
|
|
1643
1675
|
interface ClaheOptions {
|
|
1644
|
-
/** width of the region */
|
|
1676
|
+
/** width of the region. Valid values are integers in the range 1-65536. */
|
|
1645
1677
|
width: number;
|
|
1646
|
-
/** height of the region */
|
|
1678
|
+
/** height of the region. Valid values are integers in the range 1-65536. */
|
|
1647
1679
|
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 (
|
|
1680
|
+
/** 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
1681
|
maxSlope?: number | undefined;
|
|
1650
1682
|
}
|
|
1651
1683
|
|
|
@@ -1691,7 +1723,7 @@ declare namespace sharp {
|
|
|
1691
1723
|
/** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
|
|
1692
1724
|
angle?: number | undefined;
|
|
1693
1725
|
/** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
|
|
1694
|
-
background?:
|
|
1726
|
+
background?: ColorLike | undefined;
|
|
1695
1727
|
/** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
|
|
1696
1728
|
depth?: string | undefined;
|
|
1697
1729
|
/** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
|
|
@@ -1755,6 +1787,8 @@ declare namespace sharp {
|
|
|
1755
1787
|
channels: Channels;
|
|
1756
1788
|
/** indicating if premultiplication was used */
|
|
1757
1789
|
premultiplied: boolean;
|
|
1790
|
+
/** Indicates if the output image has an alpha channel */
|
|
1791
|
+
hasAlpha: boolean;
|
|
1758
1792
|
/** Only defined when using a crop strategy */
|
|
1759
1793
|
cropOffsetLeft?: number | undefined;
|
|
1760
1794
|
/** Only defined when using a crop strategy */
|
|
@@ -1913,16 +1947,13 @@ declare namespace sharp {
|
|
|
1913
1947
|
}
|
|
1914
1948
|
|
|
1915
1949
|
interface FormatEnum {
|
|
1916
|
-
avif: AvailableFormatInfo;
|
|
1917
1950
|
dcraw: AvailableFormatInfo;
|
|
1918
1951
|
dz: AvailableFormatInfo;
|
|
1919
1952
|
exr: AvailableFormatInfo;
|
|
1920
1953
|
fits: AvailableFormatInfo;
|
|
1921
1954
|
gif: AvailableFormatInfo;
|
|
1922
1955
|
heif: AvailableFormatInfo;
|
|
1923
|
-
input: AvailableFormatInfo;
|
|
1924
1956
|
jpeg: AvailableFormatInfo;
|
|
1925
|
-
jpg: AvailableFormatInfo;
|
|
1926
1957
|
jp2: AvailableFormatInfo;
|
|
1927
1958
|
jxl: AvailableFormatInfo;
|
|
1928
1959
|
magick: AvailableFormatInfo;
|
|
@@ -1934,8 +1965,7 @@ declare namespace sharp {
|
|
|
1934
1965
|
raw: AvailableFormatInfo;
|
|
1935
1966
|
svg: AvailableFormatInfo;
|
|
1936
1967
|
tiff: AvailableFormatInfo;
|
|
1937
|
-
|
|
1938
|
-
v: AvailableFormatInfo;
|
|
1968
|
+
vips: AvailableFormatInfo;
|
|
1939
1969
|
webp: AvailableFormatInfo;
|
|
1940
1970
|
}
|
|
1941
1971
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revizly/sharp",
|
|
3
3
|
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
|
4
|
-
"version": "0.35.0-
|
|
4
|
+
"version": "0.35.0-revizly41",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -89,33 +89,52 @@
|
|
|
89
89
|
"Lachlan Newman <lachnewman007@gmail.com>",
|
|
90
90
|
"Dennis Beatty <dennis@dcbeatty.com>",
|
|
91
91
|
"Ingvar Stepanyan <me@rreverser.com>",
|
|
92
|
-
"Don Denton <don@happycollision.com>"
|
|
92
|
+
"Don Denton <don@happycollision.com>",
|
|
93
|
+
"Dmytro Tiapukhin <cool.gegeg@gmail.com>",
|
|
94
|
+
"Florian Lefebvre <contact@florian-lefebvre.dev>"
|
|
93
95
|
],
|
|
94
96
|
"scripts": {
|
|
95
97
|
"build": "node install/build.js",
|
|
96
|
-
"
|
|
97
|
-
"clean": "rm -rf src/build/
|
|
98
|
+
"build:dist": "node scripts/build.mjs",
|
|
99
|
+
"clean": "rm -rf src/build/ test/fixtures/output.*",
|
|
98
100
|
"test": "npm run lint && npm run test-unit",
|
|
99
|
-
"lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
|
|
101
|
+
"lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-publish",
|
|
100
102
|
"lint-cpp": "cpplint --quiet src/*.h src/*.cc",
|
|
101
103
|
"lint-js": "biome lint",
|
|
102
|
-
"lint-
|
|
104
|
+
"lint-publish": "publint --strict",
|
|
105
|
+
"lint-types": "tsd --files ./test/types/sharp.test-d.{cts,mts}",
|
|
103
106
|
"test-leak": "./test/leak/leak.sh",
|
|
104
107
|
"test-unit": "node --experimental-test-coverage test/unit.mjs",
|
|
105
108
|
"package-from-local-build": "node npm/from-local-build.js",
|
|
109
|
+
"package-wasm-wrappers": "node npm/wasm-wrappers.js",
|
|
106
110
|
"package-release-notes": "node npm/release-notes.js",
|
|
107
111
|
"docs-build": "node docs/build.mjs",
|
|
108
112
|
"docs-serve": "cd docs && npm start",
|
|
109
113
|
"docs-publish": "cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
|
110
114
|
},
|
|
111
115
|
"type": "commonjs",
|
|
112
|
-
"main": "lib/index.js",
|
|
113
|
-
"types": "lib/index.d.ts",
|
|
114
116
|
"files": [
|
|
117
|
+
"dist",
|
|
115
118
|
"install",
|
|
116
|
-
"lib",
|
|
119
|
+
"lib/index.d.ts",
|
|
117
120
|
"src/*.{cc,h,gyp}"
|
|
118
121
|
],
|
|
122
|
+
"main": "./dist/index.cjs",
|
|
123
|
+
"module": "./dist/index.mjs",
|
|
124
|
+
"types": "./dist/index.d.mts",
|
|
125
|
+
"exports": {
|
|
126
|
+
".": {
|
|
127
|
+
"import": {
|
|
128
|
+
"types": "./dist/index.d.mts",
|
|
129
|
+
"default": "./dist/index.mjs"
|
|
130
|
+
},
|
|
131
|
+
"require": {
|
|
132
|
+
"types": "./dist/index.d.cts",
|
|
133
|
+
"default": "./dist/index.cjs"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"sideEffects": true,
|
|
119
138
|
"repository": {
|
|
120
139
|
"type": "git",
|
|
121
140
|
"url": "git://github.com/janaz/sharp.git"
|
|
@@ -139,38 +158,38 @@
|
|
|
139
158
|
"vips"
|
|
140
159
|
],
|
|
141
160
|
"dependencies": {
|
|
142
|
-
"@img/colour": "^1.
|
|
161
|
+
"@img/colour": "^1.1.0",
|
|
143
162
|
"detect-libc": "^2.1.2",
|
|
144
|
-
"semver": "^7.
|
|
163
|
+
"semver": "^7.8.5"
|
|
145
164
|
},
|
|
146
165
|
"optionalDependencies": {
|
|
147
|
-
"@revizly/sharp-libvips-linux-arm64": "1.0.
|
|
148
|
-
"@revizly/sharp-libvips-linux-x64": "1.0.
|
|
149
|
-
"@revizly/sharp-linux-arm64": "0.
|
|
150
|
-
"@revizly/sharp-linux-x64": "0.
|
|
166
|
+
"@revizly/sharp-libvips-linux-arm64": "1.0.42",
|
|
167
|
+
"@revizly/sharp-libvips-linux-x64": "1.0.42",
|
|
168
|
+
"@revizly/sharp-linux-arm64": "0.35.0-revizly41",
|
|
169
|
+
"@revizly/sharp-linux-x64": "0.35.0-revizly41"
|
|
151
170
|
},
|
|
152
171
|
"devDependencies": {
|
|
153
|
-
"@biomejs/biome": "^2.
|
|
172
|
+
"@biomejs/biome": "^2.5.1",
|
|
154
173
|
"@cpplint/cli": "^0.1.0",
|
|
155
|
-
"@emnapi/runtime": "^1.
|
|
156
|
-
"@revizly/sharp-libvips-dev": "1.0.
|
|
174
|
+
"@emnapi/runtime": "^1.11.1",
|
|
175
|
+
"@revizly/sharp-libvips-dev": "1.0.42",
|
|
157
176
|
"@types/node": "*",
|
|
158
|
-
"emnapi": "^1.
|
|
159
|
-
"exif-reader": "^2.0.
|
|
177
|
+
"emnapi": "^1.11.1",
|
|
178
|
+
"exif-reader": "^2.0.3",
|
|
160
179
|
"extract-zip": "^2.0.1",
|
|
161
|
-
"icc": "^
|
|
162
|
-
"
|
|
163
|
-
"node-
|
|
164
|
-
"
|
|
165
|
-
"tar-fs": "^3.1.
|
|
180
|
+
"icc": "^4.0.0",
|
|
181
|
+
"node-addon-api": "^8.8.0",
|
|
182
|
+
"node-gyp": "^12.4.0",
|
|
183
|
+
"publint": "^0.3.21",
|
|
184
|
+
"tar-fs": "^3.1.2",
|
|
166
185
|
"tsd": "^0.33.0"
|
|
167
186
|
},
|
|
168
187
|
"license": "Apache-2.0",
|
|
169
188
|
"engines": {
|
|
170
|
-
"node": "
|
|
189
|
+
"node": ">=20.9.0"
|
|
171
190
|
},
|
|
172
191
|
"config": {
|
|
173
|
-
"libvips": ">=8.
|
|
192
|
+
"libvips": ">=8.18.3"
|
|
174
193
|
},
|
|
175
194
|
"funding": {
|
|
176
195
|
"url": "https://opencollective.com/libvips"
|
package/src/binding.gyp
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
{
|
|
5
5
|
'variables': {
|
|
6
|
-
'vips_version': '<!(node -p "require(\'../
|
|
7
|
-
'platform_and_arch': '<!(node -p "require(\'../
|
|
6
|
+
'vips_version': '<!(node -p "require(\'../dist/libvips.cjs\').minimumLibvipsVersion")',
|
|
7
|
+
'platform_and_arch': '<!(node -p "require(\'../dist/libvips.cjs\').buildPlatformArch()")',
|
|
8
|
+
'sharp_version': '<!(node -p "require(\'../package.json\').version")',
|
|
8
9
|
'sharp_libvips_version': '<!(node -p "require(\'../package.json\').optionalDependencies[\'@revizly/sharp-libvips-<(platform_and_arch)\']")',
|
|
9
|
-
'sharp_libvips_yarn_locator': '<!(node -p "require(\'../
|
|
10
|
-
'sharp_libvips_include_dir': '<!(node -p "require(\'../
|
|
11
|
-
'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../
|
|
12
|
-
'sharp_libvips_lib_dir': '<!(node -p "require(\'../
|
|
10
|
+
'sharp_libvips_yarn_locator': '<!(node -p "require(\'../dist/libvips.cjs\').yarnLocator()")',
|
|
11
|
+
'sharp_libvips_include_dir': '<!(node -p "require(\'../dist/libvips.cjs\').buildSharpLibvipsIncludeDir()")',
|
|
12
|
+
'sharp_libvips_cplusplus_dir': '<!(node -p "require(\'../dist/libvips.cjs\').buildSharpLibvipsCPlusPlusDir()")',
|
|
13
|
+
'sharp_libvips_lib_dir': '<!(node -p "require(\'../dist/libvips.cjs\').buildSharpLibvipsLibDir()")'
|
|
13
14
|
},
|
|
14
15
|
'targets': [{
|
|
15
16
|
'target_name': 'libvips-cpp-<(vips_version)',
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
'defines': [
|
|
21
22
|
'_VIPS_PUBLIC=__declspec(dllexport)',
|
|
22
23
|
'_ALLOW_KEYWORD_MACROS',
|
|
24
|
+
'_HAS_EXCEPTIONS=1',
|
|
23
25
|
'G_DISABLE_ASSERT',
|
|
24
26
|
'G_DISABLE_CAST_CHECKS',
|
|
25
27
|
'G_DISABLE_CHECKS'
|
|
@@ -81,7 +83,7 @@
|
|
|
81
83
|
}]
|
|
82
84
|
]
|
|
83
85
|
}, {
|
|
84
|
-
'target_name': 'sharp-<(platform_and_arch)',
|
|
86
|
+
'target_name': 'sharp-<(platform_and_arch)-<(sharp_version)',
|
|
85
87
|
'defines': [
|
|
86
88
|
'G_DISABLE_ASSERT',
|
|
87
89
|
'G_DISABLE_CAST_CHECKS',
|
|
@@ -97,8 +99,8 @@
|
|
|
97
99
|
'variables': {
|
|
98
100
|
'conditions': [
|
|
99
101
|
['OS != "win"', {
|
|
100
|
-
'pkg_config_path': '<!(node -p "require(\'../
|
|
101
|
-
'use_global_libvips': '<!(node -p "Boolean(require(\'../
|
|
102
|
+
'pkg_config_path': '<!(node -p "require(\'../dist/libvips.cjs\').pkgConfigPath()")',
|
|
103
|
+
'use_global_libvips': '<!(node -p "Boolean(require(\'../dist/libvips.cjs\').useGlobalLibvips()).toString()")'
|
|
102
104
|
}, {
|
|
103
105
|
'pkg_config_path': '',
|
|
104
106
|
'use_global_libvips': ''
|
|
@@ -147,7 +149,8 @@
|
|
|
147
149
|
['OS == "win"', {
|
|
148
150
|
'defines': [
|
|
149
151
|
'_ALLOW_KEYWORD_MACROS',
|
|
150
|
-
'_FILE_OFFSET_BITS=64'
|
|
152
|
+
'_FILE_OFFSET_BITS=64',
|
|
153
|
+
'_HAS_EXCEPTIONS=1'
|
|
151
154
|
],
|
|
152
155
|
'link_settings': {
|
|
153
156
|
'libraries': [
|
|
@@ -202,14 +205,16 @@
|
|
|
202
205
|
}],
|
|
203
206
|
['OS == "emscripten"', {
|
|
204
207
|
'product_extension': 'node.js',
|
|
208
|
+
'cflags_cc': [
|
|
209
|
+
'-fwasm-exceptions'
|
|
210
|
+
],
|
|
205
211
|
'link_settings': {
|
|
206
212
|
'ldflags': [
|
|
207
|
-
'-
|
|
213
|
+
'-fwasm-exceptions',
|
|
208
214
|
'--pre-js=<!(node -p "require.resolve(\'./emscripten/pre.js\')")',
|
|
209
215
|
'-Oz',
|
|
210
216
|
'-sALLOW_MEMORY_GROWTH',
|
|
211
217
|
'-sENVIRONMENT=node',
|
|
212
|
-
'-sEXPORTED_FUNCTIONS=emnapiInit,_vips_shutdown,_uv_library_shutdown',
|
|
213
218
|
'-sNODERAWFS',
|
|
214
219
|
'-sWASM_ASYNC_COMPILATION=0'
|
|
215
220
|
],
|
|
@@ -282,7 +287,7 @@
|
|
|
282
287
|
'target_name': 'copy-dll',
|
|
283
288
|
'type': 'none',
|
|
284
289
|
'dependencies': [
|
|
285
|
-
'sharp-<(platform_and_arch)'
|
|
290
|
+
'sharp-<(platform_and_arch)-<(sharp_version)'
|
|
286
291
|
],
|
|
287
292
|
'conditions': [
|
|
288
293
|
['OS == "win"', {
|