@revizly/sharp 0.34.4-revizly1 → 0.34.4-revizly11

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.
@@ -0,0 +1,36 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ const {
5
+ useGlobalLibvips,
6
+ globalLibvipsVersion,
7
+ log,
8
+ spawnRebuild,
9
+ } = require('../lib/libvips');
10
+
11
+ log('Attempting to build from source via node-gyp');
12
+ log('See https://sharp.pixelplumbing.com/install#building-from-source');
13
+
14
+ try {
15
+ const addonApi = require('node-addon-api');
16
+ log(`Found node-addon-api ${addonApi.version || ''}`);
17
+ } catch (_err) {
18
+ log('Please add node-addon-api to your dependencies');
19
+ process.exit(1);
20
+ }
21
+ try {
22
+ const gyp = require('node-gyp');
23
+ log(`Found node-gyp ${gyp().version}`);
24
+ } catch (_err) {
25
+ log('Please add node-gyp to your dependencies');
26
+ process.exit(1);
27
+ }
28
+
29
+ if (useGlobalLibvips(log)) {
30
+ log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
31
+ }
32
+
33
+ const status = spawnRebuild();
34
+ if (status !== 0) {
35
+ process.exit(status);
36
+ }
package/install/check.js CHANGED
@@ -1,39 +1,10 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  try {
7
- const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
8
-
9
- const buildFromSource = (msg) => {
10
- log(msg);
11
- log('Attempting to build from source via node-gyp');
12
- try {
13
- const addonApi = require('node-addon-api');
14
- log(`Found node-addon-api ${addonApi.version || ''}`);
15
- } catch (err) {
16
- log('Please add node-addon-api to your dependencies');
17
- return;
18
- }
19
- try {
20
- const gyp = require('node-gyp');
21
- log(`Found node-gyp ${gyp().version}`);
22
- } catch (err) {
23
- log('Please add node-gyp to your dependencies');
24
- return;
25
- }
26
- log('See https://sharp.pixelplumbing.com/install#building-from-source');
27
- const status = spawnRebuild();
28
- if (status !== 0) {
29
- process.exit(status);
30
- }
31
- };
32
-
33
- if (useGlobalLibvips(log)) {
34
- buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
35
- } else if (process.env.npm_config_build_from_source) {
36
- buildFromSource('Detected --build-from-source flag');
5
+ const { useGlobalLibvips } = require('../lib/libvips');
6
+ if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
7
+ process.exit(1);
37
8
  }
38
9
  } catch (err) {
39
10
  const summary = err.message.split(/\n/).slice(0, 1);
package/lib/channel.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const is = require('./is');
7
5
 
8
6
  /**
package/lib/colour.js CHANGED
@@ -1,9 +1,7 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
- const color = require('color');
4
+ const color = require('@img/colour');
7
5
  const is = require('./is');
8
6
 
9
7
  /**
@@ -141,7 +139,10 @@ function toColorspace (colorspace) {
141
139
  * @throws {Error} Invalid value
142
140
  */
143
141
  function _getBackgroundColourOption (value) {
144
- if (is.object(value) || is.string(value)) {
142
+ if (
143
+ is.object(value) ||
144
+ (is.string(value) && value.length >= 3 && value.length <= 200)
145
+ ) {
145
146
  const colour = color(value);
146
147
  return [
147
148
  colour.red(),
package/lib/composite.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const is = require('./is');
7
5
 
8
6
  /**
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const util = require('node:util');
7
5
  const stream = require('node:stream');
8
6
  const is = require('./is');
@@ -205,6 +203,7 @@ const debuglog = util.debuglog('sharp');
205
203
  * @throws {Error} Invalid parameters
206
204
  */
207
205
  const Sharp = function (input, options) {
206
+ // biome-ignore lint/complexity/noArguments: constructor factory
208
207
  if (arguments.length === 1 && !is.defined(input)) {
209
208
  throw new Error('Invalid input');
210
209
  }
@@ -353,6 +352,7 @@ const Sharp = function (input, options) {
353
352
  gifProgressive: false,
354
353
  tiffQuality: 80,
355
354
  tiffCompression: 'jpeg',
355
+ tiffBigtiff: false,
356
356
  tiffPredictor: 'horizontal',
357
357
  tiffPyramid: false,
358
358
  tiffMiniswhite: false,
package/lib/index.d.ts CHANGED
@@ -27,7 +27,7 @@
27
27
 
28
28
  /// <reference types="node" />
29
29
 
30
- import { Duplex } from 'stream';
30
+ import type { Duplex } from 'node:stream';
31
31
 
32
32
  //#region Constructor functions
33
33
 
@@ -1460,6 +1460,8 @@ declare namespace sharp {
1460
1460
  quality?: number | undefined;
1461
1461
  /** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
1462
1462
  compression?: string | undefined;
1463
+ /** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
1464
+ bigtiff?: boolean | undefined;
1463
1465
  /** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
1464
1466
  predictor?: string | undefined;
1465
1467
  /** Write an image pyramid (optional, default false) */
package/lib/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const Sharp = require('./constructor');
7
5
  require('./input')(Sharp);
8
6
  require('./resize')(Sharp);
package/lib/input.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const is = require('./is');
7
5
  const sharp = require('./sharp');
8
6
 
@@ -54,7 +52,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
54
52
  const inputDescriptor = {
55
53
  autoOrient: false,
56
54
  failOn: 'warning',
57
- limitInputPixels: Math.pow(0x3FFF, 2),
55
+ limitInputPixels: 0x3FFF ** 2,
58
56
  ignoreIcc: false,
59
57
  unlimited: false,
60
58
  sequentialRead: true
@@ -150,7 +148,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
150
148
  if (is.defined(inputOptions.limitInputPixels)) {
151
149
  if (is.bool(inputOptions.limitInputPixels)) {
152
150
  inputDescriptor.limitInputPixels = inputOptions.limitInputPixels
153
- ? Math.pow(0x3FFF, 2)
151
+ ? 0x3FFF ** 2
154
152
  : 0;
155
153
  } else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {
156
154
  inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;
@@ -513,7 +511,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
513
511
  }
514
512
  }
515
513
  } else if (is.defined(inputOptions)) {
516
- throw new Error('Invalid input options ' + inputOptions);
514
+ throw new Error(`Invalid input options ${inputOptions}`);
517
515
  }
518
516
  return inputDescriptor;
519
517
  }
@@ -525,10 +523,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
525
523
  * @param {string} encoding - unused
526
524
  * @param {Function} callback
527
525
  */
528
- function _write (chunk, encoding, callback) {
529
- /* istanbul ignore else */
526
+ function _write (chunk, _encoding, callback) {
530
527
  if (Array.isArray(this.options.input.buffer)) {
531
- /* istanbul ignore else */
532
528
  if (is.buffer(chunk)) {
533
529
  if (this.options.input.buffer.length === 0) {
534
530
  this.on('finish', () => {
package/lib/is.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  /**
7
5
  * Is this value defined and not null?
8
6
  * @private
package/lib/libvips.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const { spawnSync } = require('node:child_process');
7
5
  const { createHash } = require('node:crypto');
8
6
  const semverCoerce = require('semver/functions/coerce');
@@ -12,13 +10,13 @@ const detectLibc = require('detect-libc');
12
10
 
13
11
  const { config, engines, optionalDependencies } = require('../package.json');
14
12
 
15
- const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || /* istanbul ignore next */
16
- config.libvips;
13
+ /* node:coverage ignore next */
14
+ const minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips;
17
15
  const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version;
18
16
 
19
17
  const prebuiltPlatforms = [
20
18
  'darwin-arm64', 'darwin-x64',
21
- 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-s390x', 'linux-x64',
19
+ 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-x64',
22
20
  'linuxmusl-arm64', 'linuxmusl-x64',
23
21
  'win32-arm64', 'win32-ia32', 'win32-x64'
24
22
  ];
@@ -36,17 +34,16 @@ const log = (item) => {
36
34
  }
37
35
  };
38
36
 
39
- /* istanbul ignore next */
37
+ /* node:coverage ignore next */
40
38
  const runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : '';
41
39
 
42
40
  const runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`;
43
41
 
44
- /* istanbul ignore next */
45
42
  const buildPlatformArch = () => {
43
+ /* node:coverage ignore next 3 */
46
44
  if (isEmscripten()) {
47
45
  return 'wasm32';
48
46
  }
49
- /* eslint camelcase: ["error", { allow: ["^npm_config_"] }] */
50
47
  const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;
51
48
  const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc();
52
49
  return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;
@@ -56,19 +53,19 @@ const buildSharpLibvipsIncludeDir = () => {
56
53
  try {
57
54
  return require(`@revizly/sharp-libvips-dev-${buildPlatformArch()}/include`);
58
55
  } catch {
56
+ /* node:coverage ignore next 5 */
59
57
  try {
60
58
  return require('@revizly/sharp-libvips-dev/include');
61
59
  } catch {}
62
60
  }
63
- /* istanbul ignore next */
64
61
  return '';
65
62
  };
66
63
 
67
64
  const buildSharpLibvipsCPlusPlusDir = () => {
65
+ /* node:coverage ignore next 4 */
68
66
  try {
69
67
  return require('@revizly/sharp-libvips-dev/cplusplus');
70
68
  } catch {}
71
- /* istanbul ignore next */
72
69
  return '';
73
70
  };
74
71
 
@@ -76,16 +73,17 @@ const buildSharpLibvipsLibDir = () => {
76
73
  try {
77
74
  return require(`@revizly/sharp-libvips-dev-${buildPlatformArch()}/lib`);
78
75
  } catch {
76
+ /* node:coverage ignore next 5 */
79
77
  try {
80
78
  return require(`@revizly/sharp-libvips-${buildPlatformArch()}/lib`);
81
79
  } catch {}
82
80
  }
83
- /* istanbul ignore next */
84
81
  return '';
85
82
  };
86
83
 
84
+ /* node:coverage disable */
85
+
87
86
  const isUnsupportedNodeRuntime = () => {
88
- /* istanbul ignore next */
89
87
  if (process.release?.name === 'node' && process.versions) {
90
88
  if (!semverSatisfies(process.versions.node, engines.node)) {
91
89
  return { found: process.versions.node, expected: engines.node };
@@ -93,14 +91,12 @@ const isUnsupportedNodeRuntime = () => {
93
91
  }
94
92
  };
95
93
 
96
- /* istanbul ignore next */
97
94
  const isEmscripten = () => {
98
95
  const { CC } = process.env;
99
- return Boolean(CC && CC.endsWith('/emcc'));
96
+ return Boolean(CC?.endsWith('/emcc'));
100
97
  };
101
98
 
102
99
  const isRosetta = () => {
103
- /* istanbul ignore next */
104
100
  if (process.platform === 'darwin' && process.arch === 'x64') {
105
101
  const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;
106
102
  return (translated || '').trim() === 'sysctl.proc_translated: 1';
@@ -108,6 +104,8 @@ const isRosetta = () => {
108
104
  return false;
109
105
  };
110
106
 
107
+ /* node:coverage enable */
108
+
111
109
  const sha512 = (s) => createHash('sha512').update(s).digest('hex');
112
110
 
113
111
  const yarnLocator = () => {
@@ -121,7 +119,8 @@ const yarnLocator = () => {
121
119
  return '';
122
120
  };
123
121
 
124
- /* istanbul ignore next */
122
+ /* node:coverage disable */
123
+
125
124
  const spawnRebuild = () =>
126
125
  spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {
127
126
  ...spawnSyncOptions,
@@ -137,16 +136,17 @@ const globalLibvipsVersion = () => {
137
136
  PKG_CONFIG_PATH: pkgConfigPath()
138
137
  }
139
138
  }).stdout;
140
- /* istanbul ignore next */
141
139
  return (globalLibvipsVersion || '').trim();
142
140
  } else {
143
141
  return '';
144
142
  }
145
143
  };
146
144
 
147
- /* istanbul ignore next */
145
+ /* node:coverage enable */
146
+
148
147
  const pkgConfigPath = () => {
149
148
  if (process.platform !== 'win32') {
149
+ /* node:coverage ignore next 4 */
150
150
  const brewPkgConfigPath = spawnSync(
151
151
  'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
152
152
  spawnSyncOptions
@@ -178,13 +178,13 @@ const useGlobalLibvips = (logger) => {
178
178
  if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
179
179
  return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger);
180
180
  }
181
- /* istanbul ignore next */
181
+ /* node:coverage ignore next 3 */
182
182
  if (isRosetta()) {
183
183
  return skipSearch(false, 'Rosetta', logger);
184
184
  }
185
185
  const globalVipsVersion = globalLibvipsVersion();
186
- return !!globalVipsVersion && /* istanbul ignore next */
187
- semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);
186
+ /* node:coverage ignore next */
187
+ return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);
188
188
  };
189
189
 
190
190
  module.exports = {
package/lib/operation.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const is = require('./is');
7
5
 
8
6
  /**
package/lib/output.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const path = require('node:path');
7
5
  const is = require('./is');
8
6
  const sharp = require('./sharp');
@@ -845,7 +843,6 @@ function gif (options) {
845
843
  return this._updateFormatOut('gif', options);
846
844
  }
847
845
 
848
- /* istanbul ignore next */
849
846
  /**
850
847
  * Use these JP2 options for output image.
851
848
  *
@@ -880,6 +877,7 @@ function gif (options) {
880
877
  * @throws {Error} Invalid options
881
878
  */
882
879
  function jp2 (options) {
880
+ /* node:coverage ignore next 41 */
883
881
  if (!this.constructor.format.jp2k.output.buffer) {
884
882
  throw errJp2Save();
885
883
  }
@@ -976,6 +974,7 @@ function trySetAnimationOptions (source, target) {
976
974
  * @param {number} [options.quality=80] - quality, integer 1-100
977
975
  * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
978
976
  * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
977
+ * @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)
979
978
  * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
980
979
  * @param {boolean} [options.pyramid=false] - write an image pyramid
981
980
  * @param {boolean} [options.tile=false] - write a tiled tiff
@@ -1054,6 +1053,10 @@ function tiff (options) {
1054
1053
  throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
1055
1054
  }
1056
1055
  }
1056
+ // bigtiff
1057
+ if (is.defined(options.bigtiff)) {
1058
+ this._setBooleanOption('tiffBigtiff', options.bigtiff);
1059
+ }
1057
1060
  // predictor
1058
1061
  if (is.defined(options.predictor)) {
1059
1062
  if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
@@ -1502,7 +1505,6 @@ function _setBooleanOption (key, val) {
1502
1505
  * @private
1503
1506
  */
1504
1507
  function _read () {
1505
- /* istanbul ignore else */
1506
1508
  if (!this.options.streamOut) {
1507
1509
  this.options.streamOut = true;
1508
1510
  const stack = Error();
package/lib/resize.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const is = require('./is');
7
5
 
8
6
  /**
package/lib/sharp.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  // Inspects the runtime environment and exports the relevant sharp.node binary
7
5
 
8
6
  const { familySync, versionSync } = require('detect-libc');
@@ -17,6 +15,8 @@ const paths = [
17
15
  '@revizly/sharp-wasm32/sharp.node'
18
16
  ];
19
17
 
18
+ /* node:coverage disable */
19
+
20
20
  let path, sharp;
21
21
  const errors = [];
22
22
  for (path of paths) {
@@ -24,12 +24,10 @@ for (path of paths) {
24
24
  sharp = require(path);
25
25
  break;
26
26
  } catch (err) {
27
- /* istanbul ignore next */
28
27
  errors.push(err);
29
28
  }
30
29
  }
31
30
 
32
- /* istanbul ignore next */
33
31
  if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {
34
32
  const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
35
33
  err.code = 'Unsupported CPU';
@@ -37,7 +35,6 @@ if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2())
37
35
  sharp = null;
38
36
  }
39
37
 
40
- /* istanbul ignore next */
41
38
  if (sharp) {
42
39
  module.exports = sharp;
43
40
  } else {
@@ -88,7 +85,7 @@ if (sharp) {
88
85
  ` Found ${libcFound}`,
89
86
  ` Requires ${libcRequires}`
90
87
  );
91
- } catch (errEngines) {}
88
+ } catch (_errEngines) {}
92
89
  }
93
90
  if (isLinux && /\/snap\/core[0-9]{2}/.test(messages)) {
94
91
  help.push(
package/lib/utility.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- 'use strict';
5
-
6
4
  const events = require('node:events');
7
5
  const detectLibc = require('detect-libc');
8
6
 
@@ -57,7 +55,7 @@ const interpolators = {
57
55
  let versions = {
58
56
  vips: libvipsVersion.semver
59
57
  };
60
- /* istanbul ignore next */
58
+ /* node:coverage ignore next 15 */
61
59
  if (!libvipsVersion.isGlobal) {
62
60
  if (!libvipsVersion.isWasm) {
63
61
  try {
@@ -75,7 +73,7 @@ if (!libvipsVersion.isGlobal) {
75
73
  }
76
74
  versions.sharp = require('../package.json').version;
77
75
 
78
- /* istanbul ignore next */
76
+ /* node:coverage ignore next 5 */
79
77
  if (versions.heif && format.heif) {
80
78
  // Prebuilt binaries provide AV1
81
79
  format.heif.input.fileSuffix = ['.avif'];
@@ -150,7 +148,7 @@ cache(true);
150
148
  function concurrency (concurrency) {
151
149
  return sharp.concurrency(is.integer(concurrency) ? concurrency : null);
152
150
  }
153
- /* istanbul ignore next */
151
+ /* node:coverage ignore next 7 */
154
152
  if (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {
155
153
  // Reduce default concurrency to 1 when using glibc memory allocator
156
154
  sharp.concurrency(1);
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.34.4-revizly1",
4
+ "version": "0.34.4-revizly11",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -92,14 +92,16 @@
92
92
  "Don Denton <don@happycollision.com>"
93
93
  ],
94
94
  "scripts": {
95
- "install": "node install/check.js",
95
+ "build": "node install/build.js",
96
+ "install": "node install/check.js || npm run build",
96
97
  "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
97
- "test": "npm run test-lint && npm run test-unit && npm run test-licensing && npm run test-types",
98
- "test-lint": "semistandard && cpplint",
99
- "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha",
100
- "test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;LGPL-3.0-or-later;MIT\"",
98
+ "test": "npm run lint && npm run test-unit",
99
+ "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
100
+ "lint-cpp": "cpplint --quiet src/*.h src/*.cc",
101
+ "lint-js": "biome lint",
102
+ "lint-types": "tsd --files ./test/types/sharp.test-d.ts",
101
103
  "test-leak": "./test/leak/leak.sh",
102
- "test-types": "tsd",
104
+ "test-unit": "node --experimental-test-coverage test/unit.mjs",
103
105
  "package-from-local-build": "node npm/from-local-build.js",
104
106
  "package-release-notes": "node npm/release-notes.js",
105
107
  "docs-build": "node docs/build.mjs",
@@ -137,33 +139,30 @@
137
139
  "vips"
138
140
  ],
139
141
  "dependencies": {
140
- "color": "^4.2.3",
141
- "detect-libc": "^2.0.4",
142
- "semver": "^7.7.2"
142
+ "@img/colour": "^1.0.0",
143
+ "detect-libc": "^2.1.2",
144
+ "semver": "^7.7.3"
143
145
  },
144
146
  "optionalDependencies": {
145
- "@revizly/sharp-libvips-linux-arm64": "1.0.21",
146
- "@revizly/sharp-libvips-linux-x64": "1.0.21",
147
- "@revizly/sharp-linux-arm64": "0.34.1-revizly12",
148
- "@revizly/sharp-linux-x64": "0.34.1-revizly12"
147
+ "@revizly/sharp-libvips-linux-arm64": "1.0.24",
148
+ "@revizly/sharp-libvips-linux-x64": "1.0.24",
149
+ "@revizly/sharp-linux-arm64": "0.34.4-revizly8",
150
+ "@revizly/sharp-linux-x64": "0.34.4-revizly8"
149
151
  },
150
152
  "devDependencies": {
151
- "@emnapi/runtime": "^1.4.5",
152
- "@revizly/sharp-libvips-dev": "1.0.21",
153
+ "@biomejs/biome": "^2.2.6",
154
+ "@cpplint/cli": "^0.1.0",
155
+ "@emnapi/runtime": "^1.5.0",
156
+ "@revizly/sharp-libvips-dev": "1.0.24",
153
157
  "@types/node": "*",
154
- "cc": "^3.0.1",
155
- "emnapi": "^1.4.5",
158
+ "emnapi": "^1.5.0",
156
159
  "exif-reader": "^2.0.2",
157
160
  "extract-zip": "^2.0.1",
158
161
  "icc": "^3.0.0",
159
- "jsdoc-to-markdown": "^9.1.2",
160
- "license-checker": "^25.0.1",
161
- "mocha": "^11.7.1",
162
+ "jsdoc-to-markdown": "^9.1.3",
162
163
  "node-addon-api": "^8.5.0",
163
- "node-gyp": "^11.4.1",
164
- "nyc": "^17.1.0",
165
- "semistandard": "^17.0.0",
166
- "tar-fs": "^3.1.0",
164
+ "node-gyp": "^11.5.0",
165
+ "tar-fs": "^3.1.1",
167
166
  "tsd": "^0.33.0"
168
167
  },
169
168
  "license": "Apache-2.0",
@@ -171,28 +170,15 @@
171
170
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
172
171
  },
173
172
  "config": {
174
- "libvips": ">=8.17.1"
173
+ "libvips": ">=8.17.2"
175
174
  },
176
175
  "funding": {
177
176
  "url": "https://opencollective.com/libvips"
178
177
  },
179
- "semistandard": {
180
- "env": [
181
- "mocha"
182
- ]
183
- },
184
178
  "cc": {
185
179
  "linelength": "120",
186
180
  "filter": [
187
181
  "build/include"
188
182
  ]
189
- },
190
- "nyc": {
191
- "include": [
192
- "lib"
193
- ]
194
- },
195
- "tsd": {
196
- "directory": "test/types/"
197
183
  }
198
184
  }
package/src/binding.gyp CHANGED
@@ -168,6 +168,7 @@
168
168
  # Ensure runtime linking is relative to sharp.node
169
169
  '-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
170
170
  '-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
171
+ '-Wl,-rpath,\'@loader_path/../node_modules/@revizly/sharp-libvips-<(platform_and_arch)/lib\'',
171
172
  '-Wl,-rpath,\'@loader_path/../../node_modules/@revizly/sharp-libvips-<(platform_and_arch)/lib\'',
172
173
  '-Wl,-rpath,\'@loader_path/../../../node_modules/@revizly/sharp-libvips-<(platform_and_arch)/lib\'',
173
174
  '-Wl,-rpath,\'@loader_path/../../../../../@revizly-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@revizly/sharp-libvips-<(platform_and_arch)/lib\''
package/src/common.cc CHANGED
@@ -1,18 +1,20 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ #include <algorithm>
4
5
  #include <cstdlib>
6
+ #include <map>
7
+ #include <mutex>
8
+ #include <queue>
5
9
  #include <string>
6
- #include <string.h>
10
+ #include <tuple>
11
+ #include <utility>
7
12
  #include <vector>
8
- #include <queue>
9
- #include <map>
10
- #include <mutex> // NOLINT(build/c++11)
11
13
 
12
14
  #include <napi.h>
13
15
  #include <vips/vips8>
14
16
 
15
- #include "common.h"
17
+ #include "./common.h"
16
18
 
17
19
  using vips::VImage;
18
20
 
@@ -396,6 +398,7 @@ namespace sharp {
396
398
  imageType == ImageType::JPEG ||
397
399
  imageType == ImageType::PNG ||
398
400
  imageType == ImageType::SVG ||
401
+ imageType == ImageType::TIFF ||
399
402
  imageType == ImageType::HEIF;
400
403
  }
401
404
 
@@ -420,14 +423,14 @@ namespace sharp {
420
423
  ->set("high_bitdepth", descriptor->svgHighBitdepth);
421
424
  break;
422
425
  case ImageType::TIFF:
423
- option->set("tiffSubifd", descriptor->tiffSubifd);
426
+ option->set("subifd", descriptor->tiffSubifd);
424
427
  break;
425
428
  case ImageType::PDF:
426
429
  option->set("dpi", descriptor->density)
427
430
  ->set("background", descriptor->pdfBackground);
428
431
  break;
429
432
  case ImageType::OPENSLIDE:
430
- option->set("openSlideLevel", descriptor->openSlideLevel);
433
+ option->set("level", descriptor->openSlideLevel);
431
434
  break;
432
435
  case ImageType::JP2:
433
436
  option->set("oneshot", descriptor->jp2Oneshot);
package/src/common.h CHANGED
@@ -4,10 +4,11 @@
4
4
  #ifndef SRC_COMMON_H_
5
5
  #define SRC_COMMON_H_
6
6
 
7
+ #include <atomic>
7
8
  #include <string>
8
9
  #include <tuple>
10
+ #include <utility>
9
11
  #include <vector>
10
- #include <atomic>
11
12
 
12
13
  #include <napi.h>
13
14
  #include <vips/vips8>
@@ -16,8 +17,8 @@
16
17
 
17
18
  #if (VIPS_MAJOR_VERSION < 8) || \
18
19
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 17) || \
19
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 17 && VIPS_MICRO_VERSION < 1)
20
- #error "libvips version 8.17.1+ is required - please see https://sharp.pixelplumbing.com/install"
20
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 17 && VIPS_MICRO_VERSION < 2)
21
+ #error "libvips version 8.17.2+ is required - please see https://sharp.pixelplumbing.com/install"
21
22
  #endif
22
23
 
23
24
  #if defined(__has_include)
@@ -30,7 +31,7 @@ using vips::VImage;
30
31
 
31
32
  namespace sharp {
32
33
 
33
- struct InputDescriptor { // NOLINT(runtime/indentation_namespace)
34
+ struct InputDescriptor {
34
35
  std::string name;
35
36
  std::string file;
36
37
  bool autoOrient;
package/src/metadata.cc CHANGED
@@ -1,15 +1,17 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ #include <cmath>
4
5
  #include <numeric>
6
+ #include <string>
7
+ #include <utility>
5
8
  #include <vector>
6
- #include <cmath>
7
9
 
8
10
  #include <napi.h>
9
11
  #include <vips/vips8>
10
12
 
11
- #include "common.h"
12
- #include "metadata.h"
13
+ #include "./common.h"
14
+ #include "./metadata.h"
13
15
 
14
16
  static void* readPNGComment(VipsImage *image, const char *field, GValue *value, void *p);
15
17
 
@@ -261,11 +263,11 @@ class MetadataWorker : public Napi::AsyncWorker {
261
263
  info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
262
264
  }
263
265
  if (baton->xmpLength > 0) {
264
- info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
265
266
  if (g_utf8_validate(static_cast<char const *>(baton->xmp), baton->xmpLength, nullptr)) {
266
267
  info.Set("xmpAsString",
267
268
  Napi::String::New(env, static_cast<char const *>(baton->xmp), baton->xmpLength));
268
269
  }
270
+ info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
269
271
  }
270
272
  if (baton->tifftagPhotoshopLength > 0) {
271
273
  info.Set("tifftagPhotoshop",
package/src/metadata.h CHANGED
@@ -5,6 +5,7 @@
5
5
  #define SRC_METADATA_H_
6
6
 
7
7
  #include <string>
8
+ #include <vector>
8
9
  #include <napi.h>
9
10
 
10
11
  #include "./common.h"
package/src/operations.cc CHANGED
@@ -8,8 +8,8 @@
8
8
  #include <vector>
9
9
  #include <vips/vips8>
10
10
 
11
- #include "common.h"
12
- #include "operations.h"
11
+ #include "./common.h"
12
+ #include "./operations.h"
13
13
 
14
14
  using vips::VImage;
15
15
  using vips::VError;
package/src/operations.h CHANGED
@@ -8,6 +8,7 @@
8
8
  #include <functional>
9
9
  #include <memory>
10
10
  #include <tuple>
11
+ #include <vector>
11
12
  #include <vips/vips8>
12
13
 
13
14
  using vips::VImage;
package/src/pipeline.cc CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include <algorithm>
5
5
  #include <cmath>
6
- #include <filesystem>
6
+ #include <filesystem> // NOLINT(build/c++17)
7
7
  #include <map>
8
8
  #include <memory>
9
9
  #include <numeric>
@@ -17,9 +17,9 @@
17
17
  #include <vips/vips8>
18
18
  #include <napi.h>
19
19
 
20
- #include "common.h"
21
- #include "operations.h"
22
- #include "pipeline.h"
20
+ #include "./common.h"
21
+ #include "./operations.h"
22
+ #include "./pipeline.h"
23
23
 
24
24
  class PipelineWorker : public Napi::AsyncWorker {
25
25
  public:
@@ -1009,6 +1009,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1009
1009
  ->set("Q", baton->tiffQuality)
1010
1010
  ->set("bitdepth", baton->tiffBitdepth)
1011
1011
  ->set("compression", baton->tiffCompression)
1012
+ ->set("bigtiff", baton->tiffBigtiff)
1012
1013
  ->set("miniswhite", baton->tiffMiniswhite)
1013
1014
  ->set("predictor", baton->tiffPredictor)
1014
1015
  ->set("pyramid", baton->tiffPyramid)
@@ -1211,6 +1212,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1211
1212
  ->set("Q", baton->tiffQuality)
1212
1213
  ->set("bitdepth", baton->tiffBitdepth)
1213
1214
  ->set("compression", baton->tiffCompression)
1215
+ ->set("bigtiff", baton->tiffBigtiff)
1214
1216
  ->set("miniswhite", baton->tiffMiniswhite)
1215
1217
  ->set("predictor", baton->tiffPredictor)
1216
1218
  ->set("pyramid", baton->tiffPyramid)
@@ -1276,7 +1278,12 @@ class PipelineWorker : public Napi::AsyncWorker {
1276
1278
  if (what && what[0]) {
1277
1279
  (baton->err).append(what);
1278
1280
  } else {
1279
- (baton->err).append("Unknown error");
1281
+ if (baton->input->failOn == VIPS_FAIL_ON_WARNING) {
1282
+ (baton->err).append("Warning treated as error due to failOn setting");
1283
+ baton->errUseWarning = true;
1284
+ } else {
1285
+ (baton->err).append("Unknown error");
1286
+ }
1280
1287
  }
1281
1288
  }
1282
1289
  // Clean up libvips' per-request data and threads
@@ -1291,7 +1298,11 @@ class PipelineWorker : public Napi::AsyncWorker {
1291
1298
  // Handle warnings
1292
1299
  std::string warning = sharp::VipsWarningPop();
1293
1300
  while (!warning.empty()) {
1294
- debuglog.Call(Receiver().Value(), { Napi::String::New(env, warning) });
1301
+ if (baton->errUseWarning) {
1302
+ (baton->err).append("\n").append(warning);
1303
+ } else {
1304
+ debuglog.Call(Receiver().Value(), { Napi::String::New(env, warning) });
1305
+ }
1295
1306
  warning = sharp::VipsWarningPop();
1296
1307
  }
1297
1308
 
@@ -1750,6 +1761,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
1750
1761
  baton->gifReuse = sharp::AttrAsBool(options, "gifReuse");
1751
1762
  baton->gifProgressive = sharp::AttrAsBool(options, "gifProgressive");
1752
1763
  baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality");
1764
+ baton->tiffBigtiff = sharp::AttrAsBool(options, "tiffBigtiff");
1753
1765
  baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
1754
1766
  baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
1755
1767
  baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
package/src/pipeline.h CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  #include <memory>
8
8
  #include <string>
9
- #include <vector>
10
9
  #include <unordered_map>
10
+ #include <vector>
11
11
 
12
12
  #include <napi.h>
13
13
  #include <vips/vips8>
@@ -175,6 +175,7 @@ struct PipelineBaton {
175
175
  bool gifProgressive;
176
176
  int tiffQuality;
177
177
  VipsForeignTiffCompression tiffCompression;
178
+ bool tiffBigtiff;
178
179
  VipsForeignTiffPredictor tiffPredictor;
179
180
  bool tiffPyramid;
180
181
  int tiffBitdepth;
@@ -197,6 +198,7 @@ struct PipelineBaton {
197
198
  bool jxlLossless;
198
199
  VipsBandFormat rawDepth;
199
200
  std::string err;
201
+ bool errUseWarning;
200
202
  int keepMetadata;
201
203
  int withMetadataOrientation;
202
204
  double withMetadataDensity;
@@ -350,6 +352,7 @@ struct PipelineBaton {
350
352
  gifProgressive(false),
351
353
  tiffQuality(80),
352
354
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
355
+ tiffBigtiff(false),
353
356
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
354
357
  tiffPyramid(false),
355
358
  tiffBitdepth(8),
@@ -371,6 +374,7 @@ struct PipelineBaton {
371
374
  jxlEffort(7),
372
375
  jxlLossless(false),
373
376
  rawDepth(VIPS_FORMAT_UCHAR),
377
+ errUseWarning(false),
374
378
  keepMetadata(0),
375
379
  withMetadataOrientation(-1),
376
380
  withMetadataDensity(0.0),
package/src/sharp.cc CHANGED
@@ -1,16 +1,16 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- #include <mutex> // NOLINT(build/c++11)
4
+ #include <mutex>
5
5
 
6
6
  #include <napi.h>
7
7
  #include <vips/vips8>
8
8
 
9
- #include "common.h"
10
- #include "metadata.h"
11
- #include "pipeline.h"
12
- #include "utilities.h"
13
- #include "stats.h"
9
+ #include "./common.h"
10
+ #include "./metadata.h"
11
+ #include "./pipeline.h"
12
+ #include "./stats.h"
13
+ #include "./utilities.h"
14
14
 
15
15
  Napi::Object init(Napi::Env env, Napi::Object exports) {
16
16
  static std::once_flag sharp_vips_init_once;
package/src/stats.cc CHANGED
@@ -1,15 +1,16 @@
1
1
  // Copyright 2013 Lovell Fuller and others.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ #include <iostream>
4
5
  #include <numeric>
6
+ #include <string>
5
7
  #include <vector>
6
- #include <iostream>
7
8
 
8
9
  #include <napi.h>
9
10
  #include <vips/vips8>
10
11
 
11
- #include "common.h"
12
- #include "stats.h"
12
+ #include "./common.h"
13
+ #include "./stats.h"
13
14
 
14
15
  class StatsWorker : public Napi::AsyncWorker {
15
16
  public:
package/src/stats.h CHANGED
@@ -5,6 +5,7 @@
5
5
  #define SRC_STATS_H_
6
6
 
7
7
  #include <string>
8
+ #include <vector>
8
9
  #include <napi.h>
9
10
 
10
11
  #include "./common.h"
@@ -24,7 +25,7 @@ struct ChannelStats {
24
25
 
25
26
  ChannelStats(int minVal, int maxVal, double sumVal, double squaresSumVal,
26
27
  double meanVal, double stdevVal, int minXVal, int minYVal, int maxXVal, int maxYVal):
27
- min(minVal), max(maxVal), sum(sumVal), squaresSum(squaresSumVal),
28
+ min(minVal), max(maxVal), sum(sumVal), squaresSum(squaresSumVal), // NOLINT(build/include_what_you_use)
28
29
  mean(meanVal), stdev(stdevVal), minX(minXVal), minY(minYVal), maxX(maxXVal), maxY(maxYVal) {}
29
30
  };
30
31
 
package/src/utilities.cc CHANGED
@@ -2,16 +2,16 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  #include <cmath>
5
- #include <string>
6
5
  #include <cstdio>
6
+ #include <string>
7
7
 
8
8
  #include <napi.h>
9
9
  #include <vips/vips8>
10
10
  #include <vips/vector.h>
11
11
 
12
- #include "common.h"
13
- #include "operations.h"
14
- #include "utilities.h"
12
+ #include "./common.h"
13
+ #include "./operations.h"
14
+ #include "./utilities.h"
15
15
 
16
16
  /*
17
17
  Get and set cache limits