sharp 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/lib/libvips.js +1 -0
- package/lib/output.js +2 -2
- package/lib/resize.js +5 -8
- package/package.json +14 -15
- package/src/common.cc +3 -1
- package/src/common.h +2 -2
- package/src/operations.cc +10 -7
- package/src/pipeline.cc +9 -4
package/README.md
CHANGED
|
@@ -98,7 +98,6 @@ readableStream
|
|
|
98
98
|
A [guide for contributors](https://github.com/lovell/sharp/blob/main/.github/CONTRIBUTING.md)
|
|
99
99
|
covers reporting bugs, requesting features and submitting code changes.
|
|
100
100
|
|
|
101
|
-
[](https://coveralls.io/r/lovell/sharp?branch=main)
|
|
102
101
|
[](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix)
|
|
103
102
|
|
|
104
103
|
## Licensing
|
package/lib/libvips.js
CHANGED
|
@@ -89,6 +89,7 @@ const removeVendoredLibvips = function () {
|
|
|
89
89
|
rm(vendorPath, { recursive: true, maxRetries: 3, force: true });
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
/* istanbul ignore next */
|
|
92
93
|
const pkgConfigPath = function () {
|
|
93
94
|
if (process.platform !== 'win32') {
|
|
94
95
|
const brewPkgConfigPath = spawnSync(
|
package/lib/output.js
CHANGED
|
@@ -1205,7 +1205,7 @@ function _pipeline (callback) {
|
|
|
1205
1205
|
this.push(data);
|
|
1206
1206
|
}
|
|
1207
1207
|
this.push(null);
|
|
1208
|
-
this.emit('close');
|
|
1208
|
+
this.on('end', () => this.emit('close'));
|
|
1209
1209
|
});
|
|
1210
1210
|
});
|
|
1211
1211
|
if (this.streamInFinished) {
|
|
@@ -1221,7 +1221,7 @@ function _pipeline (callback) {
|
|
|
1221
1221
|
this.push(data);
|
|
1222
1222
|
}
|
|
1223
1223
|
this.push(null);
|
|
1224
|
-
this.emit('close');
|
|
1224
|
+
this.on('end', () => this.emit('close'));
|
|
1225
1225
|
});
|
|
1226
1226
|
}
|
|
1227
1227
|
return this;
|
package/lib/resize.js
CHANGED
|
@@ -428,7 +428,7 @@ function extend (extend) {
|
|
|
428
428
|
* @throws {Error} Invalid parameters
|
|
429
429
|
*/
|
|
430
430
|
function extract (options) {
|
|
431
|
-
const suffix = isResizeExpected(this.options) ||
|
|
431
|
+
const suffix = isResizeExpected(this.options) || this.options.widthPre !== -1 ? 'Post' : 'Pre';
|
|
432
432
|
if (this.options[`width${suffix}`] !== -1) {
|
|
433
433
|
this.options.debuglog('ignoring previous extract options');
|
|
434
434
|
}
|
|
@@ -511,15 +511,12 @@ function trim (trim) {
|
|
|
511
511
|
}
|
|
512
512
|
} else if (is.object(trim)) {
|
|
513
513
|
this._setBackgroundColourOption('trimBackground', trim.background);
|
|
514
|
-
|
|
515
514
|
if (!is.defined(trim.threshold)) {
|
|
516
515
|
this.options.trimThreshold = 10;
|
|
517
|
-
} else if (is.number(trim.threshold)) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
throw is.invalidParameterError('threshold', 'positive number', trim);
|
|
522
|
-
}
|
|
516
|
+
} else if (is.number(trim.threshold) && trim.threshold >= 0) {
|
|
517
|
+
this.options.trimThreshold = trim.threshold;
|
|
518
|
+
} else {
|
|
519
|
+
throw is.invalidParameterError('threshold', 'positive number', trim);
|
|
523
520
|
}
|
|
524
521
|
} else {
|
|
525
522
|
throw is.invalidParameterError('trim', 'string, number or object', trim);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sharp",
|
|
3
3
|
"description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",
|
|
4
|
-
"version": "0.31.
|
|
4
|
+
"version": "0.31.1",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -92,9 +92,8 @@
|
|
|
92
92
|
"clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
|
|
93
93
|
"test": "npm run test-lint && npm run test-unit && npm run test-licensing",
|
|
94
94
|
"test-lint": "semistandard && cpplint",
|
|
95
|
-
"test-unit": "nyc --reporter=lcov --branches=
|
|
95
|
+
"test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha --slow=1000 --timeout=20000 ./test/unit/*.js",
|
|
96
96
|
"test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"",
|
|
97
|
-
"test-coverage": "./test/coverage/report.sh",
|
|
98
97
|
"test-leak": "./test/leak/leak.sh",
|
|
99
98
|
"docs-build": "documentation lint lib && node docs/build && node docs/search-index/build",
|
|
100
99
|
"docs-serve": "cd docs && npx serve",
|
|
@@ -156,19 +155,19 @@
|
|
|
156
155
|
},
|
|
157
156
|
"license": "Apache-2.0",
|
|
158
157
|
"config": {
|
|
159
|
-
"libvips": "8.13.
|
|
158
|
+
"libvips": "8.13.2",
|
|
160
159
|
"integrity": {
|
|
161
|
-
"darwin-arm64v8": "sha512-
|
|
162
|
-
"darwin-x64": "sha512-
|
|
163
|
-
"linux-arm64v8": "sha512-
|
|
164
|
-
"linux-armv6": "sha512-
|
|
165
|
-
"linux-armv7": "sha512-
|
|
166
|
-
"linux-x64": "sha512-
|
|
167
|
-
"linuxmusl-arm64v8": "sha512-
|
|
168
|
-
"linuxmusl-x64": "sha512
|
|
169
|
-
"win32-arm64v8": "sha512-
|
|
170
|
-
"win32-ia32": "sha512-
|
|
171
|
-
"win32-x64": "sha512-
|
|
160
|
+
"darwin-arm64v8": "sha512-4tsE/HMQDT9srV/ovSJlr7IxKnhvH9qpArCAf5Xpb/uNcAiT7BcZ+HYwX2lbf3UY8REB1TR4ThEL/lmPnzMUHw==",
|
|
161
|
+
"darwin-x64": "sha512-D4ZSvlgLpf+KzKB2OD+K8NWl0JKzzIbvWwIjjwBycIHTMkaiams3Kp/AQ/bKudqof02Ks6LtP0X4XWvCaoRoUA==",
|
|
162
|
+
"linux-arm64v8": "sha512-9ZvUM2NBluhoeUz9X7/zJ48xJ5d7KzI1cO6lsiv4HKo5fOYw/vEY28XodFJzhyfu9NuKxh3Hs9FtoQGNvvAFkw==",
|
|
163
|
+
"linux-armv6": "sha512-vu0R8DF0k7KseU62fzrJadHNk5oeJriFLVn3KxCKEfV+Wkj7rX4lQhiPmOuD7/wRcUY+GGdoZ52vysDwMQhfzA==",
|
|
164
|
+
"linux-armv7": "sha512-UdfhJTjGFgrwc3Kaos5G1ZAK2+t/16Prtnl6FAT+m7cG5EXzYAqzgvk4qtakAH7UTnVe8MUgOfbTLt0YiRpfsg==",
|
|
165
|
+
"linux-x64": "sha512-sv92VpPyN+3oBv0vi4wDjx51demGdtyhEjd+vDfC3h8S/RSuIUE9Pt/+dBFuf+iv9tRdIq9hH9vzAvsLVy6NYg==",
|
|
166
|
+
"linuxmusl-arm64v8": "sha512-TjhK/wHAS/m55l46T8PZ0qvlK+PKYFZGTQfh+c9aG8/z1v/VtG7TQOLNmPWfg0SFDTkXV7YqnJCqvgYLmJPZUg==",
|
|
167
|
+
"linuxmusl-x64": "sha512-/su96pn/H9+lDdnlM1xB2whWEoeEDJICFp/RNRJb0+bJPJhnL/IDVIhF4VnVNBq/9AlldBWii3hqMq5rY2eEAA==",
|
|
168
|
+
"win32-arm64v8": "sha512-UnSmwCcx3F5u4UOXyrdwTdYsuMK/RtQYc+1y+QxqIkBHiSL7dOlTIH/vKOSQvSaDQTPqxVLFt3wkMN1U7LZwyg==",
|
|
169
|
+
"win32-ia32": "sha512-KH/H6vpx5lJ6NEzLQmwxU/QnDg8p1Jxd+WKaPiyWmXq/HpwyKrZhi3WDoyKD4fLwnlfhAXEfVLZbUbhX21pDpQ==",
|
|
170
|
+
"win32-x64": "sha512-Xim5F21pqx7MuVQViaQNhSz24zWIiKHC9bm4KCdi7q/ytbvdMhm6bzWDI/mvFGNjI62NRB2SBkTTaqwJvM/pUg=="
|
|
172
171
|
},
|
|
173
172
|
"runtime": "napi",
|
|
174
173
|
"target": 7
|
package/src/common.cc
CHANGED
|
@@ -507,9 +507,10 @@ namespace sharp {
|
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
+
|
|
510
511
|
// Limit input images to a given number of pixels, where pixels = width * height
|
|
511
512
|
if (descriptor->limitInputPixels > 0 &&
|
|
512
|
-
static_cast<uint64_t>(image.width() * image.height()
|
|
513
|
+
static_cast<uint64_t>(image.width()) * image.height() > descriptor->limitInputPixels) {
|
|
513
514
|
throw vips::VError("Input image exceeds pixel limit");
|
|
514
515
|
}
|
|
515
516
|
return std::make_tuple(image, imageType);
|
|
@@ -556,6 +557,7 @@ namespace sharp {
|
|
|
556
557
|
VImage RemoveExifOrientation(VImage image) {
|
|
557
558
|
VImage copy = image.copy();
|
|
558
559
|
copy.remove(VIPS_META_ORIENTATION);
|
|
560
|
+
copy.remove("exif-ifd0-Orientation");
|
|
559
561
|
return copy;
|
|
560
562
|
}
|
|
561
563
|
|
package/src/common.h
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
|
|
27
27
|
#if (VIPS_MAJOR_VERSION < 8) || \
|
|
28
28
|
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 13) || \
|
|
29
|
-
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 13 && VIPS_MICRO_VERSION <
|
|
30
|
-
#error "libvips version 8.13.
|
|
29
|
+
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 13 && VIPS_MICRO_VERSION < 2)
|
|
30
|
+
#error "libvips version 8.13.2+ is required - please see https://sharp.pixelplumbing.com/install"
|
|
31
31
|
#endif
|
|
32
32
|
|
|
33
33
|
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
package/src/operations.cc
CHANGED
|
@@ -289,17 +289,20 @@ namespace sharp {
|
|
|
289
289
|
background = image.extract_area(0, 0, 1, 1)(0, 0);
|
|
290
290
|
multiplier = 1.0;
|
|
291
291
|
}
|
|
292
|
-
if (background.size() == 4) {
|
|
292
|
+
if (HasAlpha(image) && background.size() == 4) {
|
|
293
293
|
// Just discard the alpha because flattening the background colour with
|
|
294
294
|
// itself (effectively what find_trim() does) gives the same result
|
|
295
295
|
backgroundAlpha[0] = background[3] * multiplier;
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
background
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
297
|
+
if (image.bands() > 2) {
|
|
298
|
+
background = {
|
|
299
|
+
background[0] * multiplier,
|
|
300
|
+
background[1] * multiplier,
|
|
301
|
+
background[2] * multiplier
|
|
302
|
+
};
|
|
303
|
+
} else {
|
|
304
|
+
background[0] = background[0] * multiplier;
|
|
305
|
+
}
|
|
303
306
|
int left, top, width, height;
|
|
304
307
|
left = image.find_trim(&top, &width, &height, VImage::option()
|
|
305
308
|
->set("background", background)
|
package/src/pipeline.cc
CHANGED
|
@@ -92,7 +92,10 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// Rotate pre-extract
|
|
95
|
-
|
|
95
|
+
bool const shouldRotateBefore = baton->rotateBeforePreExtract &&
|
|
96
|
+
(rotation != VIPS_ANGLE_D0 || flip || flop || baton->rotationAngle != 0.0);
|
|
97
|
+
|
|
98
|
+
if (shouldRotateBefore) {
|
|
96
99
|
if (rotation != VIPS_ANGLE_D0) {
|
|
97
100
|
image = image.rot(rotation);
|
|
98
101
|
}
|
|
@@ -167,7 +170,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
167
170
|
// - input colourspace is not specified;
|
|
168
171
|
bool const shouldPreShrink = (targetResizeWidth > 0 || targetResizeHeight > 0) &&
|
|
169
172
|
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold == 0.0 &&
|
|
170
|
-
baton->colourspaceInput == VIPS_INTERPRETATION_LAST;
|
|
173
|
+
baton->colourspaceInput == VIPS_INTERPRETATION_LAST && !shouldRotateBefore;
|
|
171
174
|
|
|
172
175
|
if (shouldPreShrink) {
|
|
173
176
|
// The common part of the shrink: the bit by which both axes must be shrunk
|
|
@@ -899,12 +902,13 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
899
902
|
} else if (baton->formatOut == "heif" ||
|
|
900
903
|
(baton->formatOut == "input" && inputImageType == sharp::ImageType::HEIF)) {
|
|
901
904
|
// Write HEIF to buffer
|
|
902
|
-
image = sharp::RemoveAnimationProperties(image);
|
|
905
|
+
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
|
903
906
|
VipsArea *area = reinterpret_cast<VipsArea*>(image.heifsave_buffer(VImage::option()
|
|
904
907
|
->set("strip", !baton->withMetadata)
|
|
905
908
|
->set("Q", baton->heifQuality)
|
|
906
909
|
->set("compression", baton->heifCompression)
|
|
907
910
|
->set("effort", baton->heifEffort)
|
|
911
|
+
->set("bitdepth", 8)
|
|
908
912
|
->set("subsample_mode", baton->heifChromaSubsampling == "4:4:4"
|
|
909
913
|
? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
|
|
910
914
|
->set("lossless", baton->heifLossless)));
|
|
@@ -1070,12 +1074,13 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1070
1074
|
} else if (baton->formatOut == "heif" || (mightMatchInput && isHeif) ||
|
|
1071
1075
|
(willMatchInput && inputImageType == sharp::ImageType::HEIF)) {
|
|
1072
1076
|
// Write HEIF to file
|
|
1073
|
-
image = sharp::RemoveAnimationProperties(image);
|
|
1077
|
+
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
|
1074
1078
|
image.heifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
|
1075
1079
|
->set("strip", !baton->withMetadata)
|
|
1076
1080
|
->set("Q", baton->heifQuality)
|
|
1077
1081
|
->set("compression", baton->heifCompression)
|
|
1078
1082
|
->set("effort", baton->heifEffort)
|
|
1083
|
+
->set("bitdepth", 8)
|
|
1079
1084
|
->set("subsample_mode", baton->heifChromaSubsampling == "4:4:4"
|
|
1080
1085
|
? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
|
|
1081
1086
|
->set("lossless", baton->heifLossless));
|