@revizly/sharp 0.35.0-revizly4 → 0.35.0-revizly40

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} +1 -1
  5. package/dist/colour.mjs +195 -0
  6. package/{lib/composite.js → dist/composite.cjs} +2 -1
  7. package/dist/composite.mjs +213 -0
  8. package/{lib/constructor.js → dist/constructor.cjs} +42 -29
  9. package/dist/constructor.mjs +512 -0
  10. package/dist/index.cjs +25 -0
  11. package/dist/index.d.cts +1999 -0
  12. package/dist/index.d.mts +2046 -0
  13. package/dist/index.mjs +25 -0
  14. package/{lib/input.js → dist/input.cjs} +22 -17
  15. package/dist/input.mjs +814 -0
  16. package/{lib/is.js → dist/is.cjs} +1 -1
  17. package/dist/is.mjs +143 -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} +22 -47
  21. package/dist/operation.mjs +991 -0
  22. package/{lib/output.js → dist/output.cjs} +161 -28
  23. package/dist/output.mjs +1799 -0
  24. package/{lib/resize.js → dist/resize.cjs} +40 -18
  25. package/dist/resize.mjs +617 -0
  26. package/dist/sharp.cjs +119 -0
  27. package/dist/sharp.mjs +119 -0
  28. package/{lib/utility.js → dist/utility.cjs} +11 -7
  29. package/dist/utility.mjs +295 -0
  30. package/install/build.js +3 -3
  31. package/lib/index.d.ts +99 -71
  32. package/package.json +46 -27
  33. package/src/binding.gyp +18 -13
  34. package/src/common.cc +70 -17
  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 +194 -69
  41. package/src/pipeline.h +14 -1
  42. package/src/stats.cc +6 -6
  43. package/src/utilities.cc +4 -3
  44. package/install/check.js +0 -14
  45. package/lib/index.js +0 -16
  46. package/lib/sharp.js +0 -121
@@ -3,7 +3,7 @@
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
6
- const is = require('./is');
6
+ const is = require('./is.cjs');
7
7
 
8
8
  /**
9
9
  * Weighting to apply when using contain/cover fit.
@@ -386,48 +386,52 @@ function resize (widthOrOptions, height, options) {
386
386
  * ...
387
387
  *
388
388
  * @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts
389
- * @param {number} [extend.top=0]
390
- * @param {number} [extend.left=0]
391
- * @param {number} [extend.bottom=0]
392
- * @param {number} [extend.right=0]
389
+ * @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-10000
390
+ * @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-10000
391
+ * @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-10000
392
+ * @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-10000
393
393
  * @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror.
394
394
  * @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.
395
395
  * @returns {Sharp}
396
396
  * @throws {Error} Invalid parameters
397
397
  */
398
398
  function extend (extend) {
399
- if (is.integer(extend) && extend > 0) {
400
- this.options.extendTop = extend;
401
- this.options.extendBottom = extend;
402
- this.options.extendLeft = extend;
403
- this.options.extendRight = extend;
399
+ if (is.integer(extend)) {
400
+ if (is.inRange(extend, 1, 10000)) {
401
+ this.options.extendTop = extend;
402
+ this.options.extendBottom = extend;
403
+ this.options.extendLeft = extend;
404
+ this.options.extendRight = extend;
405
+ } else {
406
+ throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend);
407
+ }
404
408
  } else if (is.object(extend)) {
405
409
  if (is.defined(extend.top)) {
406
- if (is.integer(extend.top) && extend.top >= 0) {
410
+ if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) {
407
411
  this.options.extendTop = extend.top;
408
412
  } else {
409
- throw is.invalidParameterError('top', 'positive integer', extend.top);
413
+ throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top);
410
414
  }
411
415
  }
412
416
  if (is.defined(extend.bottom)) {
413
- if (is.integer(extend.bottom) && extend.bottom >= 0) {
417
+ if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) {
414
418
  this.options.extendBottom = extend.bottom;
415
419
  } else {
416
- throw is.invalidParameterError('bottom', 'positive integer', extend.bottom);
420
+ throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom);
417
421
  }
418
422
  }
419
423
  if (is.defined(extend.left)) {
420
- if (is.integer(extend.left) && extend.left >= 0) {
424
+ if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) {
421
425
  this.options.extendLeft = extend.left;
422
426
  } else {
423
- throw is.invalidParameterError('left', 'positive integer', extend.left);
427
+ throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left);
424
428
  }
425
429
  }
426
430
  if (is.defined(extend.right)) {
427
- if (is.integer(extend.right) && extend.right >= 0) {
431
+ if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) {
428
432
  this.options.extendRight = extend.right;
429
433
  } else {
430
- throw is.invalidParameterError('right', 'positive integer', extend.right);
434
+ throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right);
431
435
  }
432
436
  }
433
437
  this._setBackgroundColourOption('extendBackground', extend.background);
@@ -506,6 +510,8 @@ function extract (options) {
506
510
  *
507
511
  * If the result of this operation would trim an image to nothing then no change is made.
508
512
  *
513
+ * Use the `lineArt` and `threshold` options for control over sensitivity.
514
+ *
509
515
  * The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
510
516
  *
511
517
  * @example
@@ -540,10 +546,19 @@ function extract (options) {
540
546
  * })
541
547
  * .toBuffer();
542
548
  *
549
+ * @example
550
+ * // Trim image leaving (up to) a 10 pixel margin around the trimmed content.
551
+ * const output = await sharp(input)
552
+ * .trim({
553
+ * margin: 10
554
+ * })
555
+ * .toBuffer();
556
+ *
543
557
  * @param {Object} [options]
544
558
  * @param {string|Object} [options.background='top-left pixel'] - Background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to that of the top-left pixel.
545
559
  * @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.
546
560
  * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?
561
+ * @param {number} [options.margin=0] - Leave a margin around trimmed content, integral number of pixels between 0 and 10000000.
547
562
  * @returns {Sharp}
548
563
  * @throws {Error} Invalid parameters
549
564
  */
@@ -564,6 +579,13 @@ function trim (options) {
564
579
  if (is.defined(options.lineArt)) {
565
580
  this._setBooleanOption('trimLineArt', options.lineArt);
566
581
  }
582
+ if (is.defined(options.margin)) {
583
+ if (is.integer(options.margin) && is.inRange(options.margin, 0, 10000000)) {
584
+ this.options.trimMargin = options.margin;
585
+ } else {
586
+ throw is.invalidParameterError('margin', 'integer between 0 and 10000000', options.margin);
587
+ }
588
+ }
567
589
  } else {
568
590
  throw is.invalidParameterError('trim', 'object', options);
569
591
  }