@revizly/sharp 0.35.0-revizly4 → 0.35.0-revizly41
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 +12 -18
- package/{lib/channel.js → dist/channel.cjs} +1 -1
- package/dist/channel.mjs +177 -0
- package/{lib/colour.js → dist/colour.cjs} +11 -7
- package/dist/colour.mjs +199 -0
- package/{lib/composite.js → dist/composite.cjs} +2 -1
- package/dist/composite.mjs +213 -0
- package/{lib/constructor.js → dist/constructor.cjs} +42 -29
- package/dist/constructor.mjs +512 -0
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +2001 -0
- package/dist/index.d.mts +2048 -0
- package/dist/index.mjs +25 -0
- package/{lib/input.js → dist/input.cjs} +26 -21
- package/dist/input.mjs +814 -0
- package/{lib/is.js → dist/is.cjs} +1 -1
- package/dist/is.mjs +143 -0
- package/{lib/libvips.js → dist/libvips.cjs} +35 -30
- package/dist/libvips.mjs +212 -0
- package/{lib/operation.js → dist/operation.cjs} +33 -51
- package/dist/operation.mjs +998 -0
- package/{lib/output.js → dist/output.cjs} +161 -28
- package/dist/output.mjs +1799 -0
- package/{lib/resize.js → dist/resize.cjs} +46 -24
- package/dist/resize.mjs +617 -0
- package/dist/sharp.cjs +125 -0
- package/dist/sharp.mjs +125 -0
- package/{lib/utility.js → dist/utility.cjs} +18 -8
- package/dist/utility.mjs +301 -0
- package/install/build.js +3 -3
- package/lib/index.d.ts +105 -75
- package/package.json +46 -27
- package/src/binding.gyp +18 -13
- package/src/common.cc +70 -17
- package/src/common.h +22 -3
- package/src/metadata.cc +66 -8
- package/src/metadata.h +6 -1
- package/src/operations.cc +25 -8
- package/src/operations.h +1 -1
- package/src/pipeline.cc +206 -69
- package/src/pipeline.h +16 -1
- package/src/stats.cc +6 -6
- package/src/utilities.cc +7 -6
- package/install/check.js +0 -14
- package/lib/index.js +0 -16
- package/lib/sharp.js +0 -121
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Copyright 2013 Lovell Fuller and others.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import Sharp from './constructor.mjs';
|
|
7
|
+
import input from './input.mjs';
|
|
8
|
+
import resize from './resize.mjs';
|
|
9
|
+
import composite from './composite.mjs';
|
|
10
|
+
import operation from './operation.mjs';
|
|
11
|
+
import colour from './colour.mjs';
|
|
12
|
+
import channel from './channel.mjs';
|
|
13
|
+
import output from './output.mjs';
|
|
14
|
+
import utility from './utility.mjs';
|
|
15
|
+
|
|
16
|
+
input(Sharp);
|
|
17
|
+
resize(Sharp);
|
|
18
|
+
composite(Sharp);
|
|
19
|
+
operation(Sharp);
|
|
20
|
+
colour(Sharp);
|
|
21
|
+
channel(Sharp);
|
|
22
|
+
output(Sharp);
|
|
23
|
+
utility(Sharp);
|
|
24
|
+
|
|
25
|
+
export default Sharp;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
const is = require('./is');
|
|
7
|
-
const sharp = require('./sharp');
|
|
6
|
+
const is = require('./is.cjs');
|
|
7
|
+
const sharp = require('./sharp.cjs');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Justification alignment
|
|
@@ -24,13 +24,13 @@ const align = {
|
|
|
24
24
|
|
|
25
25
|
const inputStreamParameters = [
|
|
26
26
|
// Limits and error handling
|
|
27
|
-
'failOn', 'limitInputPixels', 'unlimited',
|
|
27
|
+
'failOn', 'limitInputPixels', 'limitInputChannels', 'unlimited',
|
|
28
28
|
// Format-generic
|
|
29
29
|
'animated', 'autoOrient', 'density', 'ignoreIcc', 'page', 'pages', 'sequentialRead',
|
|
30
30
|
// Format-specific
|
|
31
31
|
'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',
|
|
32
32
|
// Deprecated
|
|
33
|
-
'
|
|
33
|
+
'openSlideLevel', 'pdfBackground', 'tiffSubifd'
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -55,6 +55,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
55
55
|
autoOrient: false,
|
|
56
56
|
failOn: 'warning',
|
|
57
57
|
limitInputPixels: 0x3FFF ** 2,
|
|
58
|
+
limitInputChannels: 5,
|
|
58
59
|
ignoreIcc: false,
|
|
59
60
|
unlimited: false,
|
|
60
61
|
sequentialRead: true
|
|
@@ -106,14 +107,6 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
106
107
|
}`);
|
|
107
108
|
}
|
|
108
109
|
if (is.object(inputOptions)) {
|
|
109
|
-
// Deprecated: failOnError
|
|
110
|
-
if (is.defined(inputOptions.failOnError)) {
|
|
111
|
-
if (is.bool(inputOptions.failOnError)) {
|
|
112
|
-
inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';
|
|
113
|
-
} else {
|
|
114
|
-
throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
110
|
// failOn
|
|
118
111
|
if (is.defined(inputOptions.failOn)) {
|
|
119
112
|
if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {
|
|
@@ -132,7 +125,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
132
125
|
}
|
|
133
126
|
// Density
|
|
134
127
|
if (is.defined(inputOptions.density)) {
|
|
135
|
-
if (is.inRange(inputOptions.density, 1, 100000)) {
|
|
128
|
+
if (is.number(inputOptions.density) && is.inRange(inputOptions.density, 1, 100000)) {
|
|
136
129
|
inputDescriptor.density = inputOptions.density;
|
|
137
130
|
} else {
|
|
138
131
|
throw is.invalidParameterError('density', 'number between 1 and 100000', inputOptions.density);
|
|
@@ -158,6 +151,16 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
158
151
|
throw is.invalidParameterError('limitInputPixels', 'positive integer', inputOptions.limitInputPixels);
|
|
159
152
|
}
|
|
160
153
|
}
|
|
154
|
+
// limitInputChannels
|
|
155
|
+
if (is.defined(inputOptions.limitInputChannels)) {
|
|
156
|
+
if (is.bool(inputOptions.limitInputChannels)) {
|
|
157
|
+
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels ? 5 : 0;
|
|
158
|
+
} else if (is.integer(inputOptions.limitInputChannels) && is.inRange(inputOptions.limitInputChannels, 0, Number.MAX_SAFE_INTEGER)) {
|
|
159
|
+
inputDescriptor.limitInputChannels = inputOptions.limitInputChannels;
|
|
160
|
+
} else {
|
|
161
|
+
throw is.invalidParameterError('limitInputChannels', 'positive integer', inputOptions.limitInputChannels);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
161
164
|
// unlimited
|
|
162
165
|
if (is.defined(inputOptions.unlimited)) {
|
|
163
166
|
if (is.bool(inputOptions.unlimited)) {
|
|
@@ -178,8 +181,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
178
181
|
if (is.defined(inputOptions.raw)) {
|
|
179
182
|
if (
|
|
180
183
|
is.object(inputOptions.raw) &&
|
|
181
|
-
is.integer(inputOptions.raw.width) && inputOptions.raw.width
|
|
182
|
-
is.integer(inputOptions.raw.height) && inputOptions.raw.height
|
|
184
|
+
is.integer(inputOptions.raw.width) && is.inRange(inputOptions.raw.width, 1, 100000000) &&
|
|
185
|
+
is.integer(inputOptions.raw.height) && is.inRange(inputOptions.raw.height, 1, 100000000) &&
|
|
183
186
|
is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4)
|
|
184
187
|
) {
|
|
185
188
|
inputDescriptor.rawWidth = inputOptions.raw.width;
|
|
@@ -326,8 +329,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
326
329
|
if (is.defined(inputOptions.create)) {
|
|
327
330
|
if (
|
|
328
331
|
is.object(inputOptions.create) &&
|
|
329
|
-
is.integer(inputOptions.create.width) && inputOptions.create.width
|
|
330
|
-
is.integer(inputOptions.create.height) && inputOptions.create.height
|
|
332
|
+
is.integer(inputOptions.create.width) && is.inRange(inputOptions.create.width, 1, 100000000) &&
|
|
333
|
+
is.integer(inputOptions.create.height) && is.inRange(inputOptions.create.height, 1, 100000000) &&
|
|
331
334
|
is.integer(inputOptions.create.channels)
|
|
332
335
|
) {
|
|
333
336
|
inputDescriptor.createWidth = inputOptions.create.width;
|
|
@@ -407,17 +410,17 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
|
|
407
410
|
}
|
|
408
411
|
}
|
|
409
412
|
if (is.defined(inputOptions.text.width)) {
|
|
410
|
-
if (is.integer(inputOptions.text.width) && inputOptions.text.width
|
|
413
|
+
if (is.integer(inputOptions.text.width) && is.inRange(inputOptions.text.width, 1, 1000000)) {
|
|
411
414
|
inputDescriptor.textWidth = inputOptions.text.width;
|
|
412
415
|
} else {
|
|
413
|
-
throw is.invalidParameterError('text.width', '
|
|
416
|
+
throw is.invalidParameterError('text.width', 'integer between 1 and 1000000', inputOptions.text.width);
|
|
414
417
|
}
|
|
415
418
|
}
|
|
416
419
|
if (is.defined(inputOptions.text.height)) {
|
|
417
|
-
if (is.integer(inputOptions.text.height) && inputOptions.text.height
|
|
420
|
+
if (is.integer(inputOptions.text.height) && is.inRange(inputOptions.text.height, 1, 1000000)) {
|
|
418
421
|
inputDescriptor.textHeight = inputOptions.text.height;
|
|
419
422
|
} else {
|
|
420
|
-
throw is.invalidParameterError('text.height', '
|
|
423
|
+
throw is.invalidParameterError('text.height', 'integer between 1 and 1000000', inputOptions.text.height);
|
|
421
424
|
}
|
|
422
425
|
}
|
|
423
426
|
if (is.defined(inputOptions.text.align)) {
|
|
@@ -575,6 +578,7 @@ function _isStreamInput () {
|
|
|
575
578
|
* A `Promise` is returned when `callback` is not provided.
|
|
576
579
|
*
|
|
577
580
|
* - `format`: Name of decoder used to parse image e.g. `jpeg`, `png`, `webp`, `gif`, `svg`, `heif`, `tiff`
|
|
581
|
+
* - `mediaType`: Media Type (MIME Type) e.g. `image/jpeg`, `image/png`, `image/svg+xml`, `image/avif`
|
|
578
582
|
* - `size`: Total size of image in bytes, for Stream and Buffer input only
|
|
579
583
|
* - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)
|
|
580
584
|
* - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)
|
|
@@ -607,6 +611,7 @@ function _isStreamInput () {
|
|
|
607
611
|
* - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present
|
|
608
612
|
* - `formatMagick`: String containing format for images loaded via *magick
|
|
609
613
|
* - `comments`: Array of keyword/text pairs representing PNG text blocks, if present.
|
|
614
|
+
* - `gainMap.image`: HDR gain map, if present, as compressed JPEG image.
|
|
610
615
|
*
|
|
611
616
|
* @example
|
|
612
617
|
* const metadata = await sharp(input).metadata();
|