sharp 0.30.1 → 0.30.2

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/binding.gyp CHANGED
@@ -39,7 +39,6 @@
39
39
  'VCCLCompilerTool': {
40
40
  'ExceptionHandling': 1,
41
41
  'Optimization': 1,
42
- 'RuntimeLibrary': '2', # /MD
43
42
  'WholeProgramOptimization': 'true'
44
43
  },
45
44
  'VCLibrarianTool': {
@@ -206,7 +205,6 @@
206
205
  'VCCLCompilerTool': {
207
206
  'ExceptionHandling': 1,
208
207
  'Optimization': 1,
209
- 'RuntimeLibrary': '2', # /MD
210
208
  'WholeProgramOptimization': 'true'
211
209
  },
212
210
  'VCLibrarianTool': {
package/lib/composite.js CHANGED
@@ -162,7 +162,6 @@ function composite (images) {
162
162
  throw is.invalidParameterError('premultiplied', 'boolean', image.premultiplied);
163
163
  }
164
164
  }
165
-
166
165
  return composite;
167
166
  });
168
167
  return this;
package/lib/libvips.js CHANGED
@@ -86,9 +86,14 @@ const removeVendoredLibvips = function () {
86
86
  const pkgConfigPath = function () {
87
87
  if (process.platform !== 'win32') {
88
88
  const brewPkgConfigPath = spawnSync('which brew >/dev/null 2>&1 && eval $(brew --env) && echo $PKG_CONFIG_LIBDIR', spawnSyncOptions).stdout || '';
89
- return [brewPkgConfigPath.trim(), env.PKG_CONFIG_PATH, '/usr/local/lib/pkgconfig', '/usr/lib/pkgconfig']
90
- .filter(function (p) { return !!p; })
91
- .join(':');
89
+ return [
90
+ brewPkgConfigPath.trim(),
91
+ env.PKG_CONFIG_PATH,
92
+ '/usr/local/lib/pkgconfig',
93
+ '/usr/lib/pkgconfig',
94
+ '/usr/local/libdata/pkgconfig',
95
+ '/usr/libdata/pkgconfig'
96
+ ].filter(Boolean).join(':');
92
97
  } else {
93
98
  return '';
94
99
  }
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.30.1",
4
+ "version": "0.30.2",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -126,8 +126,8 @@
126
126
  "vips"
127
127
  ],
128
128
  "dependencies": {
129
- "color": "^4.2.0",
130
- "detect-libc": "^2.0.0",
129
+ "color": "^4.2.1",
130
+ "detect-libc": "^2.0.1",
131
131
  "node-addon-api": "^4.3.0",
132
132
  "prebuild-install": "^7.0.1",
133
133
  "semver": "^7.3.5",
@@ -143,7 +143,7 @@
143
143
  "exif-reader": "^1.0.3",
144
144
  "icc": "^2.0.0",
145
145
  "license-checker": "^25.0.1",
146
- "mocha": "^9.2.0",
146
+ "mocha": "^9.2.1",
147
147
  "mock-fs": "^5.1.2",
148
148
  "nyc": "^15.1.0",
149
149
  "prebuild": "^11.0.3",
package/src/common.cc CHANGED
@@ -398,6 +398,10 @@ namespace sharp {
398
398
  // From filesystem
399
399
  imageType = DetermineImageType(descriptor->file.data());
400
400
  if (imageType == ImageType::MISSING) {
401
+ if (descriptor->file.find("<svg") != std::string::npos) {
402
+ throw vips::VError("Input file is missing, did you mean "
403
+ "sharp(Buffer.from('" + descriptor->file.substr(0, 8) + "...')?");
404
+ }
401
405
  throw vips::VError("Input file is missing");
402
406
  }
403
407
  if (imageType != ImageType::UNKNOWN) {
package/src/pipeline.cc CHANGED
@@ -292,7 +292,8 @@ class PipelineWorker : public Napi::AsyncWorker {
292
292
  if (
293
293
  sharp::HasProfile(image) &&
294
294
  image.interpretation() != VIPS_INTERPRETATION_LABS &&
295
- image.interpretation() != VIPS_INTERPRETATION_GREY16
295
+ image.interpretation() != VIPS_INTERPRETATION_GREY16 &&
296
+ image.interpretation() != VIPS_INTERPRETATION_B_W
296
297
  ) {
297
298
  // Convert to sRGB/P3 using embedded profile
298
299
  try {
@@ -581,6 +582,8 @@ class PipelineWorker : public Napi::AsyncWorker {
581
582
 
582
583
  // Composite
583
584
  if (shouldComposite) {
585
+ std::vector<VImage> images = { image };
586
+ std::vector<int> modes, xs, ys;
584
587
  for (Composite *composite : baton->composite) {
585
588
  VImage compositeImage;
586
589
  sharp::ImageType compositeImageType = sharp::ImageType::UNKNOWN;
@@ -626,12 +629,12 @@ class PipelineWorker : public Napi::AsyncWorker {
626
629
  // gravity was used for extract_area, set it back to its default value of 0
627
630
  composite->gravity = 0;
628
631
  }
629
- // Ensure image to composite is sRGB with premultiplied alpha
632
+ // Ensure image to composite is sRGB with unpremultiplied alpha
630
633
  compositeImage = compositeImage.colourspace(VIPS_INTERPRETATION_sRGB);
631
634
  if (!sharp::HasAlpha(compositeImage)) {
632
635
  compositeImage = sharp::EnsureAlpha(compositeImage, 1);
633
636
  }
634
- if (!composite->premultiplied) compositeImage = compositeImage.premultiply();
637
+ if (composite->premultiplied) compositeImage = compositeImage.unpremultiply();
635
638
  // Calculate position
636
639
  int left;
637
640
  int top;
@@ -649,12 +652,12 @@ class PipelineWorker : public Napi::AsyncWorker {
649
652
  std::tie(left, top) = sharp::CalculateCrop(image.width(), image.height(),
650
653
  compositeImage.width(), compositeImage.height(), composite->gravity);
651
654
  }
652
- // Composite
653
- image = image.composite2(compositeImage, composite->mode, VImage::option()
654
- ->set("premultiplied", TRUE)
655
- ->set("x", left)
656
- ->set("y", top));
655
+ images.push_back(compositeImage);
656
+ modes.push_back(composite->mode);
657
+ xs.push_back(left);
658
+ ys.push_back(top);
657
659
  }
660
+ image = image.composite(images, modes, VImage::option()->set("x", xs)->set("y", ys));
658
661
  }
659
662
 
660
663
  // Reverse premultiplication after all transformations:
package/src/sharp.cc CHANGED
@@ -13,7 +13,6 @@
13
13
  // limitations under the License.
14
14
 
15
15
  #include <napi.h>
16
- #include <cstdlib>
17
16
  #include <vips/vips8>
18
17
 
19
18
  #include "common.h"
@@ -22,14 +21,6 @@
22
21
  #include "utilities.h"
23
22
  #include "stats.h"
24
23
 
25
- #if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005/8
26
- static void empty_invalid_parameter_handler(const wchar_t* expression,
27
- const wchar_t* function, const wchar_t* file, unsigned int line,
28
- uintptr_t reserved) {
29
- // No-op.
30
- }
31
- #endif
32
-
33
24
  static void* sharp_vips_init(void*) {
34
25
  g_setenv("VIPS_MIN_STACK_SIZE", "2m", FALSE);
35
26
  vips_init("sharp");
@@ -43,13 +34,6 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
43
34
  g_log_set_handler("VIPS", static_cast<GLogLevelFlags>(G_LOG_LEVEL_WARNING),
44
35
  static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
45
36
 
46
- // Tell the CRT to not exit the application when an invalid parameter is
47
- // passed. The main issue is that invalid FDs will trigger this behaviour.
48
- // See: https://github.com/libvips/libvips/pull/2571.
49
- #if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005/8
50
- _set_invalid_parameter_handler(empty_invalid_parameter_handler);
51
- #endif
52
-
53
37
  // Methods available to JavaScript
54
38
  exports.Set("metadata", Napi::Function::New(env, metadata));
55
39
  exports.Set("pipeline", Napi::Function::New(env, pipeline));