sharp 0.25.1 → 0.25.2
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/composite.js +1 -4
- package/lib/input.js +15 -3
- package/lib/output.js +3 -3
- package/lib/resize.js +2 -2
- package/package.json +4 -3
- package/src/metadata.cc +1 -0
- package/src/pipeline.cc +2 -3
- package/src/stats.cc +1 -0
package/lib/composite.js
CHANGED
|
@@ -100,10 +100,7 @@ function composite (images) {
|
|
|
100
100
|
if (!is.object(image)) {
|
|
101
101
|
throw is.invalidParameterError('image to composite', 'object', image);
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
const inputOptions = [raw, density, limitInputPixels, sequentialRead].some(is.defined)
|
|
105
|
-
? { raw, density, limitInputPixels, sequentialRead }
|
|
106
|
-
: undefined;
|
|
103
|
+
const inputOptions = this._inputOptionsFromObject(image);
|
|
107
104
|
const composite = {
|
|
108
105
|
input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),
|
|
109
106
|
blend: 'over',
|
package/lib/input.js
CHANGED
|
@@ -4,6 +4,17 @@ const color = require('color');
|
|
|
4
4
|
const is = require('./is');
|
|
5
5
|
const sharp = require('../build/Release/sharp.node');
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Extract input options, if any, from an object.
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
function _inputOptionsFromObject (obj) {
|
|
12
|
+
const { raw, density, limitInputPixels, sequentialRead, failOnError } = obj;
|
|
13
|
+
return [raw, density, limitInputPixels, sequentialRead, failOnError].some(is.defined)
|
|
14
|
+
? { raw, density, limitInputPixels, sequentialRead, failOnError }
|
|
15
|
+
: undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
/**
|
|
8
19
|
* Create Object containing input and input-related options.
|
|
9
20
|
* @private
|
|
@@ -23,12 +34,12 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
23
34
|
} else if (is.plainObject(input) && !is.defined(inputOptions)) {
|
|
24
35
|
// Plain Object descriptor, e.g. create
|
|
25
36
|
inputOptions = input;
|
|
26
|
-
if (
|
|
27
|
-
//
|
|
37
|
+
if (_inputOptionsFromObject(inputOptions)) {
|
|
38
|
+
// Stream with options
|
|
28
39
|
inputDescriptor.buffer = [];
|
|
29
40
|
}
|
|
30
41
|
} else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {
|
|
31
|
-
// Stream
|
|
42
|
+
// Stream without options
|
|
32
43
|
inputDescriptor.buffer = [];
|
|
33
44
|
} else {
|
|
34
45
|
throw new Error(`Unsupported input '${input}' of type ${typeof input}${
|
|
@@ -337,6 +348,7 @@ function stats (callback) {
|
|
|
337
348
|
module.exports = function (Sharp) {
|
|
338
349
|
Object.assign(Sharp.prototype, {
|
|
339
350
|
// Private
|
|
351
|
+
_inputOptionsFromObject,
|
|
340
352
|
_createInputDescriptor,
|
|
341
353
|
_write,
|
|
342
354
|
_flattenBufferIn,
|
package/lib/output.js
CHANGED
|
@@ -568,7 +568,7 @@ function raw () {
|
|
|
568
568
|
* @param {String} [options.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.
|
|
569
569
|
* @param {Number} [options.skipBlanks=-1] threshold to skip tile generation, a value 0 - 255 for 8-bit images or 0 - 65535 for 16-bit images
|
|
570
570
|
* @param {String} [options.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).
|
|
571
|
-
* @param {String} [options.layout='dz'] filesystem layout, possible values are `dz`, `zoomify` or `google`.
|
|
571
|
+
* @param {String} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `zoomify` or `google`.
|
|
572
572
|
* @returns {Sharp}
|
|
573
573
|
* @throws {Error} Invalid parameters
|
|
574
574
|
*/
|
|
@@ -603,10 +603,10 @@ function tile (options) {
|
|
|
603
603
|
}
|
|
604
604
|
// Layout
|
|
605
605
|
if (is.defined(options.layout)) {
|
|
606
|
-
if (is.string(options.layout) && is.inArray(options.layout, ['dz', 'google', 'zoomify'])) {
|
|
606
|
+
if (is.string(options.layout) && is.inArray(options.layout, ['dz', 'google', 'iiif', 'zoomify'])) {
|
|
607
607
|
this.options.tileLayout = options.layout;
|
|
608
608
|
} else {
|
|
609
|
-
throw is.invalidParameterError('layout', 'one of: dz, google, zoomify', options.layout);
|
|
609
|
+
throw is.invalidParameterError('layout', 'one of: dz, google, iiif, zoomify', options.layout);
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
// Angle of rotation,
|
package/lib/resize.js
CHANGED
|
@@ -96,8 +96,8 @@ function isRotationExpected (options) {
|
|
|
96
96
|
* Resize image to `width`, `height` or `width x height`.
|
|
97
97
|
*
|
|
98
98
|
* When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are:
|
|
99
|
-
* - `cover`:
|
|
100
|
-
* - `contain`:
|
|
99
|
+
* - `cover`: (default) Preserving aspect ratio, ensure the image covers both provided dimensions by cropping/clipping to fit.
|
|
100
|
+
* - `contain`: Preserving aspect ratio, contain within both provided dimensions using "letterboxing" where necessary.
|
|
101
101
|
* - `fill`: Ignore the aspect ratio of the input and stretch to both provided dimensions.
|
|
102
102
|
* - `inside`: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
|
|
103
103
|
* - `outside`: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.
|
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 and TIFF images",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.2",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"Andargor <andargor@yahoo.com>",
|
|
66
66
|
"Paul Neave <paul.neave@gmail.com>",
|
|
67
67
|
"Brendan Kennedy <brenwken@gmail.com>",
|
|
68
|
-
"Brychan Bennett-Odlum <git@brychan.io>"
|
|
68
|
+
"Brychan Bennett-Odlum <git@brychan.io>",
|
|
69
|
+
"Edward Silverton <e.silverton@gmail.com>"
|
|
69
70
|
],
|
|
70
71
|
"scripts": {
|
|
71
72
|
"install": "(node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)",
|
|
@@ -125,7 +126,7 @@
|
|
|
125
126
|
"exif-reader": "^1.0.3",
|
|
126
127
|
"icc": "^1.0.0",
|
|
127
128
|
"license-checker": "^25.0.1",
|
|
128
|
-
"mocha": "^7.1.
|
|
129
|
+
"mocha": "^7.1.1",
|
|
129
130
|
"mock-fs": "^4.11.0",
|
|
130
131
|
"nyc": "^15.0.0",
|
|
131
132
|
"prebuild": "^10.0.0",
|
package/src/metadata.cc
CHANGED
|
@@ -229,6 +229,7 @@ Napi::Value metadata(const Napi::CallbackInfo& info) {
|
|
|
229
229
|
// Join queue for worker thread
|
|
230
230
|
Napi::Function callback = info[1].As<Napi::Function>();
|
|
231
231
|
MetadataWorker *worker = new MetadataWorker(callback, baton, debuglog);
|
|
232
|
+
worker->Receiver().Set("options", options);
|
|
232
233
|
worker->Queue();
|
|
233
234
|
|
|
234
235
|
// Increment queued task counter
|
package/src/pipeline.cc
CHANGED
|
@@ -933,9 +933,6 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
933
933
|
};
|
|
934
934
|
suffix = AssembleSuffixString(".webp", options);
|
|
935
935
|
} else {
|
|
936
|
-
std::string extname = baton->tileLayout == VIPS_FOREIGN_DZ_LAYOUT_GOOGLE
|
|
937
|
-
|| baton->tileLayout == VIPS_FOREIGN_DZ_LAYOUT_ZOOMIFY
|
|
938
|
-
? ".jpg" : ".jpeg";
|
|
939
936
|
std::vector<std::pair<std::string, std::string>> options {
|
|
940
937
|
{"Q", std::to_string(baton->jpegQuality)},
|
|
941
938
|
{"interlace", baton->jpegProgressive ? "TRUE" : "FALSE"},
|
|
@@ -946,6 +943,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
946
943
|
{"optimize_scans", baton->jpegOptimiseScans ? "TRUE": "FALSE"},
|
|
947
944
|
{"optimize_coding", baton->jpegOptimiseCoding ? "TRUE": "FALSE"}
|
|
948
945
|
};
|
|
946
|
+
std::string extname = baton->tileLayout == VIPS_FOREIGN_DZ_LAYOUT_DZ ? ".jpeg" : ".jpg";
|
|
949
947
|
suffix = AssembleSuffixString(extname, options);
|
|
950
948
|
}
|
|
951
949
|
// Remove alpha channel from tile background if image does not contain an alpha channel
|
|
@@ -1362,6 +1360,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|
|
1362
1360
|
// Join queue for worker thread
|
|
1363
1361
|
Napi::Function callback = info[1].As<Napi::Function>();
|
|
1364
1362
|
PipelineWorker *worker = new PipelineWorker(callback, baton, debuglog, queueListener);
|
|
1363
|
+
worker->Receiver().Set("options", options);
|
|
1365
1364
|
worker->Queue();
|
|
1366
1365
|
|
|
1367
1366
|
// Increment queued task counter
|
package/src/stats.cc
CHANGED
|
@@ -154,6 +154,7 @@ Napi::Value stats(const Napi::CallbackInfo& info) {
|
|
|
154
154
|
// Join queue for worker thread
|
|
155
155
|
Napi::Function callback = info[1].As<Napi::Function>();
|
|
156
156
|
StatsWorker *worker = new StatsWorker(callback, baton, debuglog);
|
|
157
|
+
worker->Receiver().Set("options", options);
|
|
157
158
|
worker->Queue();
|
|
158
159
|
|
|
159
160
|
// Increment queued task counter
|