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