@revizly/sharp 0.35.0-revizly32 → 0.35.0-revizly34

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.
@@ -48,7 +48,7 @@ const queueListener = (queueLength) => {
48
48
  * // resize to 300 pixels wide,
49
49
  * // emit an 'info' event with calculated dimensions
50
50
  * // and finally write image data to writableStream
51
- * const { body } = fetch('https://...');
51
+ * const { body } = await fetch('https://...');
52
52
  * const readableStream = Readable.fromWeb(body);
53
53
  * const transformer = sharp()
54
54
  * .resize(300)
@@ -58,6 +58,17 @@ const queueListener = (queueLength) => {
58
58
  * readableStream.pipe(transformer).pipe(writableStream);
59
59
  *
60
60
  * @example
61
+ * // Web Streams API, requires Node.js >= 24.15.0
62
+ * const { Duplex } = require('node:stream');
63
+ *
64
+ * const { body } = await fetch('https://...');
65
+ * const transformer = Duplex.toWeb(
66
+ * sharp().resize(300),
67
+ * { readableType: 'bytes' }
68
+ * );
69
+ * body.pipeThrough(transformer).pipeTo(writable);
70
+ *
71
+ * @example
61
72
  * // Create a blank 300x200 PNG image of semi-translucent red pixels
62
73
  * sharp({
63
74
  * create: {
@@ -382,7 +393,7 @@ const Sharp = function (input, options) {
382
393
  heifEffort: 4,
383
394
  heifChromaSubsampling: '4:4:4',
384
395
  heifBitdepth: 8,
385
- heifTune: 'ssim',
396
+ heifTune: 'auto',
386
397
  heifEncoder: 'auto',
387
398
  jxlDistance: 1,
388
399
  jxlDecodingTier: 0,
@@ -48,7 +48,7 @@ const queueListener = (queueLength) => {
48
48
  * // resize to 300 pixels wide,
49
49
  * // emit an 'info' event with calculated dimensions
50
50
  * // and finally write image data to writableStream
51
- * const { body } = fetch('https://...');
51
+ * const { body } = await fetch('https://...');
52
52
  * const readableStream = Readable.fromWeb(body);
53
53
  * const transformer = sharp()
54
54
  * .resize(300)
@@ -58,6 +58,17 @@ const queueListener = (queueLength) => {
58
58
  * readableStream.pipe(transformer).pipe(writableStream);
59
59
  *
60
60
  * @example
61
+ * // Web Streams API, requires Node.js >= 24.15.0
62
+ * import { Duplex } from 'node:stream';
63
+ *
64
+ * const { body } = await fetch('https://...');
65
+ * const transformer = Duplex.toWeb(
66
+ * sharp().resize(300),
67
+ * { readableType: 'bytes' }
68
+ * );
69
+ * body.pipeThrough(transformer).pipeTo(writable);
70
+ *
71
+ * @example
61
72
  * // Create a blank 300x200 PNG image of semi-translucent red pixels
62
73
  * sharp({
63
74
  * create: {
@@ -382,7 +393,7 @@ const Sharp = function (input, options) {
382
393
  heifEffort: 4,
383
394
  heifChromaSubsampling: '4:4:4',
384
395
  heifBitdepth: 8,
385
- heifTune: 'ssim',
396
+ heifTune: 'auto',
386
397
  heifEncoder: 'auto',
387
398
  jxlDistance: 1,
388
399
  jxlDecodingTier: 0,
package/dist/output.cjs CHANGED
@@ -1206,7 +1206,6 @@ function tiff (options) {
1206
1206
  * Use these AVIF options for output image.
1207
1207
  *
1208
1208
  * AVIF image sequences are not supported.
1209
- * Prebuilt binaries support a bitdepth of 8 only.
1210
1209
  *
1211
1210
  * When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
1212
1211
  *
@@ -1228,13 +1227,12 @@ function tiff (options) {
1228
1227
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1229
1228
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1230
1229
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1231
- * @param {string} [options.tune='iq'] - tune output for a quality metric, one of 'iq' (default), 'ssim' (default when lossless) or 'psnr'
1230
+ * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (default), 'iq', 'psnr' or 'ssim'
1232
1231
  * @returns {Sharp}
1233
1232
  * @throws {Error} Invalid options
1234
1233
  */
1235
1234
  function avif (options) {
1236
- const tune = is.object(options) && is.defined(options.tune) ? options.tune : 'iq';
1237
- return this.heif({ ...options, compression: 'av1', tune });
1235
+ return this.heif({ ...options, compression: 'av1' });
1238
1236
  }
1239
1237
 
1240
1238
  /**
@@ -1257,7 +1255,7 @@ function avif (options) {
1257
1255
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1258
1256
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1259
1257
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1260
- * @param {string} [options.tune='ssim'] - tune output for a quality metric, one of 'ssim' (default), 'psnr' or 'iq'
1258
+ * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (default), 'iq', 'psnr' or 'ssim'
1261
1259
  * @returns {Sharp}
1262
1260
  * @throws {Error} Invalid options
1263
1261
  */
@@ -1298,23 +1296,20 @@ function heif (options) {
1298
1296
  }
1299
1297
  if (is.defined(options.bitdepth)) {
1300
1298
  if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [8, 10, 12])) {
1301
- if (options.bitdepth !== 8 && this.constructor.versions.heif) {
1302
- throw is.invalidParameterError('bitdepth when using prebuilt binaries', 8, options.bitdepth);
1303
- }
1304
1299
  this.options.heifBitdepth = options.bitdepth;
1305
1300
  } else {
1306
1301
  throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);
1307
1302
  }
1308
1303
  }
1309
1304
  if (is.defined(options.tune)) {
1310
- if (is.string(options.tune) && is.inArray(options.tune, ['iq', 'ssim', 'psnr'])) {
1305
+ if (is.string(options.tune) && is.inArray(options.tune, ['auto', 'iq', 'psnr', 'ssim'])) {
1311
1306
  if (this.options.heifLossless && options.tune === 'iq') {
1312
1307
  this.options.heifTune = 'ssim';
1313
1308
  } else {
1314
1309
  this.options.heifTune = options.tune;
1315
1310
  }
1316
1311
  } else {
1317
- throw is.invalidParameterError('tune', 'one of: psnr, ssim, iq', options.tune);
1312
+ throw is.invalidParameterError('tune', 'one of: auto, iq, psnr, ssim', options.tune);
1318
1313
  }
1319
1314
  }
1320
1315
  if (is.defined(options.encoder)) {
package/dist/output.mjs CHANGED
@@ -1206,7 +1206,6 @@ function tiff (options) {
1206
1206
  * Use these AVIF options for output image.
1207
1207
  *
1208
1208
  * AVIF image sequences are not supported.
1209
- * Prebuilt binaries support a bitdepth of 8 only.
1210
1209
  *
1211
1210
  * When using Windows ARM64, this feature requires a CPU with ARM64v8.4 or later.
1212
1211
  *
@@ -1228,13 +1227,12 @@ function tiff (options) {
1228
1227
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1229
1228
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1230
1229
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1231
- * @param {string} [options.tune='iq'] - tune output for a quality metric, one of 'iq' (default), 'ssim' (default when lossless) or 'psnr'
1230
+ * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (default), 'iq', 'psnr' or 'ssim'
1232
1231
  * @returns {Sharp}
1233
1232
  * @throws {Error} Invalid options
1234
1233
  */
1235
1234
  function avif (options) {
1236
- const tune = is.object(options) && is.defined(options.tune) ? options.tune : 'iq';
1237
- return this.heif({ ...options, compression: 'av1', tune });
1235
+ return this.heif({ ...options, compression: 'av1' });
1238
1236
  }
1239
1237
 
1240
1238
  /**
@@ -1257,7 +1255,7 @@ function avif (options) {
1257
1255
  * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)
1258
1256
  * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling
1259
1257
  * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit
1260
- * @param {string} [options.tune='ssim'] - tune output for a quality metric, one of 'ssim' (default), 'psnr' or 'iq'
1258
+ * @param {string} [options.tune='auto'] - tune output for a quality metric, one of 'auto' (default), 'iq', 'psnr' or 'ssim'
1261
1259
  * @returns {Sharp}
1262
1260
  * @throws {Error} Invalid options
1263
1261
  */
@@ -1298,23 +1296,20 @@ function heif (options) {
1298
1296
  }
1299
1297
  if (is.defined(options.bitdepth)) {
1300
1298
  if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [8, 10, 12])) {
1301
- if (options.bitdepth !== 8 && this.constructor.versions.heif) {
1302
- throw is.invalidParameterError('bitdepth when using prebuilt binaries', 8, options.bitdepth);
1303
- }
1304
1299
  this.options.heifBitdepth = options.bitdepth;
1305
1300
  } else {
1306
1301
  throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);
1307
1302
  }
1308
1303
  }
1309
1304
  if (is.defined(options.tune)) {
1310
- if (is.string(options.tune) && is.inArray(options.tune, ['iq', 'ssim', 'psnr'])) {
1305
+ if (is.string(options.tune) && is.inArray(options.tune, ['auto', 'iq', 'psnr', 'ssim'])) {
1311
1306
  if (this.options.heifLossless && options.tune === 'iq') {
1312
1307
  this.options.heifTune = 'ssim';
1313
1308
  } else {
1314
1309
  this.options.heifTune = options.tune;
1315
1310
  }
1316
1311
  } else {
1317
- throw is.invalidParameterError('tune', 'one of: psnr, ssim, iq', options.tune);
1312
+ throw is.invalidParameterError('tune', 'one of: auto, iq, psnr, ssim', options.tune);
1318
1313
  }
1319
1314
  }
1320
1315
  if (is.defined(options.encoder)) {
package/dist/resize.cjs CHANGED
@@ -506,6 +506,8 @@ function extract (options) {
506
506
  *
507
507
  * If the result of this operation would trim an image to nothing then no change is made.
508
508
  *
509
+ * Use the `lineArt` and `threshold` options for control over sensitivity.
510
+ *
509
511
  * The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
510
512
  *
511
513
  * @example
package/dist/resize.mjs CHANGED
@@ -506,6 +506,8 @@ function extract (options) {
506
506
  *
507
507
  * If the result of this operation would trim an image to nothing then no change is made.
508
508
  *
509
+ * Use the `lineArt` and `threshold` options for control over sensitivity.
510
+ *
509
511
  * The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.
510
512
  *
511
513
  * @example
package/dist/sharp.cjs CHANGED
@@ -5,11 +5,13 @@
5
5
 
6
6
  // Inspects the runtime environment and exports the relevant sharp.node binary
7
7
 
8
+
8
9
  const { familySync, versionSync } = require("detect-libc");
9
10
 
10
11
  const libvips = require("./libvips.cjs");
11
12
  const pkg = require('../package.json');
12
13
 
14
+
13
15
  const { version } = pkg;
14
16
 
15
17
  const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = libvips;
package/dist/utility.cjs CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  const events = require('node:events');
7
+
7
8
  const { availableParallelism } = require("node:os");
8
9
  const detectLibc = require('detect-libc');
9
10
 
@@ -12,6 +13,7 @@ const libvips = require('./libvips.cjs');
12
13
  const sharp = require('./sharp.cjs');
13
14
  const pkg = require("../package.json");
14
15
 
16
+
15
17
  const runtimePlatform = libvips.runtimePlatformArch();
16
18
  const libvipsVersion = sharp.libvipsVersion();
17
19
 
package/lib/index.d.ts CHANGED
@@ -1183,7 +1183,7 @@ declare namespace sharp {
1183
1183
 
1184
1184
  type HeifCompression = 'av1' | 'hevc';
1185
1185
 
1186
- type HeifTune = 'iq' | 'ssim' | 'psnr';
1186
+ type HeifTune = 'auto' | 'iq' | 'psnr' | 'ssim';
1187
1187
 
1188
1188
  type Unit = 'inch' | 'cm';
1189
1189
 
@@ -1432,7 +1432,7 @@ declare namespace sharp {
1432
1432
  chromaSubsampling?: string | undefined;
1433
1433
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1434
1434
  bitdepth?: 8 | 10 | 12 | undefined;
1435
- /** Tune output for a quality metric, one of 'iq', 'ssim' or 'psnr' (optional, default 'iq') */
1435
+ /** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
1436
1436
  tune?: HeifTune | undefined;
1437
1437
  /** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
1438
1438
  encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
@@ -1451,7 +1451,7 @@ declare namespace sharp {
1451
1451
  chromaSubsampling?: string | undefined;
1452
1452
  /** Set bitdepth to 8, 10 or 12 bit (optional, default 8) */
1453
1453
  bitdepth?: 8 | 10 | 12 | undefined;
1454
- /** Tune output for a quality metric, one of 'ssim', 'psnr' or 'iq' (optional, default 'ssim') */
1454
+ /** Tune output for a quality metric, one of 'auto', 'iq', 'psnr' or 'ssim' (optional, default 'auto') */
1455
1455
  tune?: HeifTune | undefined;
1456
1456
  /** Which encoder libheif uses (must be compiled in) (optional, default 'auto') */
1457
1457
  encoder?: 'auto' | 'aom' | 'rav1e' | 'svt' | 'x265' | undefined;
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.35.0-revizly32",
4
+ "version": "0.35.0-revizly34",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -152,26 +152,26 @@
152
152
  "dependencies": {
153
153
  "@img/colour": "^1.1.0",
154
154
  "detect-libc": "^2.1.2",
155
- "semver": "^7.7.4"
155
+ "semver": "^7.8.2"
156
156
  },
157
157
  "optionalDependencies": {
158
- "@revizly/sharp-libvips-linux-arm64": "1.0.35",
159
- "@revizly/sharp-libvips-linux-x64": "1.0.35",
160
- "@revizly/sharp-linux-arm64": "0.35.0-revizly32",
161
- "@revizly/sharp-linux-x64": "0.35.0-revizly32"
158
+ "@revizly/sharp-libvips-linux-arm64": "1.0.37",
159
+ "@revizly/sharp-libvips-linux-x64": "1.0.37",
160
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly34",
161
+ "@revizly/sharp-linux-x64": "0.35.0-revizly34"
162
162
  },
163
163
  "devDependencies": {
164
- "@biomejs/biome": "^2.4.13",
164
+ "@biomejs/biome": "^2.4.16",
165
165
  "@cpplint/cli": "^0.1.0",
166
166
  "@emnapi/runtime": "^1.10.0",
167
- "@revizly/sharp-libvips-dev": "1.0.35",
167
+ "@revizly/sharp-libvips-dev": "1.0.37",
168
168
  "@types/node": "*",
169
169
  "emnapi": "^1.10.0",
170
170
  "exif-reader": "^2.0.3",
171
171
  "extract-zip": "^2.0.1",
172
172
  "icc": "^4.0.0",
173
- "node-addon-api": "^8.7.0",
174
- "node-gyp": "^12.3.0",
173
+ "node-addon-api": "^8.8.0",
174
+ "node-gyp": "^12.4.0",
175
175
  "tar-fs": "^3.1.2",
176
176
  "tsd": "^0.33.0"
177
177
  },
@@ -180,7 +180,7 @@
180
180
  "node": ">=20.9.0"
181
181
  },
182
182
  "config": {
183
- "libvips": ">=8.18.2"
183
+ "libvips": ">=8.18.3"
184
184
  },
185
185
  "funding": {
186
186
  "url": "https://opencollective.com/libvips"
package/src/common.h CHANGED
@@ -19,8 +19,8 @@
19
19
 
20
20
  #if (VIPS_MAJOR_VERSION < 8) || \
21
21
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 18) || \
22
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 2)
23
- #error "libvips version 8.18.2+ is required - please see https://sharp.pixelplumbing.com/install"
22
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 18 && VIPS_MICRO_VERSION < 3)
23
+ #error "libvips version 8.18.3+ is required - please see https://sharp.pixelplumbing.com/install"
24
24
  #endif
25
25
 
26
26
  #if defined(__has_include)
package/src/pipeline.h CHANGED
@@ -381,7 +381,7 @@ struct PipelineBaton {
381
381
  heifChromaSubsampling("4:4:4"),
382
382
  heifLossless(false),
383
383
  heifBitdepth(8),
384
- heifTune("ssim"),
384
+ heifTune("auto"),
385
385
  jxlDistance(1.0),
386
386
  jxlDecodingTier(0),
387
387
  jxlEffort(7),