@revizly/sharp 0.35.0-revizly5 → 0.35.0-revizly51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +12 -18
  2. package/{lib/channel.js → dist/channel.cjs} +1 -1
  3. package/dist/channel.mjs +177 -0
  4. package/{lib/colour.js → dist/colour.cjs} +11 -7
  5. package/dist/colour.mjs +199 -0
  6. package/{lib/composite.js → dist/composite.cjs} +8 -7
  7. package/dist/composite.mjs +213 -0
  8. package/{lib/constructor.js → dist/constructor.cjs} +43 -30
  9. package/dist/constructor.mjs +512 -0
  10. package/dist/index.cjs +25 -0
  11. package/dist/index.d.cts +2003 -0
  12. package/dist/index.d.mts +2050 -0
  13. package/dist/index.mjs +25 -0
  14. package/{lib/input.js → dist/input.cjs} +46 -36
  15. package/dist/input.mjs +819 -0
  16. package/{lib/is.js → dist/is.cjs} +9 -3
  17. package/dist/is.mjs +149 -0
  18. package/{lib/libvips.js → dist/libvips.cjs} +35 -30
  19. package/dist/libvips.mjs +212 -0
  20. package/{lib/operation.js → dist/operation.cjs} +39 -53
  21. package/dist/operation.mjs +1002 -0
  22. package/{lib/output.js → dist/output.cjs} +174 -47
  23. package/dist/output.mjs +1793 -0
  24. package/{lib/resize.js → dist/resize.cjs} +54 -32
  25. package/dist/resize.mjs +617 -0
  26. package/dist/sharp.cjs +125 -0
  27. package/dist/sharp.mjs +125 -0
  28. package/{lib/utility.js → dist/utility.cjs} +18 -8
  29. package/dist/utility.mjs +301 -0
  30. package/install/build.js +3 -3
  31. package/lib/index.d.ts +114 -82
  32. package/package.json +53 -29
  33. package/src/binding.gyp +19 -14
  34. package/src/common.cc +81 -25
  35. package/src/common.h +22 -3
  36. package/src/metadata.cc +66 -8
  37. package/src/metadata.h +6 -1
  38. package/src/operations.cc +25 -8
  39. package/src/operations.h +1 -1
  40. package/src/pipeline.cc +234 -72
  41. package/src/pipeline.h +16 -1
  42. package/src/stats.cc +6 -6
  43. package/src/utilities.cc +8 -7
  44. package/install/check.js +0 -14
  45. package/lib/index.js +0 -16
  46. 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
- import type { Duplex } from 'node:stream';
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: Colour | Color): Sharp;
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, info: OutputInfo) => void): Sharp;
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; info: OutputInfo }>;
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 experimental strategy-based approach resizes so one dimension is at its target length then repeatedly ranks edge regions,
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. (optional, default 'warning')
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
- /** Number representing the DPI for vector images in the range 1 to 100000. (optional, default 72) */
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;
@@ -1031,7 +1032,7 @@ declare namespace sharp {
1031
1032
  /** @deprecated Use {@link SharpOptions.tiff} instead */
1032
1033
  subifd?: number | undefined;
1033
1034
  /** @deprecated Use {@link SharpOptions.pdf} instead */
1034
- pdfBackground?: Colour | Color | undefined;
1035
+ pdfBackground?: ColorLike | undefined;
1035
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) */
@@ -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: Colour | Color;
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?: Colour | Color | undefined;
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?: Colour | Color | undefined;
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 (experimental) */
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 (experimental) */
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 (experimental) */
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
 
@@ -1375,7 +1404,7 @@ declare namespace sharp {
1375
1404
  chromaSubsampling?: '4:4:4' | '4:2:0';
1376
1405
  }
1377
1406
 
1378
- interface JxlOptions extends OutputOptions {
1407
+ interface JxlOptions extends OutputOptions, AnimationOptions {
1379
1408
  /** Maximum encoding error, between 0 (highest quality) and 15 (lowest quality) (optional, default 1.0) */
1380
1409
  distance?: number;
1381
1410
  /** Calculate distance based on JPEG-like quality, between 1 and 100, overrides distance if specified */
@@ -1384,7 +1413,7 @@ declare namespace sharp {
1384
1413
  decodingTier?: number;
1385
1414
  /** Use lossless compression (optional, default false) */
1386
1415
  lossless?: boolean;
1387
- /** CPU effort, between 3 (fastest) and 9 (slowest) (optional, default 7) */
1416
+ /** CPU effort, between 1 (fastest) and 9 (slowest) (optional, default 7) */
1388
1417
  effort?: number | undefined;
1389
1418
  }
1390
1419
 
@@ -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,10 @@ 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;
1458
+ /** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
1459
+ encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
1425
1460
  }
1426
1461
 
1427
1462
  interface HeifOptions extends OutputOptions {
@@ -1437,6 +1472,10 @@ declare namespace sharp {
1437
1472
  chromaSubsampling?: string | undefined;
1438
1473
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1439
1474
  bitdepth?: 8 | 10 | 12 | undefined;
1475
+ /** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
1476
+ tune?: HeifTune | undefined;
1477
+ /** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
1478
+ encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
1440
1479
  }
1441
1480
 
1442
1481
  interface GifOptions extends OutputOptions, AnimationOptions {
@@ -1475,14 +1514,14 @@ declare namespace sharp {
1475
1514
  tile?: boolean | undefined;
1476
1515
  /** Horizontal tile size (optional, default 256) */
1477
1516
  tileWidth?: number | undefined;
1478
- /** Vertical tile size (optional, default 256) */
1517
+ /** Vertical tile size, valid values are integers in the range 1-32768 (optional, default 256) */
1479
1518
  tileHeight?: number | undefined;
1480
- /** Horizontal resolution in pixels/mm (optional, default 1.0) */
1519
+ /** Horizontal resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
1481
1520
  xres?: number | undefined;
1482
- /** Vertical resolution in pixels/mm (optional, default 1.0) */
1521
+ /** Vertical resolution in pixels/mm, valid values are numbers in the range 0.001-1000000 (optional, default 1.0) */
1483
1522
  yres?: number | undefined;
1484
- /** Reduce bitdepth to 1, 2 or 4 bit (optional, default 8) */
1485
- bitdepth?: 1 | 2 | 4 | 8 | undefined;
1523
+ /** Reduce bitdepth to 1, 2 or 4 bit (optional) */
1524
+ bitdepth?: 1 | 2 | 4 | undefined;
1486
1525
  /** Write 1-bit images as miniswhite (optional, default false) */
1487
1526
  miniswhite?: boolean | undefined;
1488
1527
  /** Resolution unit options: inch, cm (optional, default 'inch') */
@@ -1512,7 +1551,7 @@ declare namespace sharp {
1512
1551
 
1513
1552
  interface RotateOptions {
1514
1553
  /** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
1515
- background?: Colour | Color | undefined;
1554
+ background?: ColorLike | undefined;
1516
1555
  }
1517
1556
 
1518
1557
  type Precision = 'integer' | 'float' | 'approximate';
@@ -1528,7 +1567,7 @@ declare namespace sharp {
1528
1567
 
1529
1568
  interface FlattenOptions {
1530
1569
  /** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
1531
- background?: Colour | Color | undefined;
1570
+ background?: ColorLike | undefined;
1532
1571
  }
1533
1572
 
1534
1573
  interface NegateOptions {
@@ -1553,7 +1592,7 @@ declare namespace sharp {
1553
1592
  /** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
1554
1593
  position?: number | string | undefined;
1555
1594
  /** 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?: Colour | Color | undefined;
1595
+ background?: ColorLike | undefined;
1557
1596
  /** The kernel to use for image reduction. (optional, default 'lanczos3') */
1558
1597
  kernel?: keyof KernelEnum | undefined;
1559
1598
  /** 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 +1604,13 @@ declare namespace sharp {
1565
1604
  }
1566
1605
 
1567
1606
  interface Region {
1568
- /** zero-indexed offset from left edge */
1607
+ /** zero-indexed offset from left edge, an integer between 0 and 100000000 */
1569
1608
  left: number;
1570
- /** zero-indexed offset from top edge */
1609
+ /** zero-indexed offset from top edge, an integer between 0 and 100000000 */
1571
1610
  top: number;
1572
- /** dimension of extracted image */
1611
+ /** dimension of extracted image, an integer between 0 and 100000000 */
1573
1612
  width: number;
1574
- /** dimension of extracted image */
1613
+ /** dimension of extracted image, an integer between 0 and 100000000 */
1575
1614
  height: number;
1576
1615
  }
1577
1616
 
@@ -1587,27 +1626,29 @@ declare namespace sharp {
1587
1626
  type ExtendWith = 'background' | 'copy' | 'repeat' | 'mirror';
1588
1627
 
1589
1628
  interface ExtendOptions {
1590
- /** single pixel count to top edge (optional, default 0) */
1629
+ /** single pixel count to top edge, valid values are integers in the range 0-10000 (optional, default 0) */
1591
1630
  top?: number | undefined;
1592
- /** single pixel count to left edge (optional, default 0) */
1631
+ /** single pixel count to left edge, valid values are integers in the range 0-10000 (optional, default 0) */
1593
1632
  left?: number | undefined;
1594
- /** single pixel count to bottom edge (optional, default 0) */
1633
+ /** single pixel count to bottom edge, valid values are integers in the range 0-10000 (optional, default 0) */
1595
1634
  bottom?: number | undefined;
1596
- /** single pixel count to right edge (optional, default 0) */
1635
+ /** single pixel count to right edge, valid values are integers in the range 0-10000 (optional, default 0) */
1597
1636
  right?: number | undefined;
1598
1637
  /** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
1599
- background?: Colour | Color | undefined;
1638
+ background?: ColorLike | undefined;
1600
1639
  /** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
1601
1640
  extendWith?: ExtendWith | undefined;
1602
1641
  }
1603
1642
 
1604
1643
  interface TrimOptions {
1605
1644
  /** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
1606
- background?: Colour | Color | undefined;
1645
+ background?: ColorLike | undefined;
1607
1646
  /** Allowed difference from the above colour, a positive number. (optional, default 10) */
1608
1647
  threshold?: number | undefined;
1609
1648
  /** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
1610
1649
  lineArt?: boolean | undefined;
1650
+ /** Leave a margin around trimmed content, integral number of pixels between 0 and 10000000. (optional, default 0) */
1651
+ margin?: number | undefined;
1611
1652
  }
1612
1653
 
1613
1654
  interface RawOptions {
@@ -1617,15 +1658,8 @@ declare namespace sharp {
1617
1658
  /** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
1618
1659
  type Channels = 1 | 2 | 3 | 4;
1619
1660
 
1620
- interface RGBA {
1621
- r?: number | undefined;
1622
- g?: number | undefined;
1623
- b?: number | undefined;
1624
- alpha?: number | undefined;
1625
- }
1626
-
1627
- type Colour = string | RGBA;
1628
- type Color = Colour;
1661
+ type Colour = ColorLike;
1662
+ type Color = ColorLike;
1629
1663
 
1630
1664
  interface Kernel {
1631
1665
  /** width of the kernel in pixels. */
@@ -1641,11 +1675,11 @@ declare namespace sharp {
1641
1675
  }
1642
1676
 
1643
1677
  interface ClaheOptions {
1644
- /** width of the region */
1678
+ /** width of the region. Valid values are integers in the range 1-65536. */
1645
1679
  width: number;
1646
- /** height of the region */
1680
+ /** height of the region. Valid values are integers in the range 1-65536. */
1647
1681
  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 (inclusive) (optional, default 3) */
1682
+ /** 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
1683
  maxSlope?: number | undefined;
1650
1684
  }
1651
1685
 
@@ -1663,9 +1697,9 @@ declare namespace sharp {
1663
1697
  blend?: Blend | undefined;
1664
1698
  /** gravity at which to place the overlay. (optional, default 'centre') */
1665
1699
  gravity?: Gravity | undefined;
1666
- /** the pixel offset from the top edge. */
1700
+ /** the pixel offset from the top edge, an integer between -100000000 and 100000000. */
1667
1701
  top?: number | undefined;
1668
- /** the pixel offset from the left edge. */
1702
+ /** the pixel offset from the left edge, an integer between -100000000 and 100000000. */
1669
1703
  left?: number | undefined;
1670
1704
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1671
1705
  tile?: boolean | undefined;
@@ -1691,7 +1725,7 @@ declare namespace sharp {
1691
1725
  /** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
1692
1726
  angle?: number | undefined;
1693
1727
  /** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
1694
- background?: string | RGBA | undefined;
1728
+ background?: ColorLike | undefined;
1695
1729
  /** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
1696
1730
  depth?: string | undefined;
1697
1731
  /** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
@@ -1755,6 +1789,8 @@ declare namespace sharp {
1755
1789
  channels: Channels;
1756
1790
  /** indicating if premultiplication was used */
1757
1791
  premultiplied: boolean;
1792
+ /** Indicates if the output image has an alpha channel */
1793
+ hasAlpha: boolean;
1758
1794
  /** Only defined when using a crop strategy */
1759
1795
  cropOffsetLeft?: number | undefined;
1760
1796
  /** Only defined when using a crop strategy */
@@ -1913,16 +1949,13 @@ declare namespace sharp {
1913
1949
  }
1914
1950
 
1915
1951
  interface FormatEnum {
1916
- avif: AvailableFormatInfo;
1917
1952
  dcraw: AvailableFormatInfo;
1918
1953
  dz: AvailableFormatInfo;
1919
1954
  exr: AvailableFormatInfo;
1920
1955
  fits: AvailableFormatInfo;
1921
1956
  gif: AvailableFormatInfo;
1922
1957
  heif: AvailableFormatInfo;
1923
- input: AvailableFormatInfo;
1924
1958
  jpeg: AvailableFormatInfo;
1925
- jpg: AvailableFormatInfo;
1926
1959
  jp2: AvailableFormatInfo;
1927
1960
  jxl: AvailableFormatInfo;
1928
1961
  magick: AvailableFormatInfo;
@@ -1934,8 +1967,7 @@ declare namespace sharp {
1934
1967
  raw: AvailableFormatInfo;
1935
1968
  svg: AvailableFormatInfo;
1936
1969
  tiff: AvailableFormatInfo;
1937
- tif: AvailableFormatInfo;
1938
- v: AvailableFormatInfo;
1970
+ vips: AvailableFormatInfo;
1939
1971
  webp: AvailableFormatInfo;
1940
1972
  }
1941
1973
 
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-revizly5",
4
+ "version": "0.35.0-revizly51",
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
- "install": "node install/check.js || npm run build",
97
- "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
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-types": "tsd --files ./test/types/sharp.test-d.ts",
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,43 @@
139
158
  "vips"
140
159
  ],
141
160
  "dependencies": {
142
- "@img/colour": "^1.0.0",
161
+ "@img/colour": "^1.1.0",
143
162
  "detect-libc": "^2.1.2",
144
- "semver": "^7.7.3"
163
+ "semver": "^7.8.5"
145
164
  },
146
165
  "optionalDependencies": {
147
- "@revizly/sharp-libvips-linux-arm64": "1.0.25",
148
- "@revizly/sharp-libvips-linux-x64": "1.0.25",
149
- "@revizly/sharp-linux-arm64": "0.34.5-revizly1",
150
- "@revizly/sharp-linux-x64": "0.34.5-revizly1"
166
+ "@revizly/sharp-libvips-linux-arm64": "1.0.52",
167
+ "@revizly/sharp-libvips-linux-x64": "1.0.52",
168
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly51",
169
+ "@revizly/sharp-linux-x64": "0.35.0-revizly51"
170
+ },
171
+ "peerDependenciesMeta": {
172
+ "@types/node": {
173
+ "optional": true
174
+ }
151
175
  },
152
176
  "devDependencies": {
153
- "@biomejs/biome": "^2.3.4",
177
+ "@biomejs/biome": "^2.5.14",
154
178
  "@cpplint/cli": "^0.1.0",
155
- "@emnapi/runtime": "^1.7.0",
156
- "@revizly/sharp-libvips-dev": "1.0.26",
179
+ "@emnapi/runtime": "^1.11.3",
180
+ "@revizly/sharp-libvips-dev": "1.0.52",
157
181
  "@types/node": "*",
158
- "emnapi": "^1.7.0",
159
- "exif-reader": "^2.0.2",
160
- "extract-zip": "^2.0.1",
161
- "icc": "^3.0.0",
162
- "jsdoc-to-markdown": "^9.1.3",
163
- "node-addon-api": "^8.5.0",
164
- "node-gyp": "^11.5.0",
165
- "tar-fs": "^3.1.1",
166
- "tsd": "^0.33.0"
182
+ "emnapi": "^1.11.3",
183
+ "exif-reader": "^2.0.3",
184
+ "icc": "^4.0.0",
185
+ "node-addon-api": "^8.9.2",
186
+ "node-gyp": "^12.4.0",
187
+ "publint": "^0.3.24",
188
+ "tar-fs": "^3.1.3",
189
+ "tsd": "^0.33.0",
190
+ "yauzl": "^3.4.0"
167
191
  },
168
192
  "license": "Apache-2.0",
169
193
  "engines": {
170
- "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
194
+ "node": ">=20.9.0"
171
195
  },
172
196
  "config": {
173
- "libvips": ">=8.18.0"
197
+ "libvips": ">=8.18.7"
174
198
  },
175
199
  "funding": {
176
200
  "url": "https://opencollective.com/libvips"