sharp 0.33.1 → 0.33.2-rc.1

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 CHANGED
@@ -8,7 +8,7 @@ smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions
8
8
 
9
9
  It can be used with all JavaScript runtimes
10
10
  that provide support for Node-API v9, including
11
- Node.js >= 18.17.0, Deno and Bun.
11
+ Node.js (^18.17.0 or >= 20.3.0), Deno and Bun.
12
12
 
13
13
  Resizing an image is typically 4x-5x faster than using the
14
14
  quickest ImageMagick and GraphicsMagick settings
package/lib/index.d.ts CHANGED
@@ -341,6 +341,12 @@ declare namespace sharp {
341
341
  */
342
342
  metadata(): Promise<Metadata>;
343
343
 
344
+ /**
345
+ * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.
346
+ * @returns A sharp instance that can be used to chain operations
347
+ */
348
+ keepMetadata(): Sharp;
349
+
344
350
  /**
345
351
  * Access to pixel-derived image statistics for every channel in the image.
346
352
  * @returns A sharp instance that can be used to chain operations
package/lib/libvips.js CHANGED
@@ -7,6 +7,7 @@ const { spawnSync } = require('node:child_process');
7
7
  const { createHash } = require('node:crypto');
8
8
  const semverCoerce = require('semver/functions/coerce');
9
9
  const semverGreaterThanOrEqualTo = require('semver/functions/gte');
10
+ const semverSatisfies = require('semver/functions/satisfies');
10
11
  const detectLibc = require('detect-libc');
11
12
 
12
13
  const { engines, optionalDependencies } = require('../package.json');
@@ -83,6 +84,15 @@ const buildSharpLibvipsLibDir = () => {
83
84
  return '';
84
85
  };
85
86
 
87
+ const isUnsupportedNodeRuntime = () => {
88
+ /* istanbul ignore next */
89
+ if (process.release?.name === 'node' && process.versions) {
90
+ if (!semverSatisfies(process.versions.node, engines.node)) {
91
+ return { found: process.versions.node, expected: engines.node };
92
+ }
93
+ }
94
+ };
95
+
86
96
  /* istanbul ignore next */
87
97
  const isEmscripten = () => {
88
98
  const { CC } = process.env;
@@ -174,6 +184,7 @@ module.exports = {
174
184
  buildSharpLibvipsIncludeDir,
175
185
  buildSharpLibvipsCPlusPlusDir,
176
186
  buildSharpLibvipsLibDir,
187
+ isUnsupportedNodeRuntime,
177
188
  runtimePlatformArch,
178
189
  log,
179
190
  yarnLocator,
package/lib/operation.js CHANGED
@@ -24,6 +24,8 @@ const is = require('./is');
24
24
  * Only one rotation can occur per pipeline.
25
25
  * Previous calls to `rotate` in the same pipeline will be ignored.
26
26
  *
27
+ * Multi-page images can only be rotated by 180 degrees.
28
+ *
27
29
  * Method order is important when rotating, resizing and/or extracting regions,
28
30
  * for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.
29
31
  *
package/lib/sharp.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  const { familySync, versionSync } = require('detect-libc');
9
9
 
10
- const { runtimePlatformArch, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
10
+ const { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');
11
11
  const runtimePlatform = runtimePlatformArch();
12
12
 
13
13
  const paths = [
@@ -44,8 +44,16 @@ if (sharp) {
44
44
  const messages = errors.map(err => err.message).join(' ');
45
45
  help.push('Possible solutions:');
46
46
  // Common error messages
47
- if (prebuiltPlatforms.includes(runtimePlatform)) {
47
+ if (isUnsupportedNodeRuntime()) {
48
+ const { found, expected } = isUnsupportedNodeRuntime();
49
+ help.push(
50
+ '- Please upgrade Node.js:',
51
+ ` Found ${found}`,
52
+ ` Requires ${expected}`
53
+ );
54
+ } else if (prebuiltPlatforms.includes(runtimePlatform)) {
48
55
  const [os, cpu] = runtimePlatform.split('-');
56
+ const libc = os.endsWith('musl') ? ' --libc=musl' : '';
49
57
  help.push(
50
58
  '- Ensure optional dependencies can be installed:',
51
59
  ' npm install --include=optional sharp',
@@ -53,15 +61,14 @@ if (sharp) {
53
61
  '- Ensure your package manager supports multi-platform installation:',
54
62
  ' See https://sharp.pixelplumbing.com/install#cross-platform',
55
63
  '- Add platform-specific dependencies:',
56
- ` npm install --os=${os} --cpu=${cpu} sharp`,
57
- ` npm install --force @img/sharp-${runtimePlatform}`
64
+ ` npm install --os=${os.replace('musl', '')}${libc} --cpu=${cpu} sharp`
58
65
  );
59
66
  } else {
60
67
  help.push(
61
68
  `- Manually install libvips >= ${minimumLibvipsVersion}`,
62
69
  '- Add experimental WebAssembly-based dependencies:',
63
70
  ' npm install --cpu=wasm32 sharp',
64
- ' npm install --force @img/sharp-wasm32'
71
+ ' npm install @img/sharp-wasm32'
65
72
  );
66
73
  }
67
74
  if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {
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.33.1",
4
+ "version": "0.33.2-rc.1",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -141,36 +141,36 @@
141
141
  "semver": "^7.5.4"
142
142
  },
143
143
  "optionalDependencies": {
144
- "@img/sharp-darwin-arm64": "0.33.1",
145
- "@img/sharp-darwin-x64": "0.33.1",
146
- "@img/sharp-libvips-darwin-arm64": "1.0.0",
147
- "@img/sharp-libvips-darwin-x64": "1.0.0",
148
- "@img/sharp-libvips-linux-arm": "1.0.0",
149
- "@img/sharp-libvips-linux-arm64": "1.0.0",
150
- "@img/sharp-libvips-linux-s390x": "1.0.0",
151
- "@img/sharp-libvips-linux-x64": "1.0.0",
152
- "@img/sharp-libvips-linuxmusl-arm64": "1.0.0",
153
- "@img/sharp-libvips-linuxmusl-x64": "1.0.0",
154
- "@img/sharp-linux-arm": "0.33.1",
155
- "@img/sharp-linux-arm64": "0.33.1",
156
- "@img/sharp-linux-s390x": "0.33.1",
157
- "@img/sharp-linux-x64": "0.33.1",
158
- "@img/sharp-linuxmusl-arm64": "0.33.1",
159
- "@img/sharp-linuxmusl-x64": "0.33.1",
160
- "@img/sharp-wasm32": "0.33.1",
161
- "@img/sharp-win32-ia32": "0.33.1",
162
- "@img/sharp-win32-x64": "0.33.1"
144
+ "@img/sharp-darwin-arm64": "0.33.2-rc.1",
145
+ "@img/sharp-darwin-x64": "0.33.2-rc.1",
146
+ "@img/sharp-libvips-darwin-arm64": "1.0.1",
147
+ "@img/sharp-libvips-darwin-x64": "1.0.1",
148
+ "@img/sharp-libvips-linux-arm": "1.0.1",
149
+ "@img/sharp-libvips-linux-arm64": "1.0.1",
150
+ "@img/sharp-libvips-linux-s390x": "1.0.1",
151
+ "@img/sharp-libvips-linux-x64": "1.0.1",
152
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.1",
153
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.1",
154
+ "@img/sharp-linux-arm": "0.33.2-rc.1",
155
+ "@img/sharp-linux-arm64": "0.33.2-rc.1",
156
+ "@img/sharp-linux-s390x": "0.33.2-rc.1",
157
+ "@img/sharp-linux-x64": "0.33.2-rc.1",
158
+ "@img/sharp-linuxmusl-arm64": "0.33.2-rc.1",
159
+ "@img/sharp-linuxmusl-x64": "0.33.2-rc.1",
160
+ "@img/sharp-wasm32": "0.33.2-rc.1",
161
+ "@img/sharp-win32-ia32": "0.33.2-rc.1",
162
+ "@img/sharp-win32-x64": "0.33.2-rc.1"
163
163
  },
164
164
  "devDependencies": {
165
- "@emnapi/runtime": "^0.44.0",
166
- "@img/sharp-libvips-dev": "1.0.0",
167
- "@img/sharp-libvips-dev-wasm32": "1.0.0",
168
- "@img/sharp-libvips-win32-ia32": "1.0.0",
169
- "@img/sharp-libvips-win32-x64": "1.0.0",
165
+ "@emnapi/runtime": "^0.45.0",
166
+ "@img/sharp-libvips-dev": "1.0.1",
167
+ "@img/sharp-libvips-dev-wasm32": "1.0.1",
168
+ "@img/sharp-libvips-win32-ia32": "1.0.1",
169
+ "@img/sharp-libvips-win32-x64": "1.0.1",
170
170
  "@types/node": "*",
171
171
  "async": "^3.2.5",
172
172
  "cc": "^3.0.1",
173
- "emnapi": "^0.44.0",
173
+ "emnapi": "^0.45.0",
174
174
  "exif-reader": "^2.0.0",
175
175
  "extract-zip": "^2.0.1",
176
176
  "icc": "^3.0.0",
@@ -182,12 +182,12 @@
182
182
  "prebuild": "^12.1.0",
183
183
  "semistandard": "^17.0.0",
184
184
  "tar-fs": "^3.0.4",
185
- "tsd": "^0.29.0"
185
+ "tsd": "^0.30.3"
186
186
  },
187
187
  "license": "Apache-2.0",
188
188
  "engines": {
189
189
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0",
190
- "libvips": ">=8.15.0"
190
+ "libvips": ">=8.15.1"
191
191
  },
192
192
  "funding": {
193
193
  "url": "https://opencollective.com/libvips"
package/src/common.h CHANGED
@@ -16,8 +16,8 @@
16
16
 
17
17
  #if (VIPS_MAJOR_VERSION < 8) || \
18
18
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 15) || \
19
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 15 && VIPS_MICRO_VERSION < 0)
20
- #error "libvips version 8.15.0+ is required - please see https://sharp.pixelplumbing.com/install"
19
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 15 && VIPS_MICRO_VERSION < 1)
20
+ #error "libvips version 8.15.1+ is required - please see https://sharp.pixelplumbing.com/install"
21
21
  #endif
22
22
 
23
23
  #if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
package/src/pipeline.cc CHANGED
@@ -96,6 +96,9 @@ class PipelineWorker : public Napi::AsyncWorker {
96
96
  baton->rotationAngle != 0.0);
97
97
 
98
98
  if (autoRotation != VIPS_ANGLE_D0) {
99
+ if (autoRotation != VIPS_ANGLE_D180) {
100
+ MultiPageUnsupported(nPages, "Rotate");
101
+ }
99
102
  image = image.rot(autoRotation);
100
103
  autoRotation = VIPS_ANGLE_D0;
101
104
  }
@@ -114,6 +117,9 @@ class PipelineWorker : public Napi::AsyncWorker {
114
117
  baton->flop = FALSE;
115
118
  }
116
119
  if (rotation != VIPS_ANGLE_D0) {
120
+ if (rotation != VIPS_ANGLE_D180) {
121
+ MultiPageUnsupported(nPages, "Rotate");
122
+ }
117
123
  image = image.rot(rotation);
118
124
  rotation = VIPS_ANGLE_D0;
119
125
  }
@@ -397,6 +403,9 @@ class PipelineWorker : public Napi::AsyncWorker {
397
403
  rotation != VIPS_ANGLE_D0);
398
404
  // Auto-rotate post-extract
399
405
  if (autoRotation != VIPS_ANGLE_D0) {
406
+ if (autoRotation != VIPS_ANGLE_D180) {
407
+ MultiPageUnsupported(nPages, "Rotate");
408
+ }
400
409
  image = image.rot(autoRotation);
401
410
  }
402
411
  // Mirror vertically (up-down) about the x-axis
@@ -409,6 +418,9 @@ class PipelineWorker : public Napi::AsyncWorker {
409
418
  }
410
419
  // Rotate post-extract 90-angle
411
420
  if (rotation != VIPS_ANGLE_D0) {
421
+ if (rotation != VIPS_ANGLE_D180) {
422
+ MultiPageUnsupported(nPages, "Rotate");
423
+ }
412
424
  image = image.rot(rotation);
413
425
  }
414
426
 
@@ -561,6 +573,7 @@ class PipelineWorker : public Napi::AsyncWorker {
561
573
  VImage::option()->set("extend", baton->extendWith)->set("background", background));
562
574
  } else {
563
575
  std::vector<double> ignoredBackground(1);
576
+ image = sharp::StaySequential(image, baton->input->access);
564
577
  image = nPages > 1
565
578
  ? sharp::EmbedMultiPage(image,
566
579
  baton->extendLeft, baton->extendTop, baton->width, baton->height,