sharp 0.32.3 → 0.32.4
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/utility.js +68 -0
- package/package.json +14 -14
- package/src/common.h +2 -2
- package/src/sharp.cc +1 -0
- package/src/utilities.cc +11 -0
- package/src/utilities.h +1 -0
package/lib/utility.js
CHANGED
|
@@ -202,6 +202,72 @@ function simd (simd) {
|
|
|
202
202
|
}
|
|
203
203
|
simd(true);
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Block libvips operations at runtime.
|
|
207
|
+
*
|
|
208
|
+
* This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,
|
|
209
|
+
* which when set will block all "untrusted" operations.
|
|
210
|
+
*
|
|
211
|
+
* @since 0.32.4
|
|
212
|
+
*
|
|
213
|
+
* @example <caption>Block all TIFF input.</caption>
|
|
214
|
+
* sharp.block({
|
|
215
|
+
* operation: ['VipsForeignLoadTiff']
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* @param {Object} options
|
|
219
|
+
* @param {Array<string>} options.operation - List of libvips low-level operation names to block.
|
|
220
|
+
*/
|
|
221
|
+
function block (options) {
|
|
222
|
+
if (is.object(options)) {
|
|
223
|
+
if (Array.isArray(options.operation) && options.operation.every(is.string)) {
|
|
224
|
+
sharp.block(options.operation, true);
|
|
225
|
+
} else {
|
|
226
|
+
throw is.invalidParameterError('operation', 'Array<string>', options.operation);
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
throw is.invalidParameterError('options', 'object', options);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Unblock libvips operations at runtime.
|
|
235
|
+
*
|
|
236
|
+
* This is useful for defining a list of allowed operations.
|
|
237
|
+
*
|
|
238
|
+
* @since 0.32.4
|
|
239
|
+
*
|
|
240
|
+
* @example <caption>Block all input except WebP from the filesystem.</caption>
|
|
241
|
+
* sharp.block({
|
|
242
|
+
* operation: ['VipsForeignLoad']
|
|
243
|
+
* });
|
|
244
|
+
* sharp.unblock({
|
|
245
|
+
* operation: ['VipsForeignLoadWebpFile']
|
|
246
|
+
* });
|
|
247
|
+
*
|
|
248
|
+
* @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>
|
|
249
|
+
* sharp.block({
|
|
250
|
+
* operation: ['VipsForeignLoad']
|
|
251
|
+
* });
|
|
252
|
+
* sharp.unblock({
|
|
253
|
+
* operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* @param {Object} options
|
|
257
|
+
* @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.
|
|
258
|
+
*/
|
|
259
|
+
function unblock (options) {
|
|
260
|
+
if (is.object(options)) {
|
|
261
|
+
if (Array.isArray(options.operation) && options.operation.every(is.string)) {
|
|
262
|
+
sharp.block(options.operation, false);
|
|
263
|
+
} else {
|
|
264
|
+
throw is.invalidParameterError('operation', 'Array<string>', options.operation);
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
throw is.invalidParameterError('options', 'object', options);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
205
271
|
/**
|
|
206
272
|
* Decorate the Sharp class with utility-related functions.
|
|
207
273
|
* @private
|
|
@@ -216,4 +282,6 @@ module.exports = function (Sharp) {
|
|
|
216
282
|
Sharp.versions = versions;
|
|
217
283
|
Sharp.vendor = vendor;
|
|
218
284
|
Sharp.queue = queue;
|
|
285
|
+
Sharp.block = block;
|
|
286
|
+
Sharp.unblock = unblock;
|
|
219
287
|
};
|
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.32.
|
|
4
|
+
"version": "0.32.4",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
],
|
|
134
134
|
"dependencies": {
|
|
135
135
|
"color": "^4.2.3",
|
|
136
|
-
"detect-libc": "^2.0.
|
|
136
|
+
"detect-libc": "^2.0.2",
|
|
137
137
|
"node-addon-api": "^6.1.0",
|
|
138
138
|
"prebuild-install": "^7.1.1",
|
|
139
139
|
"semver": "^7.5.4",
|
|
@@ -159,19 +159,19 @@
|
|
|
159
159
|
},
|
|
160
160
|
"license": "Apache-2.0",
|
|
161
161
|
"config": {
|
|
162
|
-
"libvips": "8.14.
|
|
162
|
+
"libvips": "8.14.3",
|
|
163
163
|
"integrity": {
|
|
164
|
-
"darwin-arm64v8": "sha512-
|
|
165
|
-
"darwin-x64": "sha512-
|
|
166
|
-
"linux-arm64v8": "sha512-
|
|
167
|
-
"linux-armv6": "sha512-
|
|
168
|
-
"linux-armv7": "sha512
|
|
169
|
-
"linux-x64": "sha512-
|
|
170
|
-
"linuxmusl-arm64v8": "sha512-
|
|
171
|
-
"linuxmusl-x64": "sha512-
|
|
172
|
-
"win32-arm64v8": "sha512-
|
|
173
|
-
"win32-ia32": "sha512-
|
|
174
|
-
"win32-x64": "sha512-
|
|
164
|
+
"darwin-arm64v8": "sha512-zeb7jQ/5ARZfBH9Uy5wlpN05bFpiIN0qN3gIIpfJhpN0rhGDnjJZQgK0W+pOmG1YiLL42BMCS0SHldb0xE33rA==",
|
|
165
|
+
"darwin-x64": "sha512-C3N6smxdfprfz58cjojv0aekYXDl6+f9SwpGpxPG5RrZnrDMn5NOXtUQOEQ8PZ3Hd9VzfkJTnW/s36EvcMPfYg==",
|
|
166
|
+
"linux-arm64v8": "sha512-hT6B+OswqVQH10Fggq3jpOdn+GhxNx+5bk+EMr3lY3RZy72PZ+n4ZHJDfYSxAymdiz5rCdzGxsRLMb9GgD4OSw==",
|
|
167
|
+
"linux-armv6": "sha512-cW9giVrBssHXFt07l+PgqGu7P7XRDv7oW8jC6iXGBcjG75N7rXz2CK0DyPclfnyoWH4IQ78dh5SkQWmb6X4tig==",
|
|
168
|
+
"linux-armv7": "sha512-hgqFt3UkZHK6D91JtYrYmT1niznh+N93Zxj2EWXgTLAdcS1D3QqaDPEg2EhInHbXqYvfOuQYAAXPxt7zVtKqcw==",
|
|
169
|
+
"linux-x64": "sha512-FKbMBbCcFcSugRtuiTsA6Cov+M2WQ8nzvmmJ5xYYpRg/rsrWvObFT+6x/YBpblur9uXGjGIehjXVZtB3VXc+pg==",
|
|
170
|
+
"linuxmusl-arm64v8": "sha512-RTf6mrFyLGWnyt0DH4nHeXv5oSZMSJWxTdTt4cjvJsgp2Husz3mNJLQJGeehCuqPCYj/liJ9NIczw8u71eHFng==",
|
|
171
|
+
"linuxmusl-x64": "sha512-y/8UOkHzKhi/5UM1/ONyPvpuhO11nPQmuJWfzqUKj8kSKnDasmxv3FN46yI0XY3xA2oFC8lQNFBnLudQsi3Nvw==",
|
|
172
|
+
"win32-arm64v8": "sha512-D3PiVL981S7V0bSUwW3OqDS48H9QRw2vqQhYIY3JcIEssOnjWxmJGaz0Y9Zb8TYF5DHnnD6g5kEhob5Y2PIVEw==",
|
|
173
|
+
"win32-ia32": "sha512-FuLIaSIYJGJAcxyKkG/3/uuTzputekKSCcRCpRHkQS9J8IwM+yHzQeJ5W2PyAvNdeGIEwlYq3wnCNcXe1UGXWA==",
|
|
174
|
+
"win32-x64": "sha512-VQg4aBqpEfybgV8bjnrjfvnosxQDII/23mouFUfKHCsH5kvvHV5tTuPsxm6qbl+SCVploDK/zK1qpjop8YEvtg=="
|
|
175
175
|
},
|
|
176
176
|
"runtime": "napi",
|
|
177
177
|
"target": 7
|
package/src/common.h
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
#if (VIPS_MAJOR_VERSION < 8) || \
|
|
17
17
|
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 14) || \
|
|
18
|
-
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 14 && VIPS_MICRO_VERSION <
|
|
19
|
-
#error "libvips version 8.14.
|
|
18
|
+
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 14 && VIPS_MICRO_VERSION < 3)
|
|
19
|
+
#error "libvips version 8.14.3+ is required - please see https://sharp.pixelplumbing.com/install"
|
|
20
20
|
#endif
|
|
21
21
|
|
|
22
22
|
#if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
|
package/src/sharp.cc
CHANGED
|
@@ -31,6 +31,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
31
31
|
exports.Set("simd", Napi::Function::New(env, simd));
|
|
32
32
|
exports.Set("libvipsVersion", Napi::Function::New(env, libvipsVersion));
|
|
33
33
|
exports.Set("format", Napi::Function::New(env, format));
|
|
34
|
+
exports.Set("block", Napi::Function::New(env, block));
|
|
34
35
|
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
|
35
36
|
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
|
36
37
|
exports.Set("stats", Napi::Function::New(env, stats));
|
package/src/utilities.cc
CHANGED
|
@@ -164,6 +164,17 @@ Napi::Value format(const Napi::CallbackInfo& info) {
|
|
|
164
164
|
return format;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/*
|
|
168
|
+
(Un)block libvips operations at runtime.
|
|
169
|
+
*/
|
|
170
|
+
void block(const Napi::CallbackInfo& info) {
|
|
171
|
+
Napi::Array ops = info[size_t(0)].As<Napi::Array>();
|
|
172
|
+
bool const state = info[size_t(1)].As<Napi::Boolean>().Value();
|
|
173
|
+
for (unsigned int i = 0; i < ops.Length(); i++) {
|
|
174
|
+
vips_operation_block_set(ops.Get(i).As<Napi::String>().Utf8Value().c_str(), state);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
167
178
|
/*
|
|
168
179
|
Synchronous, internal-only method used by some of the functional tests.
|
|
169
180
|
Calculates the maximum colour distance using the DE2000 algorithm
|
package/src/utilities.h
CHANGED
|
@@ -12,6 +12,7 @@ Napi::Value counters(const Napi::CallbackInfo& info);
|
|
|
12
12
|
Napi::Value simd(const Napi::CallbackInfo& info);
|
|
13
13
|
Napi::Value libvipsVersion(const Napi::CallbackInfo& info);
|
|
14
14
|
Napi::Value format(const Napi::CallbackInfo& info);
|
|
15
|
+
void block(const Napi::CallbackInfo& info);
|
|
15
16
|
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
|
16
17
|
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
|
17
18
|
|