sharp 0.32.5 → 0.32.6

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/index.d.ts CHANGED
@@ -139,6 +139,52 @@ declare namespace sharp {
139
139
  */
140
140
  function simd(enable?: boolean): boolean;
141
141
 
142
+ /**
143
+ * Block libvips operations at runtime.
144
+ *
145
+ * This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,
146
+ * which when set will block all "untrusted" operations.
147
+ *
148
+ * @since 0.32.4
149
+ *
150
+ * @example <caption>Block all TIFF input.</caption>
151
+ * sharp.block({
152
+ * operation: ['VipsForeignLoadTiff']
153
+ * });
154
+ *
155
+ * @param {Object} options
156
+ * @param {Array<string>} options.operation - List of libvips low-level operation names to block.
157
+ */
158
+ function block(options: { operation: string[] }): void;
159
+
160
+ /**
161
+ * Unblock libvips operations at runtime.
162
+ *
163
+ * This is useful for defining a list of allowed operations.
164
+ *
165
+ * @since 0.32.4
166
+ *
167
+ * @example <caption>Block all input except WebP from the filesystem.</caption>
168
+ * sharp.block({
169
+ * operation: ['VipsForeignLoad']
170
+ * });
171
+ * sharp.unblock({
172
+ * operation: ['VipsForeignLoadWebpFile']
173
+ * });
174
+ *
175
+ * @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>
176
+ * sharp.block({
177
+ * operation: ['VipsForeignLoad']
178
+ * });
179
+ * sharp.unblock({
180
+ * operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']
181
+ * });
182
+ *
183
+ * @param {Object} options
184
+ * @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.
185
+ */
186
+ function unblock(options: { operation: string[] }): void;
187
+
142
188
  //#endregion
143
189
 
144
190
  const gravity: GravityEnum;
package/lib/operation.js CHANGED
@@ -19,7 +19,7 @@ const is = require('./is');
19
19
  * If no angle is provided, it is determined from the EXIF data.
20
20
  * Mirroring is supported and may infer the use of a flip operation.
21
21
  *
22
- * The use of `rotate` implies the removal of the EXIF `Orientation` tag, if any.
22
+ * The use of `rotate` without an angle will remove the EXIF `Orientation` tag, if any.
23
23
  *
24
24
  * Only one rotation can occur per pipeline.
25
25
  * Previous calls to `rotate` in the same pipeline will be ignored.
@@ -83,8 +83,6 @@ function rotate (angle, options) {
83
83
  * Mirror the image vertically (up-down) about the x-axis.
84
84
  * This always occurs before rotation, if any.
85
85
  *
86
- * The use of `flip` implies the removal of the EXIF `Orientation` tag, if any.
87
- *
88
86
  * This operation does not work correctly with multi-page images.
89
87
  *
90
88
  * @example
@@ -102,8 +100,6 @@ function flip (flip) {
102
100
  * Mirror the image horizontally (left-right) about the y-axis.
103
101
  * This always occurs before rotation, if any.
104
102
  *
105
- * The use of `flop` implies the removal of the EXIF `Orientation` tag, if any.
106
- *
107
103
  * @example
108
104
  * const output = await sharp(input).flop().toBuffer();
109
105
  *
package/lib/output.js CHANGED
@@ -162,8 +162,8 @@ function toBuffer (options, callback) {
162
162
 
163
163
  /**
164
164
  * Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
165
- * This will also convert to and add a web-friendly sRGB ICC profile unless a custom
166
- * output profile is provided.
165
+ * This will also convert to and add a web-friendly sRGB ICC profile if appropriate,
166
+ * unless a custom output profile is provided.
167
167
  *
168
168
  * The default behaviour, when `withMetadata` is not used, is to convert to the device-independent
169
169
  * sRGB colour space and strip all metadata, including the removal of any ICC profile.
@@ -1046,6 +1046,7 @@ function jxl (options) {
1046
1046
  *
1047
1047
  * @param {Object} [options] - output options
1048
1048
  * @param {string} [options.depth='uchar'] - bit depth, one of: char, uchar (default), short, ushort, int, uint, float, complex, double, dpcomplex
1049
+ * @returns {Sharp}
1049
1050
  * @throws {Error} Invalid options
1050
1051
  */
1051
1052
  function raw (options) {
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.5",
4
+ "version": "0.32.6",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -153,25 +153,25 @@
153
153
  "mocha": "^10.2.0",
154
154
  "mock-fs": "^5.2.0",
155
155
  "nyc": "^15.1.0",
156
- "prebuild": "lovell/prebuild#add-nodejs-20-drop-nodejs-10-and-12",
156
+ "prebuild": "^12.0.0",
157
157
  "semistandard": "^16.0.1",
158
- "tsd": "^0.28.1"
158
+ "tsd": "^0.29.0"
159
159
  },
160
160
  "license": "Apache-2.0",
161
161
  "config": {
162
- "libvips": "8.14.4",
162
+ "libvips": "8.14.5",
163
163
  "integrity": {
164
- "darwin-arm64v8": "sha512-jZt5+ZBQzdloop9z/XlOAy8jHxD+ZGt3J8YUm1g3njjjKmZ/RmM9r6QAeLLILe67ATHaaAtmCil37fDc400OrQ==",
165
- "darwin-x64": "sha512-Mhpr8n8CjrU+u5K9YLucmkCgwtJGexECLOZejPfqM8CiOMerowR0wJTuSt9WTOtb9qGOL/ndybfrymsw+YH8PA==",
166
- "linux-arm64v8": "sha512-k2PiOOv8amzS4m5jc4Vceozv8h041IoyHL/1s0Rj290jg3w6BUJL3V+TLwKUPM35i7rV5rm14gtnGZ7qKENdmA==",
167
- "linux-armv6": "sha512-CuPTo50owR8P+BCCcWk1tF4qB3XSAaHeaIzSanJM/v9zBZfUfMGI0OLv+ByyHCL3BE2CbGXaSXhuEVw2JQ08Sw==",
168
- "linux-armv7": "sha512-CvD6fMy9PkZk1m2UPTWDcFfcD4qFA3RALyAWIih8ftOY9ksI3Y4uz6c0ML+ixBl0hqQK3WEg6+ac5TGDjZbbYA==",
169
- "linux-x64": "sha512-vqoV61ka2hBYQ5582nQlyUcVPtItu927mng9RUU9nyO4Wt50z9nNT/pfcYEfF2jkBNW9JaiMaj6bENHgxA6mMg==",
170
- "linuxmusl-arm64v8": "sha512-iCyl0y/qxdvgGidsYn11R8d4TEcU92uYHtYI8FSHyUobZw/9i2y3189PUTQ/fw44oqaBzTR3p9NF2eP6aLT9gQ==",
171
- "linuxmusl-x64": "sha512-qj7IUqWUqCtxECpgNp4E1NcIbsNe1ujzBuJcnnQot7GZOuPUhI5N6ZUhozmh6LfbGFdBZpPc/JFh1eDZ0IEpbQ==",
172
- "win32-arm64v8": "sha512-VRi7fpE9Kb3xQGcNmPPTJnWGAEUMq+YOq9abpaIIB2r3Ax327/7wHS7o2ezD6zQKdxIX6gODC5io/hReIJ9Jnw==",
173
- "win32-ia32": "sha512-EnvtU7Q6+pjl5/Y1/UngCFDM2CSqpYWVDwY03ilUKSuqTeDKTJYyus0rJ+n6p4nmdjJlVdhYlkvpy8kkEAtDHg==",
174
- "win32-x64": "sha512-fCl/KQuSijVYC8hULWbff8Mfuh3vjjdz4j5p73VgdLP6aZUrHctbhBvEIe0aQ8HpmcGdBnATX5pXUQ4GDl3mwQ=="
164
+ "darwin-arm64v8": "sha512-1QZzICfCJd4wAO0P6qmYI5e5VFMt9iCE4QgefI8VMMbdSzjIXA9L/ARN6pkMQPZ3h20Y9RtJ2W1skgCsvCIccw==",
165
+ "darwin-x64": "sha512-sMIKMYXsdU9FlIfztj6Kt/SfHlhlDpP0Ups7ftVFqwjaszmYmpI9y/d/q3mLb4jrzuSiSUEislSWCwBnW7MPTw==",
166
+ "linux-arm64v8": "sha512-CD8owELzkDumaom+O3jJ8fKamILAQdj+//KK/VNcHK3sngUcFpdjx36C8okwbux9sml/T7GTB/gzpvReDrAejQ==",
167
+ "linux-armv6": "sha512-wk6IPHatDFVWKJy7lI1TJezHGHPQut1wF2bwx256KlZwXUQU3fcVcMpV1zxXjgLFewHq2+uhyMkoSGBPahWzlA==",
168
+ "linux-armv7": "sha512-HEZC9KYtkmBK5rUR2MqBhrVarnQVZ/TwLUeLkKq0XuoM2pc/eXI6N0Fh5NGEFwdXI2XE8g1ySf+OYS6DDi+xCQ==",
169
+ "linux-x64": "sha512-SlFWrITSW5XVUkaFPQOySAaSGXnhkGJCj8X2wGYYta9hk5piZldQyMp4zwy0z6UeRu1qKTKtZvmq28W3Gnh9xA==",
170
+ "linuxmusl-arm64v8": "sha512-ga9iX7WUva3sG/VsKkOD318InLlCfPIztvzCZKZ2/+izQXRbQi8VoXWMHgEN4KHACv45FTl7mJ/8CRqUzhS8wQ==",
171
+ "linuxmusl-x64": "sha512-yeaHnpfee1hrZLok2l4eFceHzlfq8gN3QOu0R4Mh8iMK5O5vAUu97bdtxeZZeJJvHw8tfh2/msGi0qysxKN8bw==",
172
+ "win32-arm64v8": "sha512-kR91hy9w1+GEXK56hLh51+hBCBo7T+ijM4Slkmvb/2PsYZySq5H7s61n99iDYl6kTJP2y9sW5Xcvm3uuXDaDgg==",
173
+ "win32-ia32": "sha512-HrnofEbzHNpHJ0vVnjsTj5yfgVdcqdWshXuwFO2zc8xlEjA83BvXZ0lVj9MxPxkxJ2ta+/UlLr+CFzc5bOceMw==",
174
+ "win32-x64": "sha512-BwKckinJZ0Fu/EcunqiLPwOLEBWp4xf8GV7nvmVuKKz5f6B+GxoA2k9aa2wueqv4r4RJVgV/aWXZWFKOIjre/Q=="
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 < 4)
19
- #error "libvips version 8.14.4+ is required - please see https://sharp.pixelplumbing.com/install"
18
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 14 && VIPS_MICRO_VERSION < 5)
19
+ #error "libvips version 8.14.5+ 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/pipeline.cc CHANGED
@@ -326,7 +326,7 @@ class PipelineWorker : public Napi::AsyncWorker {
326
326
  try {
327
327
  image = image.icc_transform(processingProfile, VImage::option()
328
328
  ->set("embedded", TRUE)
329
- ->set("depth", image.interpretation() == VIPS_INTERPRETATION_RGB16 ? 16 : 8)
329
+ ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
330
330
  ->set("intent", VIPS_INTENT_PERCEPTUAL));
331
331
  } catch(...) {
332
332
  sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid embedded profile", nullptr);
@@ -653,7 +653,7 @@ class PipelineWorker : public Napi::AsyncWorker {
653
653
  if (across != 0 || down != 0) {
654
654
  int left;
655
655
  int top;
656
- compositeImage = compositeImage.replicate(across, down);
656
+ compositeImage = sharp::StaySequential(compositeImage, access).replicate(across, down);
657
657
  if (composite->hasOffset) {
658
658
  std::tie(left, top) = sharp::CalculateCrop(
659
659
  compositeImage.width(), compositeImage.height(), image.width(), image.height(),
@@ -763,6 +763,7 @@ class PipelineWorker : public Napi::AsyncWorker {
763
763
  if (baton->withMetadata && sharp::HasProfile(image) && baton->withMetadataIcc.empty()) {
764
764
  image = image.icc_transform("srgb", VImage::option()
765
765
  ->set("embedded", TRUE)
766
+ ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
766
767
  ->set("intent", VIPS_INTENT_PERCEPTUAL));
767
768
  }
768
769
  }
@@ -794,6 +795,7 @@ class PipelineWorker : public Napi::AsyncWorker {
794
795
  VImage::option()
795
796
  ->set("input_profile", processingProfile)
796
797
  ->set("embedded", TRUE)
798
+ ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
797
799
  ->set("intent", VIPS_INTENT_PERCEPTUAL));
798
800
  }
799
801
  // Override EXIF Orientation tag