@revizly/sharp 0.34.4-revizly10 → 0.34.4-revizly12

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.
@@ -0,0 +1,36 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ const {
5
+ useGlobalLibvips,
6
+ globalLibvipsVersion,
7
+ log,
8
+ spawnRebuild,
9
+ } = require('../lib/libvips');
10
+
11
+ log('Attempting to build from source via node-gyp');
12
+ log('See https://sharp.pixelplumbing.com/install#building-from-source');
13
+
14
+ try {
15
+ const addonApi = require('node-addon-api');
16
+ log(`Found node-addon-api ${addonApi.version || ''}`);
17
+ } catch (_err) {
18
+ log('Please add node-addon-api to your dependencies');
19
+ process.exit(1);
20
+ }
21
+ try {
22
+ const gyp = require('node-gyp');
23
+ log(`Found node-gyp ${gyp().version}`);
24
+ } catch (_err) {
25
+ log('Please add node-gyp to your dependencies');
26
+ process.exit(1);
27
+ }
28
+
29
+ if (useGlobalLibvips(log)) {
30
+ log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
31
+ }
32
+
33
+ const status = spawnRebuild();
34
+ if (status !== 0) {
35
+ process.exit(status);
36
+ }
package/install/check.js CHANGED
@@ -2,36 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  try {
5
- const { useGlobalLibvips, globalLibvipsVersion, log, spawnRebuild } = require('../lib/libvips');
6
-
7
- const buildFromSource = (msg) => {
8
- log(msg);
9
- log('Attempting to build from source via node-gyp');
10
- try {
11
- const addonApi = require('node-addon-api');
12
- log(`Found node-addon-api ${addonApi.version || ''}`);
13
- } catch (_err) {
14
- log('Please add node-addon-api to your dependencies');
15
- return;
16
- }
17
- try {
18
- const gyp = require('node-gyp');
19
- log(`Found node-gyp ${gyp().version}`);
20
- } catch (_err) {
21
- log('Please add node-gyp to your dependencies');
22
- return;
23
- }
24
- log('See https://sharp.pixelplumbing.com/install#building-from-source');
25
- const status = spawnRebuild();
26
- if (status !== 0) {
27
- process.exit(status);
28
- }
29
- };
30
-
31
- if (useGlobalLibvips(log)) {
32
- buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
33
- } else if (process.env.npm_config_build_from_source) {
34
- buildFromSource('Detected --build-from-source flag');
5
+ const { useGlobalLibvips } = require('../lib/libvips');
6
+ if (useGlobalLibvips() || process.env.npm_config_build_from_source) {
7
+ process.exit(1);
35
8
  }
36
9
  } catch (err) {
37
10
  const summary = err.message.split(/\n/).slice(0, 1);
package/lib/colour.js CHANGED
@@ -139,7 +139,10 @@ function toColorspace (colorspace) {
139
139
  * @throws {Error} Invalid value
140
140
  */
141
141
  function _getBackgroundColourOption (value) {
142
- if (is.object(value) || is.string(value)) {
142
+ if (
143
+ is.object(value) ||
144
+ (is.string(value) && value.length >= 3 && value.length <= 200)
145
+ ) {
143
146
  const colour = color(value);
144
147
  return [
145
148
  colour.red(),
@@ -352,6 +352,7 @@ const Sharp = function (input, options) {
352
352
  gifProgressive: false,
353
353
  tiffQuality: 80,
354
354
  tiffCompression: 'jpeg',
355
+ tiffBigtiff: false,
355
356
  tiffPredictor: 'horizontal',
356
357
  tiffPyramid: false,
357
358
  tiffMiniswhite: false,
package/lib/index.d.ts CHANGED
@@ -1460,6 +1460,8 @@ declare namespace sharp {
1460
1460
  quality?: number | undefined;
1461
1461
  /** Compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k (optional, default 'jpeg') */
1462
1462
  compression?: string | undefined;
1463
+ /** Use BigTIFF variant (has no effect when compression is none) (optional, default false) */
1464
+ bigtiff?: boolean | undefined;
1463
1465
  /** Compression predictor options: none, horizontal, float (optional, default 'horizontal') */
1464
1466
  predictor?: string | undefined;
1465
1467
  /** Write an image pyramid (optional, default false) */
package/lib/libvips.js CHANGED
@@ -16,7 +16,7 @@ const minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).versio
16
16
 
17
17
  const prebuiltPlatforms = [
18
18
  'darwin-arm64', 'darwin-x64',
19
- 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-s390x', 'linux-x64',
19
+ 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-x64',
20
20
  'linuxmusl-arm64', 'linuxmusl-x64',
21
21
  'win32-arm64', 'win32-ia32', 'win32-x64'
22
22
  ];
package/lib/output.js CHANGED
@@ -974,6 +974,7 @@ function trySetAnimationOptions (source, target) {
974
974
  * @param {number} [options.quality=80] - quality, integer 1-100
975
975
  * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
976
976
  * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k
977
+ * @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)
977
978
  * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float
978
979
  * @param {boolean} [options.pyramid=false] - write an image pyramid
979
980
  * @param {boolean} [options.tile=false] - write a tiled tiff
@@ -1052,6 +1053,10 @@ function tiff (options) {
1052
1053
  throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);
1053
1054
  }
1054
1055
  }
1056
+ // bigtiff
1057
+ if (is.defined(options.bigtiff)) {
1058
+ this._setBooleanOption('tiffBigtiff', options.bigtiff);
1059
+ }
1055
1060
  // predictor
1056
1061
  if (is.defined(options.predictor)) {
1057
1062
  if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {
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.34.4-revizly10",
4
+ "version": "0.34.4-revizly12",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -92,7 +92,8 @@
92
92
  "Don Denton <don@happycollision.com>"
93
93
  ],
94
94
  "scripts": {
95
- "install": "node install/check.js",
95
+ "build": "node install/build.js",
96
+ "install": "node install/check.js || npm run build",
96
97
  "clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
97
98
  "test": "npm run lint && npm run test-unit",
98
99
  "lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
@@ -139,28 +140,28 @@
139
140
  ],
140
141
  "dependencies": {
141
142
  "@img/colour": "^1.0.0",
142
- "detect-libc": "^2.1.0",
143
- "semver": "^7.7.2"
143
+ "detect-libc": "^2.1.2",
144
+ "semver": "^7.7.3"
144
145
  },
145
146
  "optionalDependencies": {
146
- "@revizly/sharp-libvips-linux-arm64": "1.0.23",
147
- "@revizly/sharp-libvips-linux-x64": "1.0.23",
148
- "@revizly/sharp-linux-arm64": "0.34.4-revizly8",
149
- "@revizly/sharp-linux-x64": "0.34.4-revizly8"
147
+ "@revizly/sharp-libvips-linux-arm64": "1.0.24",
148
+ "@revizly/sharp-libvips-linux-x64": "1.0.24",
149
+ "@revizly/sharp-linux-arm64": "0.34.4-revizly11",
150
+ "@revizly/sharp-linux-x64": "0.34.4-revizly11"
150
151
  },
151
152
  "devDependencies": {
152
- "@biomejs/biome": "^2.2.4",
153
+ "@biomejs/biome": "^2.2.6",
153
154
  "@cpplint/cli": "^0.1.0",
154
155
  "@emnapi/runtime": "^1.5.0",
155
- "@revizly/sharp-libvips-dev": "1.0.23",
156
+ "@revizly/sharp-libvips-dev": "1.0.24",
156
157
  "@types/node": "*",
157
158
  "emnapi": "^1.5.0",
158
159
  "exif-reader": "^2.0.2",
159
160
  "extract-zip": "^2.0.1",
160
161
  "icc": "^3.0.0",
161
- "jsdoc-to-markdown": "^9.1.2",
162
+ "jsdoc-to-markdown": "^9.1.3",
162
163
  "node-addon-api": "^8.5.0",
163
- "node-gyp": "^11.4.2",
164
+ "node-gyp": "^11.5.0",
164
165
  "tar-fs": "^3.1.1",
165
166
  "tsd": "^0.33.0"
166
167
  },
package/src/pipeline.cc CHANGED
@@ -1009,6 +1009,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1009
1009
  ->set("Q", baton->tiffQuality)
1010
1010
  ->set("bitdepth", baton->tiffBitdepth)
1011
1011
  ->set("compression", baton->tiffCompression)
1012
+ ->set("bigtiff", baton->tiffBigtiff)
1012
1013
  ->set("miniswhite", baton->tiffMiniswhite)
1013
1014
  ->set("predictor", baton->tiffPredictor)
1014
1015
  ->set("pyramid", baton->tiffPyramid)
@@ -1211,6 +1212,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1211
1212
  ->set("Q", baton->tiffQuality)
1212
1213
  ->set("bitdepth", baton->tiffBitdepth)
1213
1214
  ->set("compression", baton->tiffCompression)
1215
+ ->set("bigtiff", baton->tiffBigtiff)
1214
1216
  ->set("miniswhite", baton->tiffMiniswhite)
1215
1217
  ->set("predictor", baton->tiffPredictor)
1216
1218
  ->set("pyramid", baton->tiffPyramid)
@@ -1276,7 +1278,12 @@ class PipelineWorker : public Napi::AsyncWorker {
1276
1278
  if (what && what[0]) {
1277
1279
  (baton->err).append(what);
1278
1280
  } else {
1279
- (baton->err).append("Unknown error");
1281
+ if (baton->input->failOn == VIPS_FAIL_ON_WARNING) {
1282
+ (baton->err).append("Warning treated as error due to failOn setting");
1283
+ baton->errUseWarning = true;
1284
+ } else {
1285
+ (baton->err).append("Unknown error");
1286
+ }
1280
1287
  }
1281
1288
  }
1282
1289
  // Clean up libvips' per-request data and threads
@@ -1291,7 +1298,11 @@ class PipelineWorker : public Napi::AsyncWorker {
1291
1298
  // Handle warnings
1292
1299
  std::string warning = sharp::VipsWarningPop();
1293
1300
  while (!warning.empty()) {
1294
- debuglog.Call(Receiver().Value(), { Napi::String::New(env, warning) });
1301
+ if (baton->errUseWarning) {
1302
+ (baton->err).append("\n").append(warning);
1303
+ } else {
1304
+ debuglog.Call(Receiver().Value(), { Napi::String::New(env, warning) });
1305
+ }
1295
1306
  warning = sharp::VipsWarningPop();
1296
1307
  }
1297
1308
 
@@ -1750,6 +1761,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
1750
1761
  baton->gifReuse = sharp::AttrAsBool(options, "gifReuse");
1751
1762
  baton->gifProgressive = sharp::AttrAsBool(options, "gifProgressive");
1752
1763
  baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality");
1764
+ baton->tiffBigtiff = sharp::AttrAsBool(options, "tiffBigtiff");
1753
1765
  baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
1754
1766
  baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
1755
1767
  baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
package/src/pipeline.h CHANGED
@@ -175,6 +175,7 @@ struct PipelineBaton {
175
175
  bool gifProgressive;
176
176
  int tiffQuality;
177
177
  VipsForeignTiffCompression tiffCompression;
178
+ bool tiffBigtiff;
178
179
  VipsForeignTiffPredictor tiffPredictor;
179
180
  bool tiffPyramid;
180
181
  int tiffBitdepth;
@@ -197,6 +198,7 @@ struct PipelineBaton {
197
198
  bool jxlLossless;
198
199
  VipsBandFormat rawDepth;
199
200
  std::string err;
201
+ bool errUseWarning;
200
202
  int keepMetadata;
201
203
  int withMetadataOrientation;
202
204
  double withMetadataDensity;
@@ -350,6 +352,7 @@ struct PipelineBaton {
350
352
  gifProgressive(false),
351
353
  tiffQuality(80),
352
354
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
355
+ tiffBigtiff(false),
353
356
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_HORIZONTAL),
354
357
  tiffPyramid(false),
355
358
  tiffBitdepth(8),
@@ -371,6 +374,7 @@ struct PipelineBaton {
371
374
  jxlEffort(7),
372
375
  jxlLossless(false),
373
376
  rawDepth(VIPS_FORMAT_UCHAR),
377
+ errUseWarning(false),
374
378
  keepMetadata(0),
375
379
  withMetadataOrientation(-1),
376
380
  withMetadataDensity(0.0),