@revizly/sharp 0.35.0-revizly51 → 0.35.0-revizly53

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/dist/channel.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/channel.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/colour.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/colour.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/index.d.cts CHANGED
@@ -775,7 +775,7 @@ declare namespace sharp {
775
775
  * Use these JPEG-XL (JXL) options for output image.
776
776
  * This feature is experimental, please do not use in production systems.
777
777
  * Requires libvips compiled with support for libjxl.
778
- * The prebuilt binaries do not include this.
778
+ * The `@revizly` prebuilt binaries include this.
779
779
  * Image metadata (EXIF, XMP) is unsupported.
780
780
  * @param options Output options.
781
781
  * @throws {Error} Invalid options
package/dist/index.d.mts CHANGED
@@ -769,7 +769,7 @@ export interface Sharp extends Duplex {
769
769
  * Use these JPEG-XL (JXL) options for output image.
770
770
  * This feature is experimental, please do not use in production systems.
771
771
  * Requires libvips compiled with support for libjxl.
772
- * The prebuilt binaries do not include this.
772
+ * The `@revizly` prebuilt binaries include this.
773
773
  * Image metadata (EXIF, XMP) is unsupported.
774
774
  * @param options Output options.
775
775
  * @throws {Error} Invalid options
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/input.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/input.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/is.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/is.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/libvips.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/libvips.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/output.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1326,8 +1326,7 @@ function heif (options) {
1326
1326
  * This feature is experimental, please do not use in production systems.
1327
1327
  *
1328
1328
  * Requires libvips compiled with support for libjxl.
1329
- * The prebuilt binaries do not include this - see
1330
- * {@link /install/#custom-libvips installing a custom libvips}.
1329
+ * The `@revizly` prebuilt binaries include this.
1331
1330
  *
1332
1331
  * @since 0.31.3
1333
1332
  *
package/dist/output.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -1326,8 +1326,7 @@ function heif (options) {
1326
1326
  * This feature is experimental, please do not use in production systems.
1327
1327
  *
1328
1328
  * Requires libvips compiled with support for libjxl.
1329
- * The prebuilt binaries do not include this - see
1330
- * {@link /install/#custom-libvips installing a custom libvips}.
1329
+ * The `@revizly` prebuilt binaries include this.
1331
1330
  *
1332
1331
  * @since 0.31.3
1333
1332
  *
package/dist/resize.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/resize.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/sharp.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/sharp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/utility.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/dist/utility.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/install/build.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/lib/index.d.ts CHANGED
@@ -775,7 +775,7 @@ declare namespace sharp {
775
775
  * Use these JPEG-XL (JXL) options for output image.
776
776
  * This feature is experimental, please do not use in production systems.
777
777
  * Requires libvips compiled with support for libjxl.
778
- * The prebuilt binaries do not include this.
778
+ * The `@revizly` prebuilt binaries include this.
779
779
  * Image metadata (EXIF, XMP) is unsupported.
780
780
  * @param options Output options.
781
781
  * @throws {Error} Invalid options
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-revizly51",
4
+ "version": "0.35.0-revizly53",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://sharp.pixelplumbing.com",
7
7
  "contributors": [
@@ -163,10 +163,10 @@
163
163
  "semver": "^7.8.5"
164
164
  },
165
165
  "optionalDependencies": {
166
- "@revizly/sharp-libvips-linux-arm64": "1.0.52",
167
- "@revizly/sharp-libvips-linux-x64": "1.0.52",
168
- "@revizly/sharp-linux-arm64": "0.35.0-revizly51",
169
- "@revizly/sharp-linux-x64": "0.35.0-revizly51"
166
+ "@revizly/sharp-libvips-linux-arm64": "1.0.54",
167
+ "@revizly/sharp-libvips-linux-x64": "1.0.54",
168
+ "@revizly/sharp-linux-arm64": "0.35.0-revizly53",
169
+ "@revizly/sharp-linux-x64": "0.35.0-revizly53"
170
170
  },
171
171
  "peerDependenciesMeta": {
172
172
  "@types/node": {
@@ -177,7 +177,7 @@
177
177
  "@biomejs/biome": "^2.5.14",
178
178
  "@cpplint/cli": "^0.1.0",
179
179
  "@emnapi/runtime": "^1.11.3",
180
- "@revizly/sharp-libvips-dev": "1.0.52",
180
+ "@revizly/sharp-libvips-dev": "1.0.54",
181
181
  "@types/node": "*",
182
182
  "emnapi": "^1.11.3",
183
183
  "exif-reader": "^2.0.3",
package/src/binding.gyp CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2013 Lovell Fuller and others.
1
+ # SPDX-FileCopyrightText: 2013 Lovell Fuller and others
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  { # noqa: B018
package/src/common.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -635,7 +635,7 @@ namespace sharp {
635
635
  if (HasProfile(image)) {
636
636
  size_t length;
637
637
  const void *data = image.get_blob(VIPS_META_ICC_NAME, &length);
638
- icc.first = static_cast<char*>(vips_malloc(reinterpret_cast<VipsObject*>(image.get_image()), length));
638
+ icc.first = static_cast<char*>(g_malloc(length));
639
639
  icc.second = length;
640
640
  memcpy(icc.first, data, length);
641
641
  }
@@ -648,7 +648,7 @@ namespace sharp {
648
648
  VImage SetProfile(VImage image, std::pair<char*, size_t> icc) {
649
649
  if (icc.first != nullptr) {
650
650
  image = image.copy();
651
- image.set(VIPS_META_ICC_NAME, nullptr, icc.first, icc.second);
651
+ image.set(VIPS_META_ICC_NAME, reinterpret_cast<VipsCallbackFn>(vips_area_free_cb), icc.first, icc.second);
652
652
  }
653
653
  return image;
654
654
  }
@@ -720,7 +720,7 @@ namespace sharp {
720
720
  if (hasDelay) {
721
721
  if (delay.size() == 1) {
722
722
  // We have just one delay, repeat that value for all frames.
723
- delay.insert(delay.end(), nPages - 1, delay[0]);
723
+ delay.insert(delay.end(), std::max(0, nPages - 1), delay[0]);
724
724
  }
725
725
  copy.set("delay", delay);
726
726
  }
package/src/common.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/metadata.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/metadata.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/operations.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/operations.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/pipeline.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
@@ -78,7 +78,20 @@ class PipelineWorker : public Napi::AsyncWorker {
78
78
  }
79
79
  }
80
80
  VipsAccess access = baton->input->access;
81
- image = sharp::EnsureColourspace(image, baton->colourspacePipeline);
81
+ // A device-independent colourspace is reached through the ICC profile connection space, either Lab or XYZ
82
+ bool const labPcs =
83
+ baton->colourspacePipeline == VIPS_INTERPRETATION_LAB ||
84
+ baton->colourspacePipeline == VIPS_INTERPRETATION_LABS ||
85
+ baton->colourspacePipeline == VIPS_INTERPRETATION_LCH;
86
+ bool const xyzPcs =
87
+ baton->colourspacePipeline == VIPS_INTERPRETATION_scRGB ||
88
+ baton->colourspacePipeline == VIPS_INTERPRETATION_XYZ ||
89
+ baton->colourspacePipeline == VIPS_INTERPRETATION_YXY;
90
+ // lcms needs 8/16-bit device values, so the conversion must wait for the import
91
+ bool const deferColourspace = sharp::HasProfile(image) && (labPcs || xyzPcs);
92
+ if (!deferColourspace) {
93
+ image = sharp::EnsureColourspace(image, baton->colourspacePipeline);
94
+ }
82
95
 
83
96
  int nPages = baton->input->pages;
84
97
  if (nPages == -1) {
@@ -372,6 +385,7 @@ class PipelineWorker : public Napi::AsyncWorker {
372
385
  baton->input->ignoreIcc = true;
373
386
  }
374
387
  char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb";
388
+ bool importedToPcs = false;
375
389
  if (
376
390
  sharp::HasProfile(image) &&
377
391
  image.interpretation() != VIPS_INTERPRETATION_LABS &&
@@ -381,10 +395,20 @@ class PipelineWorker : public Napi::AsyncWorker {
381
395
  ) {
382
396
  // Convert to sRGB/P3 using embedded profile
383
397
  try {
384
- image = image.icc_transform(processingProfile, VImage::option()
385
- ->set("embedded", true)
386
- ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
387
- ->set("intent", VIPS_INTENT_PERCEPTUAL));
398
+ if (deferColourspace &&
399
+ (image.format() == VIPS_FORMAT_UCHAR || image.format() == VIPS_FORMAT_USHORT)) {
400
+ // XYZ PCS is linear and device-independent, so colour management and linearisation are a single operation
401
+ image = image.icc_import(VImage::option()
402
+ ->set("embedded", true)
403
+ ->set("pcs", labPcs ? VIPS_PCS_LAB : VIPS_PCS_XYZ)
404
+ ->set("intent", VIPS_INTENT_PERCEPTUAL));
405
+ importedToPcs = true;
406
+ } else {
407
+ image = image.icc_transform(processingProfile, VImage::option()
408
+ ->set("embedded", true)
409
+ ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
410
+ ->set("intent", VIPS_INTENT_PERCEPTUAL));
411
+ }
388
412
  } catch(...) {
389
413
  sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid embedded profile", nullptr);
390
414
  }
@@ -397,6 +421,10 @@ class PipelineWorker : public Napi::AsyncWorker {
397
421
  ->set("intent", VIPS_INTENT_PERCEPTUAL));
398
422
  }
399
423
 
424
+ if (deferColourspace) {
425
+ image = sharp::EnsureColourspace(image, baton->colourspacePipeline);
426
+ }
427
+
400
428
  // Flatten image to remove alpha channel
401
429
  if (baton->flatten && image.has_alpha()) {
402
430
  image = sharp::Flatten(image, baton->flattenBackground);
@@ -638,15 +666,17 @@ class PipelineWorker : public Napi::AsyncWorker {
638
666
  std::tie(image, background) = sharp::ApplyAlpha(image, baton->extendBackground, shouldPremultiplyAlpha);
639
667
  }
640
668
  image = sharp::StaySequential(image, nPages > 1 || baton->extendWith != VIPS_EXTEND_BACKGROUND);
641
- auto options = VImage::option()->set("extend", baton->extendWith);
642
- if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
643
- options->set("background", background);
669
+ if (nPages > 1) {
670
+ image = sharp::EmbedMultiPage(image,
671
+ baton->extendLeft, baton->extendTop, baton->width, baton->height,
672
+ baton->extendWith, background, nPages, &targetPageHeight);
673
+ } else {
674
+ auto options = VImage::option()->set("extend", baton->extendWith);
675
+ if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
676
+ options->set("background", background);
677
+ }
678
+ image = image.embed(baton->extendLeft, baton->extendTop, baton->width, baton->height, options);
644
679
  }
645
- image = nPages > 1
646
- ? sharp::EmbedMultiPage(image,
647
- baton->extendLeft, baton->extendTop, baton->width, baton->height,
648
- baton->extendWith, background, nPages, &targetPageHeight)
649
- : image.embed(baton->extendLeft, baton->extendTop, baton->width, baton->height, options);
650
680
  if (baton->keepGainMap) {
651
681
  gainMap = gainMap.embed(baton->extendLeft / gainMapScaleFactor, baton->extendTop / gainMapScaleFactor,
652
682
  baton->width / gainMapScaleFactor, baton->height / gainMapScaleFactor, VImage::option()
@@ -880,6 +910,19 @@ class PipelineWorker : public Napi::AsyncWorker {
880
910
  image = sharp::EnsureAlpha(image, baton->ensureAlpha);
881
911
  }
882
912
 
913
+ // Leave PCS before the output colourspace is applied, which would gamut-clip
914
+ if (importedToPcs) {
915
+ try {
916
+ image = image.colourspace(VIPS_INTERPRETATION_XYZ).icc_export(VImage::option()
917
+ ->set("output_profile", baton->withIccProfile.empty()
918
+ ? processingProfile
919
+ : const_cast<char*>(baton->withIccProfile.data()))
920
+ ->set("intent", VIPS_INTENT_PERCEPTUAL));
921
+ } catch(...) {
922
+ sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid profile", nullptr);
923
+ }
924
+ }
925
+
883
926
  // Ensure output colour space
884
927
  if (sharp::Is16Bit(image.interpretation())) {
885
928
  image = image.cast(VIPS_FORMAT_USHORT);
@@ -888,7 +931,11 @@ class PipelineWorker : public Napi::AsyncWorker {
888
931
  image = image.colourspace(baton->colourspace, VImage::option()->set("source_space", image.interpretation()));
889
932
  if (inputProfile.first != nullptr && baton->withIccProfile.empty()) {
890
933
  image = sharp::SetProfile(image, inputProfile);
934
+ } else {
935
+ g_free(inputProfile.first);
891
936
  }
937
+ } else {
938
+ g_free(inputProfile.first);
892
939
  }
893
940
 
894
941
  // Extract channel
@@ -913,7 +960,7 @@ class PipelineWorker : public Napi::AsyncWorker {
913
960
  }
914
961
 
915
962
  // Apply output ICC profile
916
- if (!baton->withIccProfile.empty()) {
963
+ if (!importedToPcs && !baton->withIccProfile.empty()) {
917
964
  try {
918
965
  image = image.icc_transform(const_cast<char*>(baton->withIccProfile.data()), VImage::option()
919
966
  ->set("input_profile", processingProfile)
@@ -1383,8 +1430,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1383
1430
  baton->formatOut = "v";
1384
1431
  } else {
1385
1432
  // Unsupported output format
1386
- (baton->err).append("Unsupported output format " + baton->fileOut);
1387
- return Error();
1433
+ throw std::runtime_error("Unsupported output format " + baton->fileOut);
1388
1434
  }
1389
1435
  }
1390
1436
  } catch (std::runtime_error const &err) {
@@ -1467,7 +1513,7 @@ class PipelineWorker : public Napi::AsyncWorker {
1467
1513
  // ECMAScript ArrayBuffer with Uint8Array view
1468
1514
  Napi::TypedArrayOf<uint8_t> data = Napi::Buffer<char>::Copy(env,
1469
1515
  static_cast<char*>(baton->bufferOut), baton->bufferOutLength);
1470
- sharp::FreeCallback(static_cast<char*>(baton->bufferOut), nullptr);
1516
+ sharp::FreeCallback(nullptr, static_cast<char*>(baton->bufferOut));
1471
1517
  Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), data, info });
1472
1518
  } else {
1473
1519
  // Node.js Buffer
@@ -1659,6 +1705,8 @@ class PipelineWorker : public Napi::AsyncWorker {
1659
1705
  image = image.copy();
1660
1706
  image.set("gainmap-data", reinterpret_cast<VipsCallbackFn>(vips_area_free_cb),
1661
1707
  gainMapJpeg->data, gainMapJpeg->length);
1708
+ gainMapJpeg->free_fn = nullptr;
1709
+ vips_area_unref(gainMapJpeg);
1662
1710
  return image;
1663
1711
  }
1664
1712
 
package/src/pipeline.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/sharp.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/stats.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/stats.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/utilities.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
 
package/src/utilities.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- Copyright 2013 Lovell Fuller and others.
2
+ SPDX-FileCopyrightText: 2013 Lovell Fuller and others
3
3
  SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5