@revizly/sharp 0.35.0-revizly55 → 0.35.0-revizly56

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.
@@ -202,7 +202,7 @@ const queueListener = (queueLength) => {
202
202
  * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.
203
203
  * @param {Object} [options.join] - describes how an array of input images should be joined.
204
204
  * @param {number} [options.join.across=1] - number of images to join horizontally.
205
- * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.
205
+ * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image, cannot be used with `across` or `shim`.
206
206
  * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.
207
207
  * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
208
208
  * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).
@@ -202,7 +202,7 @@ const queueListener = (queueLength) => {
202
202
  * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.
203
203
  * @param {Object} [options.join] - describes how an array of input images should be joined.
204
204
  * @param {number} [options.join.across=1] - number of images to join horizontally.
205
- * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.
205
+ * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image, cannot be used with `across` or `shim`.
206
206
  * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.
207
207
  * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
208
208
  * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ /* cspell:disable */
1
2
  /**
2
3
  * Copyright 2017 François Nguyen and others.
3
4
  *
@@ -22,6 +23,7 @@
22
23
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
24
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
  */
26
+ /* cspell:enable */
25
27
 
26
28
  // SPDX-License-Identifier: MIT
27
29
 
@@ -408,7 +410,7 @@ declare namespace sharp {
408
410
 
409
411
  /**
410
412
  * Alias for calling `rotate()` with no arguments, which orients the image based
411
- * on EXIF orientsion.
413
+ * on EXIF orientation.
412
414
  *
413
415
  * This operation is aliased to emphasize its purpose, helping to remove any
414
416
  * confusion between rotation and orientation.
@@ -580,7 +582,7 @@ declare namespace sharp {
580
582
  convolve(kernel: Kernel): Sharp;
581
583
 
582
584
  /**
583
- * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
585
+ * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
584
586
  * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
585
587
  * @param options threshold options
586
588
  * @throws {Error} Invalid parameters
@@ -1703,7 +1705,7 @@ declare namespace sharp {
1703
1705
  left?: number | undefined;
1704
1706
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1705
1707
  tile?: boolean | undefined;
1706
- /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1708
+ /** Set to true to avoid premultiplying the image below. Equivalent to the --premultiplied vips option. */
1707
1709
  premultiplied?: boolean | undefined;
1708
1710
  /** number representing the DPI for vector overlay image. (optional, default 72)*/
1709
1711
  density?: number | undefined;
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ /* cspell:disable */
1
2
  /**
2
3
  * Copyright 2017 François Nguyen and others.
3
4
  *
@@ -22,6 +23,7 @@
22
23
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
24
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
  */
26
+ /* cspell:enable */
25
27
 
26
28
  // SPDX-License-Identifier: MIT
27
29
 
@@ -402,7 +404,7 @@ export interface Sharp extends Duplex {
402
404
 
403
405
  /**
404
406
  * Alias for calling `rotate()` with no arguments, which orients the image based
405
- * on EXIF orientsion.
407
+ * on EXIF orientation.
406
408
  *
407
409
  * This operation is aliased to emphasize its purpose, helping to remove any
408
410
  * confusion between rotation and orientation.
@@ -574,7 +576,7 @@ export interface Sharp extends Duplex {
574
576
  convolve(kernel: Kernel): Sharp;
575
577
 
576
578
  /**
577
- * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
579
+ * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
578
580
  * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
579
581
  * @param options threshold options
580
582
  * @throws {Error} Invalid parameters
@@ -1697,7 +1699,7 @@ export interface OverlayOptions extends SharpOptions {
1697
1699
  left?: number | undefined;
1698
1700
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1699
1701
  tile?: boolean | undefined;
1700
- /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1702
+ /** Set to true to avoid premultiplying the image below. Equivalent to the --premultiplied vips option. */
1701
1703
  premultiplied?: boolean | undefined;
1702
1704
  /** number representing the DPI for vector overlay image. (optional, default 72)*/
1703
1705
  density?: number | undefined;
package/dist/input.cjs CHANGED
@@ -511,6 +511,9 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
511
511
  throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);
512
512
  }
513
513
  }
514
+ if (inputDescriptor.joinAnimated && (inputDescriptor.joinAcross > 1 || inputDescriptor.joinShim > 0)) {
515
+ throw new Error('Expected neither join.across nor join.shim when join.animated is set');
516
+ }
514
517
  } else {
515
518
  throw new Error('Expected input to be an array of images to join');
516
519
  }
package/dist/input.mjs CHANGED
@@ -511,6 +511,9 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
511
511
  throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);
512
512
  }
513
513
  }
514
+ if (inputDescriptor.joinAnimated && (inputDescriptor.joinAcross > 1 || inputDescriptor.joinShim > 0)) {
515
+ throw new Error('Expected neither join.across nor join.shim when join.animated is set');
516
+ }
514
517
  } else {
515
518
  throw new Error('Expected input to be an array of images to join');
516
519
  }
@@ -62,7 +62,7 @@ function rotate (angle, options) {
62
62
  this.options.rotationAngle = 0;
63
63
  }
64
64
  if (is.integer(angle) && !(angle % 90)) {
65
- this.options.angle = angle;
65
+ this.options.angle = angle % 360;
66
66
  } else if (is.number(angle)) {
67
67
  this.options.rotationAngle = angle;
68
68
  if (is.object(options) && options.background) {
@@ -62,7 +62,7 @@ function rotate (angle, options) {
62
62
  this.options.rotationAngle = 0;
63
63
  }
64
64
  if (is.integer(angle) && !(angle % 90)) {
65
- this.options.angle = angle;
65
+ this.options.angle = angle % 360;
66
66
  } else if (is.number(angle)) {
67
67
  this.options.rotationAngle = angle;
68
68
  if (is.object(options) && options.background) {
package/dist/output.cjs CHANGED
@@ -1524,7 +1524,7 @@ function tile (options) {
1524
1524
  // Angle of rotation,
1525
1525
  if (is.defined(options.angle)) {
1526
1526
  if (is.integer(options.angle) && !(options.angle % 90)) {
1527
- this.options.tileAngle = options.angle;
1527
+ this.options.tileAngle = options.angle % 360;
1528
1528
  } else {
1529
1529
  throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);
1530
1530
  }
package/dist/output.mjs CHANGED
@@ -1524,7 +1524,7 @@ function tile (options) {
1524
1524
  // Angle of rotation,
1525
1525
  if (is.defined(options.angle)) {
1526
1526
  if (is.integer(options.angle) && !(options.angle % 90)) {
1527
- this.options.tileAngle = options.angle;
1527
+ this.options.tileAngle = options.angle % 360;
1528
1528
  } else {
1529
1529
  throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);
1530
1530
  }
package/dist/resize.cjs CHANGED
@@ -52,7 +52,7 @@ const extendWith = {
52
52
  };
53
53
 
54
54
  /**
55
- * Strategies for automagic cover behaviour.
55
+ * Strategies for cover behaviour.
56
56
  * @member
57
57
  * @private
58
58
  */
package/dist/resize.mjs CHANGED
@@ -52,7 +52,7 @@ const extendWith = {
52
52
  };
53
53
 
54
54
  /**
55
- * Strategies for automagic cover behaviour.
55
+ * Strategies for cover behaviour.
56
56
  * @member
57
57
  * @private
58
58
  */
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* cspell:disable */
1
2
  /**
2
3
  * Copyright 2017 François Nguyen and others.
3
4
  *
@@ -22,6 +23,7 @@
22
23
  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
24
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
  */
26
+ /* cspell:enable */
25
27
 
26
28
  // SPDX-License-Identifier: MIT
27
29
 
@@ -408,7 +410,7 @@ declare namespace sharp {
408
410
 
409
411
  /**
410
412
  * Alias for calling `rotate()` with no arguments, which orients the image based
411
- * on EXIF orientsion.
413
+ * on EXIF orientation.
412
414
  *
413
415
  * This operation is aliased to emphasize its purpose, helping to remove any
414
416
  * confusion between rotation and orientation.
@@ -580,7 +582,7 @@ declare namespace sharp {
580
582
  convolve(kernel: Kernel): Sharp;
581
583
 
582
584
  /**
583
- * Any pixel value greather than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
585
+ * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.
584
586
  * @param threshold a value in the range 0-255 representing the level at which the threshold will be applied. (optional, default 128)
585
587
  * @param options threshold options
586
588
  * @throws {Error} Invalid parameters
@@ -1703,7 +1705,7 @@ declare namespace sharp {
1703
1705
  left?: number | undefined;
1704
1706
  /** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
1705
1707
  tile?: boolean | undefined;
1706
- /** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
1708
+ /** Set to true to avoid premultiplying the image below. Equivalent to the --premultiplied vips option. */
1707
1709
  premultiplied?: boolean | undefined;
1708
1710
  /** number representing the DPI for vector overlay image. (optional, default 72)*/
1709
1711
  density?: number | undefined;
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-revizly55",
4
+ "version": "0.35.0-revizly56",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -98,10 +98,11 @@
98
98
  "build:dist": "node scripts/build.mjs",
99
99
  "clean": "rm -rf src/build/ test/fixtures/output.*",
100
100
  "test": "npm run lint && npm run test-unit",
101
- "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-publish",
101
+ "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types && npm run lint-spell && npm run lint-publish",
102
102
  "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
103
103
  "lint-js": "biome lint",
104
104
  "lint-publish": "publint --strict",
105
+ "lint-spell": "cspell --config ./test/spell/cspell.jsonc --no-progress .",
105
106
  "lint-types": "tsd --files ./test/types/sharp.test-d.{cts,mts}",
106
107
  "test-leak": "./test/leak/leak.sh",
107
108
  "test-unit": "node --experimental-test-coverage test/unit.mjs",
@@ -163,10 +164,10 @@
163
164
  "semver": "^7.8.5"
164
165
  },
165
166
  "optionalDependencies": {
166
- "@revizly/sharp-libvips-linux-arm64": "1.0.55",
167
- "@revizly/sharp-libvips-linux-x64": "1.0.55",
168
- "@revizly/sharp-linux-arm64": "0.35.0-revizly55",
169
- "@revizly/sharp-linux-x64": "0.35.0-revizly55"
167
+ "@revizly/sharp-libvips-linux-arm64": "1.0.56",
168
+ "@revizly/sharp-libvips-linux-x64": "1.0.56",
169
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly56",
170
+ "@revizly/sharp-linux-x64": "0.35.0-revizly56"
170
171
  },
171
172
  "peerDependenciesMeta": {
172
173
  "@types/node": {
@@ -174,17 +175,18 @@
174
175
  }
175
176
  },
176
177
  "devDependencies": {
177
- "@biomejs/biome": "^2.5.14",
178
+ "@biomejs/biome": "^2.5.15",
178
179
  "@cpplint/cli": "^0.1.0",
179
180
  "@emnapi/runtime": "^1.11.3",
180
- "@revizly/sharp-libvips-dev": "1.0.55",
181
+ "@revizly/sharp-libvips-dev": "1.0.56",
181
182
  "@types/node": "*",
183
+ "cspell": "^10.4.0",
182
184
  "emnapi": "^1.11.3",
183
185
  "exif-reader": "^2.0.3",
184
186
  "icc": "^4.0.0",
185
187
  "node-addon-api": "^8.9.2",
186
188
  "node-gyp": "^12.4.0",
187
- "publint": "^0.3.24",
189
+ "publint": "^0.3.25",
188
190
  "tar-fs": "^3.1.3",
189
191
  "tsd": "^0.33.0",
190
192
  "yauzl": "^3.4.0"
package/src/common.cc CHANGED
@@ -198,7 +198,7 @@ namespace sharp {
198
198
  }
199
199
  descriptor->limitInputPixels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputPixels"));
200
200
  descriptor->limitInputChannels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputChannels"));
201
- if (HasAttr(input, "access")) {
201
+ if (HasAttr(input, "sequentialRead")) {
202
202
  descriptor->access = AttrAsBool(input, "sequentialRead") ? VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM;
203
203
  }
204
204
  // Remove safety features and allow unlimited input
package/src/operations.cc CHANGED
@@ -97,7 +97,7 @@ namespace sharp {
97
97
  }
98
98
 
99
99
  /*
100
- * Contrast limiting adapative histogram equalization (CLAHE)
100
+ * Contrast limiting adaptive histogram equalization (CLAHE)
101
101
  */
102
102
  VImage Clahe(VImage image, int const width, int const height, int const maxSlope) {
103
103
  return image.hist_local(width, height, VImage::option()->set("max_slope", maxSlope));
package/src/operations.h CHANGED
@@ -28,7 +28,7 @@ namespace sharp {
28
28
  VImage Normalise(VImage image, int const lower, int const upper);
29
29
 
30
30
  /*
31
- * Contrast limiting adapative histogram equalization (CLAHE)
31
+ * Contrast limiting adaptive histogram equalization (CLAHE)
32
32
  */
33
33
  VImage Clahe(VImage image, int const width, int const height, int const maxSlope);
34
34
 
package/src/pipeline.cc CHANGED
@@ -270,7 +270,12 @@ class PipelineWorker : public Napi::AsyncWorker {
270
270
  if (baton->input->buffer != nullptr) {
271
271
  // Reload JPEG buffer
272
272
  VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
273
- image = VImage::jpegload_buffer(blob, option);
273
+ try {
274
+ image = VImage::jpegload_buffer(blob, option);
275
+ } catch (...) {
276
+ vips_area_unref(reinterpret_cast<VipsArea*>(blob));
277
+ throw;
278
+ }
274
279
  vips_area_unref(reinterpret_cast<VipsArea*>(blob));
275
280
  } else {
276
281
  // Reload JPEG file
@@ -282,7 +287,12 @@ class PipelineWorker : public Napi::AsyncWorker {
282
287
  if (baton->input->buffer != nullptr) {
283
288
  // Reload WebP buffer
284
289
  VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
285
- image = VImage::webpload_buffer(blob, option);
290
+ try {
291
+ image = VImage::webpload_buffer(blob, option);
292
+ } catch (...) {
293
+ vips_area_unref(reinterpret_cast<VipsArea*>(blob));
294
+ throw;
295
+ }
286
296
  vips_area_unref(reinterpret_cast<VipsArea*>(blob));
287
297
  } else {
288
298
  // Reload WebP file
@@ -292,7 +302,12 @@ class PipelineWorker : public Napi::AsyncWorker {
292
302
  if (baton->input->buffer != nullptr) {
293
303
  // Reload SVG buffer
294
304
  VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
295
- image = VImage::svgload_buffer(blob, option);
305
+ try {
306
+ image = VImage::svgload_buffer(blob, option);
307
+ } catch (...) {
308
+ vips_area_unref(reinterpret_cast<VipsArea*>(blob));
309
+ throw;
310
+ }
296
311
  vips_area_unref(reinterpret_cast<VipsArea*>(blob));
297
312
  } else {
298
313
  // Reload SVG file
@@ -306,7 +321,12 @@ class PipelineWorker : public Napi::AsyncWorker {
306
321
  if (baton->input->buffer != nullptr) {
307
322
  // Reload PDF buffer
308
323
  VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
309
- image = VImage::pdfload_buffer(blob, option);
324
+ try {
325
+ image = VImage::pdfload_buffer(blob, option);
326
+ } catch (...) {
327
+ vips_area_unref(reinterpret_cast<VipsArea*>(blob));
328
+ throw;
329
+ }
310
330
  vips_area_unref(reinterpret_cast<VipsArea*>(blob));
311
331
  } else {
312
332
  // Reload PDF file
@@ -1867,9 +1887,9 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
1867
1887
  baton->convKernelOffset = sharp::AttrAsDouble(kernel, "offset");
1868
1888
  size_t const kernelSize = static_cast<size_t>(baton->convKernelWidth * baton->convKernelHeight);
1869
1889
  baton->convKernel.resize(kernelSize);
1870
- Napi::Array kdata = kernel.Get("kernel").As<Napi::Array>();
1890
+ Napi::Array kernelData = kernel.Get("kernel").As<Napi::Array>();
1871
1891
  for (unsigned int i = 0; i < kernelSize; i++) {
1872
- baton->convKernel[i] = sharp::AttrAsDouble(kdata, i);
1892
+ baton->convKernel[i] = sharp::AttrAsDouble(kernelData, i);
1873
1893
  }
1874
1894
  }
1875
1895
  if (options.Has("recombMatrix")) {
package/src/stats.cc CHANGED
@@ -60,7 +60,7 @@ class StatsWorker : public Napi::AsyncWorker {
60
60
  static_cast<int>(stats.getpoint(STAT_MAXY_INDEX, b).front()));
61
61
  baton->channelStats.push_back(cStats);
62
62
  }
63
- // Image is not opaque when alpha layer is present and contains a non-mamixa value
63
+ // Image is not opaque when alpha layer is present and contains a non-maxima value
64
64
  if (image.has_alpha()) {
65
65
  double const minAlpha = static_cast<double>(stats.getpoint(STAT_MIN_INDEX, bands).front());
66
66
  if (minAlpha != vips_interpretation_max_alpha(image.interpretation())) {