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