sharp 0.35.4 → 0.35.5-rc.1

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/dist/index.d.cts CHANGED
@@ -1404,7 +1404,7 @@ declare namespace sharp {
1404
1404
  chromaSubsampling?: '4:4:4' | '4:2:0';
1405
1405
  }
1406
1406
 
1407
- interface JxlOptions extends OutputOptions {
1407
+ interface JxlOptions extends OutputOptions, AnimationOptions {
1408
1408
  /** Maximum encoding error, between 0 (highest quality) and 15 (lowest quality) (optional, default 1.0) */
1409
1409
  distance?: number;
1410
1410
  /** Calculate distance based on JPEG-like quality, between 1 and 100, overrides distance if specified */
@@ -1413,7 +1413,7 @@ declare namespace sharp {
1413
1413
  decodingTier?: number;
1414
1414
  /** Use lossless compression (optional, default false) */
1415
1415
  lossless?: boolean;
1416
- /** CPU effort, between 3 (fastest) and 9 (slowest) (optional, default 7) */
1416
+ /** CPU effort, between 1 (fastest) and 9 (slowest) (optional, default 7) */
1417
1417
  effort?: number | undefined;
1418
1418
  }
1419
1419
 
package/dist/index.d.mts CHANGED
@@ -1398,7 +1398,7 @@ export interface Jp2Options extends OutputOptions {
1398
1398
  chromaSubsampling?: '4:4:4' | '4:2:0';
1399
1399
  }
1400
1400
 
1401
- export interface JxlOptions extends OutputOptions {
1401
+ export interface JxlOptions extends OutputOptions, AnimationOptions {
1402
1402
  /** Maximum encoding error, between 0 (highest quality) and 15 (lowest quality) (optional, default 1.0) */
1403
1403
  distance?: number;
1404
1404
  /** Calculate distance based on JPEG-like quality, between 1 and 100, overrides distance if specified */
@@ -1407,7 +1407,7 @@ export interface JxlOptions extends OutputOptions {
1407
1407
  decodingTier?: number;
1408
1408
  /** Use lossless compression (optional, default false) */
1409
1409
  lossless?: boolean;
1410
- /** CPU effort, between 3 (fastest) and 9 (slowest) (optional, default 7) */
1410
+ /** CPU effort, between 1 (fastest) and 9 (slowest) (optional, default 7) */
1411
1411
  effort?: number | undefined;
1412
1412
  }
1413
1413
 
@@ -2041,6 +2041,6 @@ export interface SharpConstructor {
2041
2041
  bool: BoolEnum;
2042
2042
  }
2043
2043
 
2044
- export const sharp: SharpConstructor;
2044
+ declare const sharp: SharpConstructor;
2045
2045
  export default sharp;
2046
2046
 
package/dist/is.cjs CHANGED
@@ -107,9 +107,15 @@ const inArray = (val, list) => list.includes(val);
107
107
  * @returns {Error} Containing the formatted message.
108
108
  * @private
109
109
  */
110
- const invalidParameterError = (name, expected, actual) => new Error(
111
- `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
110
+ const invalidParameterError = (name, expected, actual) => {
111
+ let actualString;
112
+ try {
113
+ actualString = String(actual).slice(0, 100);
114
+ } catch {}
115
+ return new Error(
116
+ `Expected ${expected} for ${name} but received ${actualString} of type ${typeof actual}`
112
117
  );
118
+ };
113
119
 
114
120
  /**
115
121
  * Ensures an Error from C++ contains a JS stack.
package/dist/is.mjs CHANGED
@@ -107,9 +107,15 @@ const inArray = (val, list) => list.includes(val);
107
107
  * @returns {Error} Containing the formatted message.
108
108
  * @private
109
109
  */
110
- const invalidParameterError = (name, expected, actual) => new Error(
111
- `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
110
+ const invalidParameterError = (name, expected, actual) => {
111
+ let actualString;
112
+ try {
113
+ actualString = String(actual).slice(0, 100);
114
+ } catch {}
115
+ return new Error(
116
+ `Expected ${expected} for ${name} but received ${actualString} of type ${typeof actual}`
112
117
  );
118
+ };
113
119
 
114
120
  /**
115
121
  * Ensures an Error from C++ contains a JS stack.
@@ -824,7 +824,7 @@ function linear (a, b) {
824
824
  this.options.linearA = [];
825
825
  } else if (is.number(a)) {
826
826
  this.options.linearA = [a];
827
- } else if (Array.isArray(a) && a.length && a.every(is.number)) {
827
+ } else if (Array.isArray(a) && is.inRange(a.length, 1, 1000000) && a.every(is.number)) {
828
828
  this.options.linearA = a;
829
829
  } else {
830
830
  throw is.invalidParameterError('a', 'number or array of numbers', a);
@@ -833,7 +833,7 @@ function linear (a, b) {
833
833
  this.options.linearB = [];
834
834
  } else if (is.number(b)) {
835
835
  this.options.linearB = [b];
836
- } else if (Array.isArray(b) && b.length && b.every(is.number)) {
836
+ } else if (Array.isArray(b) && is.inRange(b.length, 1, 1000000) && b.every(is.number)) {
837
837
  this.options.linearB = b;
838
838
  } else {
839
839
  throw is.invalidParameterError('b', 'number or array of numbers', b);
@@ -824,7 +824,7 @@ function linear (a, b) {
824
824
  this.options.linearA = [];
825
825
  } else if (is.number(a)) {
826
826
  this.options.linearA = [a];
827
- } else if (Array.isArray(a) && a.length && a.every(is.number)) {
827
+ } else if (Array.isArray(a) && is.inRange(a.length, 1, 1000000) && a.every(is.number)) {
828
828
  this.options.linearA = a;
829
829
  } else {
830
830
  throw is.invalidParameterError('a', 'number or array of numbers', a);
@@ -833,7 +833,7 @@ function linear (a, b) {
833
833
  this.options.linearB = [];
834
834
  } else if (is.number(b)) {
835
835
  this.options.linearB = [b];
836
- } else if (Array.isArray(b) && b.length && b.every(is.number)) {
836
+ } else if (Array.isArray(b) && is.inRange(b.length, 1, 1000000) && b.every(is.number)) {
837
837
  this.options.linearB = b;
838
838
  } else {
839
839
  throw is.invalidParameterError('b', 'number or array of numbers', b);
package/dist/output.cjs CHANGED
@@ -1066,6 +1066,7 @@ function trySetAnimationOptions (source, target) {
1066
1066
  target.delay = [source.delay];
1067
1067
  } else if (
1068
1068
  Array.isArray(source.delay) &&
1069
+ is.inRange(source.delay.length, 1, 1000000) &&
1069
1070
  source.delay.every(is.integer) &&
1070
1071
  source.delay.every(v => is.inRange(v, 0, 65535))) {
1071
1072
  target.delay = source.delay;
package/dist/output.mjs CHANGED
@@ -1066,6 +1066,7 @@ function trySetAnimationOptions (source, target) {
1066
1066
  target.delay = [source.delay];
1067
1067
  } else if (
1068
1068
  Array.isArray(source.delay) &&
1069
+ is.inRange(source.delay.length, 1, 1000000) &&
1069
1070
  source.delay.every(is.integer) &&
1070
1071
  source.delay.every(v => is.inRange(v, 0, 65535))) {
1071
1072
  target.delay = source.delay;
package/dist/resize.cjs CHANGED
@@ -386,10 +386,10 @@ 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] - 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
389
+ * @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-100000000
390
+ * @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-100000000
391
+ * @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-100000000
392
+ * @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-100000000
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}
@@ -397,41 +397,41 @@ function resize (widthOrOptions, height, options) {
397
397
  */
398
398
  function extend (extend) {
399
399
  if (is.integer(extend)) {
400
- if (is.inRange(extend, 1, 10000)) {
400
+ if (is.inRange(extend, 1, 100000000)) {
401
401
  this.options.extendTop = extend;
402
402
  this.options.extendBottom = extend;
403
403
  this.options.extendLeft = extend;
404
404
  this.options.extendRight = extend;
405
405
  } else {
406
- throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend);
406
+ throw is.invalidParameterError('extend', 'integer between 1 and 100000000', extend);
407
407
  }
408
408
  } else if (is.object(extend)) {
409
409
  if (is.defined(extend.top)) {
410
- if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) {
410
+ if (is.integer(extend.top) && is.inRange(extend.top, 0, 100000000)) {
411
411
  this.options.extendTop = extend.top;
412
412
  } else {
413
- throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top);
413
+ throw is.invalidParameterError('top', 'integer between 0 and 100000000', extend.top);
414
414
  }
415
415
  }
416
416
  if (is.defined(extend.bottom)) {
417
- if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) {
417
+ if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 100000000)) {
418
418
  this.options.extendBottom = extend.bottom;
419
419
  } else {
420
- throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom);
420
+ throw is.invalidParameterError('bottom', 'integer between 0 and 100000000', extend.bottom);
421
421
  }
422
422
  }
423
423
  if (is.defined(extend.left)) {
424
- if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) {
424
+ if (is.integer(extend.left) && is.inRange(extend.left, 0, 100000000)) {
425
425
  this.options.extendLeft = extend.left;
426
426
  } else {
427
- throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left);
427
+ throw is.invalidParameterError('left', 'integer between 0 and 100000000', extend.left);
428
428
  }
429
429
  }
430
430
  if (is.defined(extend.right)) {
431
- if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) {
431
+ if (is.integer(extend.right) && is.inRange(extend.right, 0, 100000000)) {
432
432
  this.options.extendRight = extend.right;
433
433
  } else {
434
- throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right);
434
+ throw is.invalidParameterError('right', 'integer between 0 and 100000000', extend.right);
435
435
  }
436
436
  }
437
437
  this._setBackgroundColourOption('extendBackground', extend.background);
package/dist/resize.mjs CHANGED
@@ -386,10 +386,10 @@ 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] - 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
389
+ * @param {number} [extend.top=0] - number of pixels to add to the top edge, valid values are integers in the range 0-100000000
390
+ * @param {number} [extend.left=0] - number of pixels to add to the left edge, valid values are integers in the range 0-100000000
391
+ * @param {number} [extend.bottom=0] - number of pixels to add to the bottom edge, valid values are integers in the range 0-100000000
392
+ * @param {number} [extend.right=0] - number of pixels to add to the right edge, valid values are integers in the range 0-100000000
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}
@@ -397,41 +397,41 @@ function resize (widthOrOptions, height, options) {
397
397
  */
398
398
  function extend (extend) {
399
399
  if (is.integer(extend)) {
400
- if (is.inRange(extend, 1, 10000)) {
400
+ if (is.inRange(extend, 1, 100000000)) {
401
401
  this.options.extendTop = extend;
402
402
  this.options.extendBottom = extend;
403
403
  this.options.extendLeft = extend;
404
404
  this.options.extendRight = extend;
405
405
  } else {
406
- throw is.invalidParameterError('extend', 'integer between 1 and 10000', extend);
406
+ throw is.invalidParameterError('extend', 'integer between 1 and 100000000', extend);
407
407
  }
408
408
  } else if (is.object(extend)) {
409
409
  if (is.defined(extend.top)) {
410
- if (is.integer(extend.top) && is.inRange(extend.top, 0, 10000)) {
410
+ if (is.integer(extend.top) && is.inRange(extend.top, 0, 100000000)) {
411
411
  this.options.extendTop = extend.top;
412
412
  } else {
413
- throw is.invalidParameterError('top', 'integer between 0 and 10000', extend.top);
413
+ throw is.invalidParameterError('top', 'integer between 0 and 100000000', extend.top);
414
414
  }
415
415
  }
416
416
  if (is.defined(extend.bottom)) {
417
- if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 10000)) {
417
+ if (is.integer(extend.bottom) && is.inRange(extend.bottom, 0, 100000000)) {
418
418
  this.options.extendBottom = extend.bottom;
419
419
  } else {
420
- throw is.invalidParameterError('bottom', 'integer between 0 and 10000', extend.bottom);
420
+ throw is.invalidParameterError('bottom', 'integer between 0 and 100000000', extend.bottom);
421
421
  }
422
422
  }
423
423
  if (is.defined(extend.left)) {
424
- if (is.integer(extend.left) && is.inRange(extend.left, 0, 10000)) {
424
+ if (is.integer(extend.left) && is.inRange(extend.left, 0, 100000000)) {
425
425
  this.options.extendLeft = extend.left;
426
426
  } else {
427
- throw is.invalidParameterError('left', 'integer between 0 and 10000', extend.left);
427
+ throw is.invalidParameterError('left', 'integer between 0 and 100000000', extend.left);
428
428
  }
429
429
  }
430
430
  if (is.defined(extend.right)) {
431
- if (is.integer(extend.right) && is.inRange(extend.right, 0, 10000)) {
431
+ if (is.integer(extend.right) && is.inRange(extend.right, 0, 100000000)) {
432
432
  this.options.extendRight = extend.right;
433
433
  } else {
434
- throw is.invalidParameterError('right', 'integer between 0 and 10000', extend.right);
434
+ throw is.invalidParameterError('right', 'integer between 0 and 100000000', extend.right);
435
435
  }
436
436
  }
437
437
  this._setBackgroundColourOption('extendBackground', extend.background);
package/dist/sharp.cjs CHANGED
@@ -112,8 +112,8 @@ if (!sharp) {
112
112
 
113
113
  const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
114
114
  errors.forEach((err) => {
115
- if (!err.code.endsWith("MODULE_NOT_FOUND")) {
116
- help.push(`${err.code}: ${err.message}`);
115
+ if (!err.code?.endsWith("MODULE_NOT_FOUND")) {
116
+ help.push(err.code ? `${err.code}: ${err.message}` : err.message);
117
117
  }
118
118
  });
119
119
  const messages = errors.map((err) => err.message).join(" ");
@@ -122,7 +122,7 @@ if (!sharp) {
122
122
  if (isUnsupportedNodeRuntime()) {
123
123
  const { found, expected } = isUnsupportedNodeRuntime();
124
124
  help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
125
- } else if (prebuiltPlatforms.includes(runtimePlatform)) {
125
+ } else if (prebuiltPlatforms.includes(runtimePlatform) && !/libstdc\+\+\.so/.test(messages)) {
126
126
  const [os, cpu] = runtimePlatform.split("-");
127
127
  const libc = os.endsWith("musl") ? " --libc=musl" : "";
128
128
  help.push(
package/dist/sharp.mjs CHANGED
@@ -112,8 +112,8 @@ if (!sharp) {
112
112
 
113
113
  const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
114
114
  errors.forEach((err) => {
115
- if (!err.code.endsWith("MODULE_NOT_FOUND")) {
116
- help.push(`${err.code}: ${err.message}`);
115
+ if (!err.code?.endsWith("MODULE_NOT_FOUND")) {
116
+ help.push(err.code ? `${err.code}: ${err.message}` : err.message);
117
117
  }
118
118
  });
119
119
  const messages = errors.map((err) => err.message).join(" ");
@@ -122,7 +122,7 @@ if (!sharp) {
122
122
  if (isUnsupportedNodeRuntime()) {
123
123
  const { found, expected } = isUnsupportedNodeRuntime();
124
124
  help.push("- Please upgrade Node.js:", ` Found ${found}`, ` Requires ${expected}`);
125
- } else if (prebuiltPlatforms.includes(runtimePlatform)) {
125
+ } else if (prebuiltPlatforms.includes(runtimePlatform) && !/libstdc\+\+\.so/.test(messages)) {
126
126
  const [os, cpu] = runtimePlatform.split("-");
127
127
  const libc = os.endsWith("musl") ? " --libc=musl" : "";
128
128
  help.push(
package/lib/index.d.ts CHANGED
@@ -1404,7 +1404,7 @@ declare namespace sharp {
1404
1404
  chromaSubsampling?: '4:4:4' | '4:2:0';
1405
1405
  }
1406
1406
 
1407
- interface JxlOptions extends OutputOptions {
1407
+ interface JxlOptions extends OutputOptions, AnimationOptions {
1408
1408
  /** Maximum encoding error, between 0 (highest quality) and 15 (lowest quality) (optional, default 1.0) */
1409
1409
  distance?: number;
1410
1410
  /** Calculate distance based on JPEG-like quality, between 1 and 100, overrides distance if specified */
@@ -1413,7 +1413,7 @@ declare namespace sharp {
1413
1413
  decodingTier?: number;
1414
1414
  /** Use lossless compression (optional, default false) */
1415
1415
  lossless?: boolean;
1416
- /** CPU effort, between 3 (fastest) and 9 (slowest) (optional, default 7) */
1416
+ /** CPU effort, between 1 (fastest) and 9 (slowest) (optional, default 7) */
1417
1417
  effort?: number | undefined;
1418
1418
  }
1419
1419
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "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.4",
4
+ "version": "0.35.5-rc.1",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -163,31 +163,31 @@
163
163
  "semver": "^7.8.5"
164
164
  },
165
165
  "optionalDependencies": {
166
- "@img/sharp-darwin-arm64": "0.35.4",
167
- "@img/sharp-darwin-x64": "0.35.4",
168
- "@img/sharp-freebsd-wasm32": "0.35.4",
169
- "@img/sharp-libvips-darwin-arm64": "1.3.3",
170
- "@img/sharp-libvips-darwin-x64": "1.3.3",
171
- "@img/sharp-libvips-linux-arm": "1.3.3",
172
- "@img/sharp-libvips-linux-arm64": "1.3.3",
173
- "@img/sharp-libvips-linux-ppc64": "1.3.3",
174
- "@img/sharp-libvips-linux-riscv64": "1.3.3",
175
- "@img/sharp-libvips-linux-s390x": "1.3.3",
176
- "@img/sharp-libvips-linux-x64": "1.3.3",
177
- "@img/sharp-libvips-linuxmusl-arm64": "1.3.3",
178
- "@img/sharp-libvips-linuxmusl-x64": "1.3.3",
179
- "@img/sharp-linux-arm": "0.35.4",
180
- "@img/sharp-linux-arm64": "0.35.4",
181
- "@img/sharp-linux-ppc64": "0.35.4",
182
- "@img/sharp-linux-riscv64": "0.35.4",
183
- "@img/sharp-linux-s390x": "0.35.4",
184
- "@img/sharp-linux-x64": "0.35.4",
185
- "@img/sharp-linuxmusl-arm64": "0.35.4",
186
- "@img/sharp-linuxmusl-x64": "0.35.4",
187
- "@img/sharp-webcontainers-wasm32": "0.35.4",
188
- "@img/sharp-win32-arm64": "0.35.4",
189
- "@img/sharp-win32-ia32": "0.35.4",
190
- "@img/sharp-win32-x64": "0.35.4"
166
+ "@img/sharp-darwin-arm64": "0.35.5-rc.1",
167
+ "@img/sharp-darwin-x64": "0.35.5-rc.1",
168
+ "@img/sharp-freebsd-wasm32": "0.35.5-rc.1",
169
+ "@img/sharp-libvips-darwin-arm64": "1.3.4-rc.1",
170
+ "@img/sharp-libvips-darwin-x64": "1.3.4-rc.1",
171
+ "@img/sharp-libvips-linux-arm": "1.3.4-rc.1",
172
+ "@img/sharp-libvips-linux-arm64": "1.3.4-rc.1",
173
+ "@img/sharp-libvips-linux-ppc64": "1.3.4-rc.1",
174
+ "@img/sharp-libvips-linux-riscv64": "1.3.4-rc.1",
175
+ "@img/sharp-libvips-linux-s390x": "1.3.4-rc.1",
176
+ "@img/sharp-libvips-linux-x64": "1.3.4-rc.1",
177
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.4-rc.1",
178
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.4-rc.1",
179
+ "@img/sharp-linux-arm": "0.35.5-rc.1",
180
+ "@img/sharp-linux-arm64": "0.35.5-rc.1",
181
+ "@img/sharp-linux-ppc64": "0.35.5-rc.1",
182
+ "@img/sharp-linux-riscv64": "0.35.5-rc.1",
183
+ "@img/sharp-linux-s390x": "0.35.5-rc.1",
184
+ "@img/sharp-linux-x64": "0.35.5-rc.1",
185
+ "@img/sharp-linuxmusl-arm64": "0.35.5-rc.1",
186
+ "@img/sharp-linuxmusl-x64": "0.35.5-rc.1",
187
+ "@img/sharp-webcontainers-wasm32": "0.35.5-rc.1",
188
+ "@img/sharp-win32-arm64": "0.35.5-rc.1",
189
+ "@img/sharp-win32-ia32": "0.35.5-rc.1",
190
+ "@img/sharp-win32-x64": "0.35.5-rc.1"
191
191
  },
192
192
  "peerDependenciesMeta": {
193
193
  "@types/node": {
@@ -195,31 +195,31 @@
195
195
  }
196
196
  },
197
197
  "devDependencies": {
198
- "@biomejs/biome": "^2.5.10",
198
+ "@biomejs/biome": "^2.5.14",
199
199
  "@cpplint/cli": "^0.1.0",
200
200
  "@emnapi/runtime": "^1.11.3",
201
- "@img/sharp-libvips-dev": "1.3.3",
202
- "@img/sharp-libvips-dev-wasm32": "1.3.3",
203
- "@img/sharp-libvips-win32-arm64": "1.3.3",
204
- "@img/sharp-libvips-win32-ia32": "1.3.3",
205
- "@img/sharp-libvips-win32-x64": "1.3.3",
201
+ "@img/sharp-libvips-dev": "1.3.4-rc.1",
202
+ "@img/sharp-libvips-dev-wasm32": "1.3.4-rc.1",
203
+ "@img/sharp-libvips-win32-arm64": "1.3.4-rc.1",
204
+ "@img/sharp-libvips-win32-ia32": "1.3.4-rc.1",
205
+ "@img/sharp-libvips-win32-x64": "1.3.4-rc.1",
206
206
  "@types/node": "*",
207
207
  "emnapi": "^1.11.3",
208
208
  "exif-reader": "^2.0.3",
209
- "yauzl": "^3.4.0",
210
209
  "icc": "^4.0.0",
211
210
  "node-addon-api": "^8.9.2",
212
211
  "node-gyp": "^12.4.0",
213
212
  "publint": "^0.3.24",
214
213
  "tar-fs": "^3.1.3",
215
- "tsd": "^0.33.0"
214
+ "tsd": "^0.33.0",
215
+ "yauzl": "^3.4.0"
216
216
  },
217
217
  "license": "Apache-2.0",
218
218
  "engines": {
219
219
  "node": ">=20.9.0"
220
220
  },
221
221
  "config": {
222
- "libvips": ">=8.18.6"
222
+ "libvips": ">=8.18.7"
223
223
  },
224
224
  "funding": {
225
225
  "url": "https://opencollective.com/libvips"
package/src/binding.gyp CHANGED
@@ -1,7 +1,7 @@
1
1
  # Copyright 2013 Lovell Fuller and others.
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
- {
4
+ { # noqa: B018
5
5
  'variables': {
6
6
  'vips_version': '<!(node -p "require(\'../dist/libvips.cjs\').minimumLibvipsVersion")',
7
7
  'platform_and_arch': '<!(node -p "require(\'../dist/libvips.cjs\').buildPlatformArch()")',
package/src/common.cc CHANGED
@@ -540,10 +540,10 @@ namespace sharp {
540
540
  if (channels == 4) {
541
541
  background.push_back(descriptor->createBackground[3]);
542
542
  }
543
- image = VImage::new_matrix(descriptor->createWidth, descriptor->createHeight)
544
- .copy(VImage::option()->set("interpretation",
545
- channels < 3 ? VIPS_INTERPRETATION_B_W : VIPS_INTERPRETATION_sRGB))
546
- .new_from_image(background);
543
+ image = VImage::black(descriptor->createWidth, descriptor->createHeight,
544
+ VImage::option()->set("bands", channels))
545
+ .copy(VImage::option()->set("interpretation", VIPS_INTERPRETATION_sRGB))
546
+ .linear(std::vector<double>(channels, 0.0), background, VImage::option()->set("uchar", true));
547
547
  }
548
548
  if (descriptor->createPageHeight > 0) {
549
549
  image.set(VIPS_META_PAGE_HEIGHT, descriptor->createPageHeight);
package/src/common.h CHANGED
@@ -19,8 +19,8 @@
19
19
 
20
20
  #if (VIPS_MAJOR_VERSION < 8) || \
21
21
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 18) || \
22
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 6)
23
- #error "libvips version 8.18.6+ is required - please see https://sharp.pixelplumbing.com/install"
22
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 7)
23
+ #error "libvips version 8.18.7+ is required - please see https://sharp.pixelplumbing.com/install"
24
24
  #endif
25
25
 
26
26
  #if defined(__has_include)
package/src/pipeline.cc CHANGED
@@ -56,9 +56,9 @@ class PipelineWorker : public Napi::AsyncWorker {
56
56
  hasAlpha |= image.has_alpha();
57
57
  }
58
58
  if (hasAlpha) {
59
- for (auto &image : images) {
60
- if (!image.has_alpha()) {
61
- image = sharp::EnsureAlpha(image, 1);
59
+ for (size_t i = 0; i < images.size(); i++) {
60
+ if (!images[i].has_alpha()) {
61
+ images[i] = sharp::EnsureAlpha(images[i], 1);
62
62
  }
63
63
  }
64
64
  } else {
@@ -94,7 +94,10 @@ class PipelineWorker : public Napi::AsyncWorker {
94
94
  // Calculate angle of rotation
95
95
  VipsAngle rotation = VIPS_ANGLE_D0;
96
96
  VipsAngle autoRotation = VIPS_ANGLE_D0;
97
+ VipsAngle gainMapRotation = VIPS_ANGLE_D0;
97
98
  bool autoFlop = false;
99
+ bool gainMapFlip = false;
100
+ bool gainMapFlop = false;
98
101
 
99
102
  if (baton->input->autoOrient) {
100
103
  // Rotate and flip image according to Exif orientation
@@ -115,11 +118,13 @@ class PipelineWorker : public Napi::AsyncWorker {
115
118
  MultiPageUnsupported(nPages, "Rotate");
116
119
  }
117
120
  image = image.rot(autoRotation);
121
+ gainMapRotation = autoRotation;
118
122
  autoRotation = VIPS_ANGLE_D0;
119
123
  }
120
124
  if (autoFlop) {
121
125
  image = image.flip(VIPS_DIRECTION_HORIZONTAL);
122
126
  autoFlop = false;
127
+ gainMapFlop = true;
123
128
  }
124
129
  }
125
130
 
@@ -128,20 +133,24 @@ class PipelineWorker : public Napi::AsyncWorker {
128
133
  if (baton->flip) {
129
134
  image = image.flip(VIPS_DIRECTION_VERTICAL);
130
135
  baton->flip = false;
136
+ gainMapFlip = true;
131
137
  }
132
138
  if (baton->flop) {
133
139
  image = image.flip(VIPS_DIRECTION_HORIZONTAL);
134
140
  baton->flop = false;
141
+ gainMapFlop = true;
135
142
  }
136
143
  if (rotation != VIPS_ANGLE_D0) {
137
144
  if (rotation != VIPS_ANGLE_D180) {
138
145
  MultiPageUnsupported(nPages, "Rotate");
139
146
  }
140
147
  image = image.rot(rotation);
148
+ gainMapRotation = rotation;
141
149
  rotation = VIPS_ANGLE_D0;
142
150
  }
143
151
  if (baton->rotationAngle != 0.0) {
144
152
  MultiPageUnsupported(nPages, "Rotate");
153
+ KeepGainMapUnsupported(baton->keepGainMap, "Rotate");
145
154
  std::vector<double> background;
146
155
  std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, false);
147
156
  image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)).copy_memory();
@@ -152,6 +161,7 @@ class PipelineWorker : public Napi::AsyncWorker {
152
161
  // Trim
153
162
  if (baton->trimThreshold >= 0.0) {
154
163
  MultiPageUnsupported(nPages, "Trim");
164
+ KeepGainMapUnsupported(baton->keepGainMap, "Trim");
155
165
  image = sharp::StaySequential(image);
156
166
  image = sharp::Trim(image, baton->trimBackground, baton->trimThreshold, baton->trimLineArt, baton->trimMargin);
157
167
  baton->trimOffsetLeft = image.xoffset();
@@ -306,6 +316,20 @@ class PipelineWorker : public Napi::AsyncWorker {
306
316
  if (image.get_typeof("gainmap-scale-factor") == G_TYPE_INT) {
307
317
  gainMapScaleFactor = image.get_int("gainmap-scale-factor");
308
318
  }
319
+ if (gainMapFlip) {
320
+ gainMap = gainMap.flip(VIPS_DIRECTION_VERTICAL);
321
+ }
322
+ if (gainMapFlop) {
323
+ gainMap = gainMap.flip(VIPS_DIRECTION_HORIZONTAL);
324
+ }
325
+ if (gainMapRotation != VIPS_ANGLE_D0) {
326
+ gainMap = gainMap.rot(gainMapRotation);
327
+ }
328
+ if (baton->topOffsetPre != -1) {
329
+ gainMap = gainMap.extract_area(
330
+ baton->leftOffsetPre / gainMapScaleFactor, baton->topOffsetPre / gainMapScaleFactor,
331
+ baton->widthPre / gainMapScaleFactor, baton->heightPre / gainMapScaleFactor);
332
+ }
309
333
  } else if (baton->withGainMap) {
310
334
  image = image.uhdr2scRGB();
311
335
  }
@@ -557,6 +581,7 @@ class PipelineWorker : public Napi::AsyncWorker {
557
581
  // Rotate post-extract non-90 angle
558
582
  if (!baton->rotateBefore && baton->rotationAngle != 0.0) {
559
583
  MultiPageUnsupported(nPages, "Rotate");
584
+ KeepGainMapUnsupported(baton->keepGainMap, "Rotate");
560
585
  image = sharp::StaySequential(image);
561
586
  std::vector<double> background;
562
587
  std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, shouldPremultiplyAlpha);
package/src/utilities.cc CHANGED
@@ -133,7 +133,7 @@ Napi::Value format(const Napi::CallbackInfo& info) {
133
133
  input.Set("file", hasInputFile);
134
134
  input.Set("buffer", hasInputBuffer);
135
135
  input.Set("stream", hasInputBuffer);
136
- if (hasInputFile) {
136
+ if (oc) {
137
137
  const VipsForeignClass *fc = VIPS_FOREIGN_CLASS(oc);
138
138
  if (fc->suffs) {
139
139
  Napi::Array fileSuffix = Napi::Array::New(env);