@revizly/sharp 0.35.0-revizly17 → 0.35.0-revizly18
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/lib/constructor.js +1 -1
- package/lib/index.d.ts +23 -21
- package/lib/libvips.js +15 -7
- package/lib/output.js +24 -0
- package/lib/sharp.js +60 -20
- package/package.json +11 -10
- package/src/metadata.cc +3 -3
- package/src/pipeline.cc +7 -7
- package/src/stats.cc +3 -3
package/lib/constructor.js
CHANGED
|
@@ -153,7 +153,7 @@ const queueListener = (queueLength) => {
|
|
|
153
153
|
* @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).
|
|
154
154
|
* @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.
|
|
155
155
|
* @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.
|
|
156
|
-
* @param {number} [options.density=72] -
|
|
156
|
+
* @param {number} [options.density=72] - The DPI at which to render SVG and PDF images, in the range 1 to 100000.
|
|
157
157
|
* @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.
|
|
158
158
|
* @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.
|
|
159
159
|
* @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.
|
package/lib/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
/// <reference types="node" />
|
|
29
29
|
|
|
30
30
|
import type { Duplex } from 'node:stream';
|
|
31
|
+
import { ColorLike } from '@img/colour';
|
|
31
32
|
|
|
32
33
|
//#region Constructor functions
|
|
33
34
|
|
|
@@ -234,7 +235,7 @@ declare namespace sharp {
|
|
|
234
235
|
* @param tint Parsed by the color module.
|
|
235
236
|
* @returns A sharp instance that can be used to chain operations
|
|
236
237
|
*/
|
|
237
|
-
tint(tint:
|
|
238
|
+
tint(tint: ColorLike): Sharp;
|
|
238
239
|
|
|
239
240
|
/**
|
|
240
241
|
* Convert to 8-bit greyscale; 256 shades of grey.
|
|
@@ -684,6 +685,14 @@ declare namespace sharp {
|
|
|
684
685
|
*/
|
|
685
686
|
toUint8Array(): Promise<{ data: Uint8Array; info: OutputInfo }>;
|
|
686
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Set output density (DPI) in EXIF metadata.
|
|
690
|
+
* @param density Density in dots per inch (DPI).
|
|
691
|
+
* @returns A sharp instance that can be used to chain operations
|
|
692
|
+
* @throws {Error} Invalid parameters
|
|
693
|
+
*/
|
|
694
|
+
withDensity(density: number): Sharp;
|
|
695
|
+
|
|
687
696
|
/**
|
|
688
697
|
* Keep all EXIF metadata from the input image in the output image.
|
|
689
698
|
* EXIF metadata is unsupported for TIFF output.
|
|
@@ -993,7 +1002,7 @@ declare namespace sharp {
|
|
|
993
1002
|
unlimited?: boolean | undefined;
|
|
994
1003
|
/** Set this to false to use random access rather than sequential read. Some operations will do this automatically. */
|
|
995
1004
|
sequentialRead?: boolean | undefined;
|
|
996
|
-
/**
|
|
1005
|
+
/** The DPI at which to render SVG and PDF images, in the range 1 to 100000. (optional, default 72) */
|
|
997
1006
|
density?: number | undefined;
|
|
998
1007
|
/** Should the embedded ICC profile, if any, be ignored. */
|
|
999
1008
|
ignoreIcc?: boolean | undefined;
|
|
@@ -1014,7 +1023,7 @@ declare namespace sharp {
|
|
|
1014
1023
|
/** @deprecated Use {@link SharpOptions.tiff} instead */
|
|
1015
1024
|
subifd?: number | undefined;
|
|
1016
1025
|
/** @deprecated Use {@link SharpOptions.pdf} instead */
|
|
1017
|
-
pdfBackground?:
|
|
1026
|
+
pdfBackground?: ColorLike | undefined;
|
|
1018
1027
|
/** @deprecated Use {@link SharpOptions.openSlide} instead */
|
|
1019
1028
|
level?: number | undefined;
|
|
1020
1029
|
/** Set to `true` to read all frames/pages of an animated image (equivalent of setting `pages` to `-1`). (optional, default false) */
|
|
@@ -1073,7 +1082,7 @@ declare namespace sharp {
|
|
|
1073
1082
|
/** Number of bands, 3 for RGB, 4 for RGBA */
|
|
1074
1083
|
channels: CreateChannels;
|
|
1075
1084
|
/** Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha. */
|
|
1076
|
-
background:
|
|
1085
|
+
background: ColorLike;
|
|
1077
1086
|
/** Describes a noise to be created. */
|
|
1078
1087
|
noise?: Noise | undefined;
|
|
1079
1088
|
/** The height of each page/frame for animated images, must be an integral factor of the overall image height. */
|
|
@@ -1120,7 +1129,7 @@ declare namespace sharp {
|
|
|
1120
1129
|
/** Space between images, in pixels. */
|
|
1121
1130
|
shim?: number | undefined;
|
|
1122
1131
|
/** Background colour. */
|
|
1123
|
-
background?:
|
|
1132
|
+
background?: ColorLike | undefined;
|
|
1124
1133
|
/** Horizontal alignment. */
|
|
1125
1134
|
halign?: HorizontalAlignment | undefined;
|
|
1126
1135
|
/** Vertical alignment. */
|
|
@@ -1141,7 +1150,7 @@ declare namespace sharp {
|
|
|
1141
1150
|
|
|
1142
1151
|
interface PdfInputOptions {
|
|
1143
1152
|
/** Background colour to use when PDF is partially transparent. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick. */
|
|
1144
|
-
background?:
|
|
1153
|
+
background?: ColorLike | undefined;
|
|
1145
1154
|
}
|
|
1146
1155
|
|
|
1147
1156
|
interface OpenSlideInputOptions {
|
|
@@ -1510,7 +1519,7 @@ declare namespace sharp {
|
|
|
1510
1519
|
|
|
1511
1520
|
interface RotateOptions {
|
|
1512
1521
|
/** parsed by the color module to extract values for red, green, blue and alpha. (optional, default "#000000") */
|
|
1513
|
-
background?:
|
|
1522
|
+
background?: ColorLike | undefined;
|
|
1514
1523
|
}
|
|
1515
1524
|
|
|
1516
1525
|
type Precision = 'integer' | 'float' | 'approximate';
|
|
@@ -1526,7 +1535,7 @@ declare namespace sharp {
|
|
|
1526
1535
|
|
|
1527
1536
|
interface FlattenOptions {
|
|
1528
1537
|
/** background colour, parsed by the color module, defaults to black. (optional, default {r:0,g:0,b:0}) */
|
|
1529
|
-
background?:
|
|
1538
|
+
background?: ColorLike | undefined;
|
|
1530
1539
|
}
|
|
1531
1540
|
|
|
1532
1541
|
interface NegateOptions {
|
|
@@ -1551,7 +1560,7 @@ declare namespace sharp {
|
|
|
1551
1560
|
/** Position, gravity or strategy to use when fit is cover or contain. (optional, default 'centre') */
|
|
1552
1561
|
position?: number | string | undefined;
|
|
1553
1562
|
/** Background colour when using a fit of contain, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1554
|
-
background?:
|
|
1563
|
+
background?: ColorLike | undefined;
|
|
1555
1564
|
/** The kernel to use for image reduction. (optional, default 'lanczos3') */
|
|
1556
1565
|
kernel?: keyof KernelEnum | undefined;
|
|
1557
1566
|
/** Do not enlarge if the width or height are already less than the specified dimensions, equivalent to GraphicsMagick's > geometry option. (optional, default false) */
|
|
@@ -1594,14 +1603,14 @@ declare namespace sharp {
|
|
|
1594
1603
|
/** single pixel count to right edge (optional, default 0) */
|
|
1595
1604
|
right?: number | undefined;
|
|
1596
1605
|
/** background colour, parsed by the color module, defaults to black without transparency. (optional, default {r:0,g:0,b:0,alpha:1}) */
|
|
1597
|
-
background?:
|
|
1606
|
+
background?: ColorLike | undefined;
|
|
1598
1607
|
/** how the extension is done, one of: "background", "copy", "repeat", "mirror" (optional, default `'background'`) */
|
|
1599
1608
|
extendWith?: ExtendWith | undefined;
|
|
1600
1609
|
}
|
|
1601
1610
|
|
|
1602
1611
|
interface TrimOptions {
|
|
1603
1612
|
/** Background colour, parsed by the color module, defaults to that of the top-left pixel. (optional) */
|
|
1604
|
-
background?:
|
|
1613
|
+
background?: ColorLike | undefined;
|
|
1605
1614
|
/** Allowed difference from the above colour, a positive number. (optional, default 10) */
|
|
1606
1615
|
threshold?: number | undefined;
|
|
1607
1616
|
/** Does the input more closely resemble line art (e.g. vector) rather than being photographic? (optional, default false) */
|
|
@@ -1617,15 +1626,8 @@ declare namespace sharp {
|
|
|
1617
1626
|
/** 1 for grayscale, 2 for grayscale + alpha, 3 for sRGB, 4 for CMYK or RGBA */
|
|
1618
1627
|
type Channels = 1 | 2 | 3 | 4;
|
|
1619
1628
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
g?: number | undefined;
|
|
1623
|
-
b?: number | undefined;
|
|
1624
|
-
alpha?: number | undefined;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
type Colour = string | RGBA;
|
|
1628
|
-
type Color = Colour;
|
|
1629
|
+
type Colour = ColorLike;
|
|
1630
|
+
type Color = ColorLike;
|
|
1629
1631
|
|
|
1630
1632
|
interface Kernel {
|
|
1631
1633
|
/** width of the kernel in pixels. */
|
|
@@ -1691,7 +1693,7 @@ declare namespace sharp {
|
|
|
1691
1693
|
/** Tile angle of rotation, must be a multiple of 90. (optional, default 0) */
|
|
1692
1694
|
angle?: number | undefined;
|
|
1693
1695
|
/** background colour, parsed by the color module, defaults to white without transparency. (optional, default {r:255,g:255,b:255,alpha:1}) */
|
|
1694
|
-
background?:
|
|
1696
|
+
background?: ColorLike | undefined;
|
|
1695
1697
|
/** How deep to make the pyramid, possible values are "onepixel", "onetile" or "one" (default based on layout) */
|
|
1696
1698
|
depth?: string | undefined;
|
|
1697
1699
|
/** Threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images */
|
package/lib/libvips.js
CHANGED
|
@@ -18,7 +18,8 @@ const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).versio
|
|
|
18
18
|
|
|
19
19
|
const prebuiltPlatforms = [
|
|
20
20
|
'darwin-arm64', 'darwin-x64',
|
|
21
|
-
'
|
|
21
|
+
'freebsd-arm64', 'freebsd-x64',
|
|
22
|
+
'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-wasm32', 'linux-x64',
|
|
22
23
|
'linuxmusl-arm64', 'linuxmusl-x64',
|
|
23
24
|
'win32-arm64', 'win32-ia32', 'win32-x64'
|
|
24
25
|
];
|
|
@@ -144,17 +145,24 @@ const globalLibvipsVersion = () => {
|
|
|
144
145
|
}
|
|
145
146
|
};
|
|
146
147
|
|
|
148
|
+
const getBrewPkgConfigPath = () => {
|
|
149
|
+
try {
|
|
150
|
+
const brewPrefix = (spawnSync('brew', ['--prefix'], { encoding: 'utf8' }).stdout || '').trim();
|
|
151
|
+
if (brewPrefix) {
|
|
152
|
+
return `${brewPrefix}/lib/pkgconfig`;
|
|
153
|
+
}
|
|
154
|
+
} catch (_err) {
|
|
155
|
+
// ignore
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
};
|
|
159
|
+
|
|
147
160
|
/* node:coverage enable */
|
|
148
161
|
|
|
149
162
|
const pkgConfigPath = () => {
|
|
150
163
|
if (process.platform !== 'win32') {
|
|
151
|
-
/* node:coverage ignore next 4 */
|
|
152
|
-
const brewPkgConfigPath = spawnSync(
|
|
153
|
-
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
|
|
154
|
-
spawnSyncOptions
|
|
155
|
-
).stdout || '';
|
|
156
164
|
return [
|
|
157
|
-
|
|
165
|
+
getBrewPkgConfigPath(),
|
|
158
166
|
process.env.PKG_CONFIG_PATH,
|
|
159
167
|
'/usr/local/lib/pkgconfig',
|
|
160
168
|
'/usr/lib/pkgconfig',
|
package/lib/output.js
CHANGED
|
@@ -199,6 +199,29 @@ function toUint8Array () {
|
|
|
199
199
|
return this._pipeline(null, stack);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Set output density (DPI) in EXIF metadata.
|
|
204
|
+
*
|
|
205
|
+
* @since 0.35.0
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* const data = await sharp(input)
|
|
209
|
+
* .withDensity(96)
|
|
210
|
+
* .toBuffer();
|
|
211
|
+
*
|
|
212
|
+
* @param {number} density Number of pixels per inch (DPI).
|
|
213
|
+
* @returns {Sharp}
|
|
214
|
+
* @throws {Error} Invalid parameters
|
|
215
|
+
*/
|
|
216
|
+
function withDensity (density) {
|
|
217
|
+
if (is.number(density) && density > 0) {
|
|
218
|
+
this.options.withMetadataDensity = density;
|
|
219
|
+
} else {
|
|
220
|
+
throw is.invalidParameterError('density', 'positive number', density);
|
|
221
|
+
}
|
|
222
|
+
return this.keepExif();
|
|
223
|
+
}
|
|
224
|
+
|
|
202
225
|
/**
|
|
203
226
|
* Keep all EXIF metadata from the input image in the output image.
|
|
204
227
|
*
|
|
@@ -1712,6 +1735,7 @@ module.exports = (Sharp) => {
|
|
|
1712
1735
|
toFile,
|
|
1713
1736
|
toBuffer,
|
|
1714
1737
|
toUint8Array,
|
|
1738
|
+
withDensity,
|
|
1715
1739
|
keepExif,
|
|
1716
1740
|
withExif,
|
|
1717
1741
|
withExifMerge,
|
package/lib/sharp.js
CHANGED
|
@@ -11,31 +11,72 @@ const { version } = require('../package.json');
|
|
|
11
11
|
const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
|
|
12
12
|
const runtimePlatform = runtimePlatformArch();
|
|
13
13
|
|
|
14
|
-
const paths = [
|
|
15
|
-
`../src/build/Release/sharp-${runtimePlatform}-${version}.node`,
|
|
16
|
-
`../src/build/Release/sharp-wasm32-${version}.node`,
|
|
17
|
-
`@revizly/sharp-${runtimePlatform}/sharp.node`,
|
|
18
|
-
'@revizly/sharp-wasm32/sharp.node'
|
|
19
|
-
];
|
|
20
|
-
|
|
21
14
|
/* node:coverage disable */
|
|
22
15
|
|
|
23
|
-
|
|
16
|
+
const prebuiltBinaryForRuntime = () => {
|
|
17
|
+
switch (runtimePlatform) {
|
|
18
|
+
case 'darwin-arm64':
|
|
19
|
+
return require('@revizly/sharp-darwin-arm64/sharp.node');
|
|
20
|
+
case 'darwin-x64':
|
|
21
|
+
return require('@revizly/sharp-darwin-x64/sharp.node');
|
|
22
|
+
case 'linux-arm':
|
|
23
|
+
return require('@revizly/sharp-linux-arm/sharp.node');
|
|
24
|
+
case 'linux-arm64':
|
|
25
|
+
return require('@revizly/sharp-linux-arm64/sharp.node');
|
|
26
|
+
case 'linux-ppc64':
|
|
27
|
+
return require('@revizly/sharp-linux-ppc64/sharp.node');
|
|
28
|
+
case 'linux-riscv64':
|
|
29
|
+
return require('@revizly/sharp-linux-riscv64/sharp.node');
|
|
30
|
+
case 'linux-s390x':
|
|
31
|
+
return require('@revizly/sharp-linux-s390x/sharp.node');
|
|
32
|
+
case 'linux-x64':
|
|
33
|
+
return require('@revizly/sharp-linux-x64/sharp.node');
|
|
34
|
+
case 'linuxmusl-arm64':
|
|
35
|
+
return require('@revizly/sharp-linuxmusl-arm64/sharp.node') ;
|
|
36
|
+
case 'linuxmusl-x64':
|
|
37
|
+
return require('@revizly/sharp-linuxmusl-x64/sharp.node');
|
|
38
|
+
case 'win32-arm64':
|
|
39
|
+
return require('@revizly/sharp-win32-arm64/sharp.node');
|
|
40
|
+
case 'win32-ia32':
|
|
41
|
+
return require('@revizly/sharp-win32-ia32/sharp.node');
|
|
42
|
+
case 'win32-x64':
|
|
43
|
+
return require('@revizly/sharp-win32-x64/sharp.node');
|
|
44
|
+
case 'freebsd-arm64':
|
|
45
|
+
case 'freebsd-x64':
|
|
46
|
+
return require('@revizly/sharp-freebsd-wasm32/sharp.node');
|
|
47
|
+
case 'linux-wasm32':
|
|
48
|
+
return require('@revizly/sharp-webcontainers-wasm32/sharp.node');
|
|
49
|
+
default:
|
|
50
|
+
return require('@revizly/sharp-wasm32/sharp.node');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let sharp;
|
|
24
55
|
const errors = [];
|
|
25
|
-
|
|
56
|
+
try {
|
|
57
|
+
sharp = require(`../src/build/Release/sharp-${runtimePlatform}-${version}.node`);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
errors.push(err);
|
|
60
|
+
}
|
|
61
|
+
if (!sharp) {
|
|
26
62
|
try {
|
|
27
|
-
sharp = require(
|
|
28
|
-
break;
|
|
63
|
+
sharp = require(`../src/build/Release/sharp-wasm32-${version}.node`);
|
|
29
64
|
} catch (err) {
|
|
30
65
|
errors.push(err);
|
|
31
66
|
}
|
|
32
67
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
68
|
+
if (!sharp) {
|
|
69
|
+
try {
|
|
70
|
+
sharp = prebuiltBinaryForRuntime();
|
|
71
|
+
if (['linux-x64', 'linuxmusl-x64'].includes(runtimePlatform) && !sharp._isUsingX64V2()) {
|
|
72
|
+
const err = new Error('Prebuilt binaries for Linux x64 require v2 microarchitecture');
|
|
73
|
+
err.code = 'Unsupported CPU';
|
|
74
|
+
errors.push(err);
|
|
75
|
+
sharp = null;
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
errors.push(err);
|
|
79
|
+
}
|
|
39
80
|
}
|
|
40
81
|
|
|
41
82
|
if (sharp) {
|
|
@@ -74,9 +115,8 @@ if (sharp) {
|
|
|
74
115
|
help.push(
|
|
75
116
|
`- Manually install libvips >= ${minimumLibvipsVersion}`,
|
|
76
117
|
' See https://sharp.pixelplumbing.com/install#building-from-source',
|
|
77
|
-
'- Add
|
|
78
|
-
' npm install
|
|
79
|
-
' npm install @revizly/sharp-wasm32'
|
|
118
|
+
'- Add WebAssembly-based dependencies:',
|
|
119
|
+
' npm install sharp @revizly/sharp-wasm32'
|
|
80
120
|
);
|
|
81
121
|
}
|
|
82
122
|
if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revizly/sharp",
|
|
3
3
|
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
|
4
|
-
"version": "0.35.0-
|
|
4
|
+
"version": "0.35.0-revizly18",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"test-leak": "./test/leak/leak.sh",
|
|
104
104
|
"test-unit": "node --experimental-test-coverage test/unit.mjs",
|
|
105
105
|
"package-from-local-build": "node npm/from-local-build.js",
|
|
106
|
+
"package-wasm-wrappers": "node npm/wasm-wrappers.js",
|
|
106
107
|
"package-release-notes": "node npm/release-notes.js",
|
|
107
108
|
"docs-build": "node docs/build.mjs",
|
|
108
109
|
"docs-serve": "cd docs && npm start",
|
|
@@ -139,28 +140,28 @@
|
|
|
139
140
|
"vips"
|
|
140
141
|
],
|
|
141
142
|
"dependencies": {
|
|
142
|
-
"@img/colour": "^1.
|
|
143
|
+
"@img/colour": "^1.1.0",
|
|
143
144
|
"detect-libc": "^2.1.2",
|
|
144
|
-
"semver": "^7.7.
|
|
145
|
+
"semver": "^7.7.4"
|
|
145
146
|
},
|
|
146
147
|
"optionalDependencies": {
|
|
147
|
-
"@revizly/sharp-libvips-linux-arm64": "1.0.
|
|
148
|
-
"@revizly/sharp-libvips-linux-x64": "1.0.
|
|
148
|
+
"@revizly/sharp-libvips-linux-arm64": "1.0.28",
|
|
149
|
+
"@revizly/sharp-libvips-linux-x64": "1.0.28",
|
|
149
150
|
"@revizly/sharp-linux-arm64": "0.35.0-revizly16",
|
|
150
151
|
"@revizly/sharp-linux-x64": "0.35.0-revizly16"
|
|
151
152
|
},
|
|
152
153
|
"devDependencies": {
|
|
153
|
-
"@biomejs/biome": "^2.
|
|
154
|
+
"@biomejs/biome": "^2.4.4",
|
|
154
155
|
"@cpplint/cli": "^0.1.0",
|
|
155
|
-
"@emnapi/runtime": "^1.
|
|
156
|
-
"@revizly/sharp-libvips-dev": "1.0.
|
|
156
|
+
"@emnapi/runtime": "^1.8.1",
|
|
157
|
+
"@revizly/sharp-libvips-dev": "1.0.28",
|
|
157
158
|
"@types/node": "*",
|
|
158
|
-
"emnapi": "^1.
|
|
159
|
+
"emnapi": "^1.8.1",
|
|
159
160
|
"exif-reader": "^2.0.3",
|
|
160
161
|
"extract-zip": "^2.0.1",
|
|
161
162
|
"icc": "^3.0.0",
|
|
162
163
|
"node-addon-api": "^8.5.0",
|
|
163
|
-
"node-gyp": "^12.
|
|
164
|
+
"node-gyp": "^12.2.0",
|
|
164
165
|
"tar-fs": "^3.1.1",
|
|
165
166
|
"tsd": "^0.33.0"
|
|
166
167
|
},
|
package/src/metadata.cc
CHANGED
|
@@ -209,7 +209,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
209
209
|
// Handle warnings
|
|
210
210
|
std::string warning = sharp::VipsWarningPop();
|
|
211
211
|
while (!warning.empty()) {
|
|
212
|
-
debuglog.
|
|
212
|
+
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
213
213
|
warning = sharp::VipsWarningPop();
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -344,9 +344,9 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
344
344
|
}
|
|
345
345
|
info.Set("comments", comments);
|
|
346
346
|
}
|
|
347
|
-
Callback().
|
|
347
|
+
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
|
348
348
|
} else {
|
|
349
|
-
Callback().
|
|
349
|
+
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
delete baton->input;
|
package/src/pipeline.cc
CHANGED
|
@@ -1301,7 +1301,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1301
1301
|
if (baton->errUseWarning) {
|
|
1302
1302
|
(baton->err).append("\n").append(warning);
|
|
1303
1303
|
} else {
|
|
1304
|
-
debuglog.
|
|
1304
|
+
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
1305
1305
|
}
|
|
1306
1306
|
warning = sharp::VipsWarningPop();
|
|
1307
1307
|
}
|
|
@@ -1355,12 +1355,12 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1355
1355
|
sharp::FreeCallback(static_cast<char*>(baton->bufferOut), nullptr);
|
|
1356
1356
|
Napi::TypedArrayOf<uint8_t> data = Napi::TypedArrayOf<uint8_t>::New(env,
|
|
1357
1357
|
baton->bufferOutLength, ab, 0, napi_uint8_array);
|
|
1358
|
-
Callback().
|
|
1358
|
+
Callback().MakeCallback(Receiver().Value(), { env.Null(), data, info });
|
|
1359
1359
|
} else {
|
|
1360
1360
|
// Node.js Buffer
|
|
1361
1361
|
Napi::Buffer<char> data = Napi::Buffer<char>::NewOrCopy(env, static_cast<char*>(baton->bufferOut),
|
|
1362
1362
|
baton->bufferOutLength, sharp::FreeCallback);
|
|
1363
|
-
Callback().
|
|
1363
|
+
Callback().MakeCallback(Receiver().Value(), { env.Null(), data, info });
|
|
1364
1364
|
}
|
|
1365
1365
|
} else {
|
|
1366
1366
|
// Add file size to info
|
|
@@ -1371,10 +1371,10 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1371
1371
|
info.Set("size", size);
|
|
1372
1372
|
} catch (...) {}
|
|
1373
1373
|
}
|
|
1374
|
-
Callback().
|
|
1374
|
+
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
|
1375
1375
|
}
|
|
1376
1376
|
} else {
|
|
1377
|
-
Callback().
|
|
1377
|
+
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
1380
1380
|
// Delete baton
|
|
@@ -1395,7 +1395,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1395
1395
|
// Decrement processing task counter
|
|
1396
1396
|
sharp::counterProcess--;
|
|
1397
1397
|
Napi::Number queueLength = Napi::Number::New(env, static_cast<int>(sharp::counterQueue));
|
|
1398
|
-
queueListener.
|
|
1398
|
+
queueListener.MakeCallback(Receiver().Value(), { queueLength });
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
1401
|
private:
|
|
@@ -1833,7 +1833,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|
|
1833
1833
|
|
|
1834
1834
|
// Increment queued task counter
|
|
1835
1835
|
Napi::Number queueLength = Napi::Number::New(info.Env(), static_cast<int>(++sharp::counterQueue));
|
|
1836
|
-
queueListener.
|
|
1836
|
+
queueListener.MakeCallback(info.This(), { queueLength });
|
|
1837
1837
|
|
|
1838
1838
|
return info.Env().Undefined();
|
|
1839
1839
|
}
|
package/src/stats.cc
CHANGED
|
@@ -109,7 +109,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
109
109
|
// Handle warnings
|
|
110
110
|
std::string warning = sharp::VipsWarningPop();
|
|
111
111
|
while (!warning.empty()) {
|
|
112
|
-
debuglog.
|
|
112
|
+
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
|
113
113
|
warning = sharp::VipsWarningPop();
|
|
114
114
|
}
|
|
115
115
|
if (baton->err.empty()) {
|
|
@@ -143,9 +143,9 @@ class StatsWorker : public Napi::AsyncWorker {
|
|
|
143
143
|
dominant.Set("g", baton->dominantGreen);
|
|
144
144
|
dominant.Set("b", baton->dominantBlue);
|
|
145
145
|
info.Set("dominant", dominant);
|
|
146
|
-
Callback().
|
|
146
|
+
Callback().MakeCallback(Receiver().Value(), { env.Null(), info });
|
|
147
147
|
} else {
|
|
148
|
-
Callback().
|
|
148
|
+
Callback().MakeCallback(Receiver().Value(), { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
delete baton->input;
|