@basemaps/lambda-tiler 6.16.1 → 6.20.0

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +2 -2
  3. package/build/__test__/tile.style.json.test.d.ts +2 -0
  4. package/build/__test__/tile.style.json.test.d.ts.map +1 -0
  5. package/build/__test__/tile.style.json.test.js +33 -0
  6. package/build/__test__/xyz.test.js +35 -34
  7. package/build/cli/dump.js +2 -2
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +10 -0
  10. package/build/routes/esri/rest.d.ts +10 -0
  11. package/build/routes/esri/rest.d.ts.map +1 -0
  12. package/build/routes/esri/rest.js +87 -0
  13. package/build/routes/imagery.d.ts +10 -0
  14. package/build/routes/imagery.d.ts.map +1 -0
  15. package/build/routes/imagery.js +50 -0
  16. package/build/routes/response.d.ts +4 -0
  17. package/build/routes/response.d.ts.map +1 -0
  18. package/build/routes/response.js +3 -0
  19. package/build/routes/tile.d.ts +0 -20
  20. package/build/routes/tile.d.ts.map +1 -1
  21. package/build/routes/tile.js +11 -164
  22. package/build/routes/tile.json.d.ts +10 -0
  23. package/build/routes/tile.json.d.ts.map +1 -0
  24. package/build/routes/tile.json.js +31 -0
  25. package/build/routes/tile.style.json.d.ts +10 -0
  26. package/build/routes/tile.style.json.d.ts.map +1 -0
  27. package/build/routes/tile.style.json.js +74 -0
  28. package/build/routes/tile.wmts.d.ts +9 -0
  29. package/build/routes/tile.wmts.d.ts.map +1 -0
  30. package/build/routes/tile.wmts.js +57 -0
  31. package/build/routes/tile.xyz.d.ts +13 -0
  32. package/build/routes/tile.xyz.d.ts.map +1 -0
  33. package/build/routes/tile.xyz.js +28 -0
  34. package/build/tile.set.raster.d.ts +2 -0
  35. package/build/tile.set.raster.d.ts.map +1 -1
  36. package/build/tile.set.raster.js +3 -1
  37. package/build/tile.set.vector.js +1 -1
  38. package/dist/index.js +10580 -9573
  39. package/dist/node_modules/color/README.md +7 -7
  40. package/dist/node_modules/color/index.js +173 -158
  41. package/dist/node_modules/color/package.json +18 -16
  42. package/dist/node_modules/color-convert/conversions.js +281 -310
  43. package/dist/node_modules/color-convert/index.js +27 -24
  44. package/dist/node_modules/color-convert/package.json +16 -14
  45. package/dist/node_modules/color-convert/route.js +22 -22
  46. package/dist/node_modules/color-name/package.json +17 -14
  47. package/dist/node_modules/color-string/index.js +2 -2
  48. package/dist/node_modules/color-string/package.json +10 -10
  49. package/dist/node_modules/decompress-response/index.d.ts +14 -21
  50. package/dist/node_modules/decompress-response/index.js +34 -16
  51. package/dist/node_modules/decompress-response/license +1 -1
  52. package/dist/node_modules/decompress-response/package.json +23 -17
  53. package/dist/node_modules/decompress-response/readme.md +2 -6
  54. package/dist/node_modules/detect-libc/package.json +0 -1
  55. package/dist/node_modules/mimic-response/index.d.ts +2 -2
  56. package/dist/node_modules/mimic-response/index.js +41 -2
  57. package/dist/node_modules/mimic-response/package.json +17 -17
  58. package/dist/node_modules/mimic-response/readme.md +22 -1
  59. package/dist/node_modules/node-abi/.circleci/config.yml +63 -0
  60. package/dist/node_modules/node-abi/.releaserc.json +9 -0
  61. package/dist/node_modules/node-abi/abi_registry.json +39 -4
  62. package/dist/node_modules/node-abi/index.js +5 -2
  63. package/dist/node_modules/node-abi/package.json +17 -16
  64. package/dist/node_modules/node-abi/test/index.js +7 -15
  65. package/dist/node_modules/node-addon-api/README.md +2 -2
  66. package/dist/node_modules/node-addon-api/except.gypi +20 -11
  67. package/dist/node_modules/node-addon-api/napi-inl.h +734 -196
  68. package/dist/node_modules/node-addon-api/napi.h +420 -164
  69. package/dist/node_modules/node-addon-api/noexcept.gypi +21 -11
  70. package/dist/node_modules/node-addon-api/package.json +43 -14
  71. package/dist/node_modules/node-addon-api/tools/clang-format.js +18 -17
  72. package/dist/node_modules/node-addon-api/tools/eslint-format.js +71 -0
  73. package/dist/node_modules/prebuild-install/CHANGELOG.md +24 -7
  74. package/dist/node_modules/prebuild-install/README.md +24 -4
  75. package/dist/node_modules/prebuild-install/asset.js +10 -10
  76. package/dist/node_modules/prebuild-install/bin.js +13 -13
  77. package/dist/node_modules/prebuild-install/download.js +22 -22
  78. package/dist/node_modules/prebuild-install/log.js +4 -4
  79. package/dist/node_modules/prebuild-install/node_modules/detect-libc/LICENSE +201 -0
  80. package/dist/node_modules/prebuild-install/node_modules/detect-libc/README.md +160 -0
  81. package/dist/node_modules/prebuild-install/node_modules/detect-libc/index.d.ts +11 -0
  82. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/detect-libc.js +178 -0
  83. package/dist/node_modules/prebuild-install/node_modules/detect-libc/lib/process.js +16 -0
  84. package/dist/node_modules/prebuild-install/node_modules/detect-libc/package.json +71 -0
  85. package/dist/node_modules/prebuild-install/package.json +18 -19
  86. package/dist/node_modules/prebuild-install/proxy.js +10 -10
  87. package/dist/node_modules/prebuild-install/rc.js +12 -12
  88. package/dist/node_modules/prebuild-install/util.js +14 -14
  89. package/dist/node_modules/semver/package.json +1 -0
  90. package/dist/node_modules/sharp/README.md +2 -2
  91. package/dist/node_modules/sharp/binding.gyp +12 -9
  92. package/dist/node_modules/sharp/build/Release/sharp-linux-x64.node +0 -0
  93. package/dist/node_modules/sharp/install/dll-copy.js +6 -6
  94. package/dist/node_modules/sharp/install/libvips.js +4 -8
  95. package/dist/node_modules/sharp/lib/channel.js +11 -7
  96. package/dist/node_modules/sharp/lib/colour.js +42 -1
  97. package/dist/node_modules/sharp/lib/constructor.js +18 -31
  98. package/dist/node_modules/sharp/lib/input.js +45 -3
  99. package/dist/node_modules/sharp/lib/is.js +19 -5
  100. package/dist/node_modules/sharp/lib/libvips.js +4 -19
  101. package/dist/node_modules/sharp/lib/operation.js +28 -5
  102. package/dist/node_modules/sharp/lib/output.js +147 -16
  103. package/dist/node_modules/sharp/lib/sharp.js +31 -0
  104. package/dist/node_modules/sharp/lib/utility.js +3 -2
  105. package/dist/node_modules/sharp/package.json +32 -23
  106. package/dist/node_modules/sharp/src/common.cc +67 -11
  107. package/dist/node_modules/sharp/src/common.h +25 -5
  108. package/dist/node_modules/sharp/src/libvips/cplusplus/VConnection.cpp +0 -26
  109. package/dist/node_modules/sharp/src/libvips/cplusplus/VImage.cpp +54 -16
  110. package/dist/node_modules/sharp/src/libvips/cplusplus/VInterpolate.cpp +0 -13
  111. package/dist/node_modules/sharp/src/libvips/cplusplus/vips-operators.cpp +185 -1
  112. package/dist/node_modules/sharp/src/metadata.cc +14 -0
  113. package/dist/node_modules/sharp/src/metadata.h +1 -0
  114. package/dist/node_modules/sharp/src/operations.cc +29 -3
  115. package/dist/node_modules/sharp/src/operations.h +13 -2
  116. package/dist/node_modules/sharp/src/pipeline.cc +103 -35
  117. package/dist/node_modules/sharp/src/pipeline.h +23 -3
  118. package/dist/node_modules/sharp/src/utilities.cc +1 -1
  119. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/THIRD-PARTY-NOTICES.md +2 -3
  120. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/lib/libvips-cpp.so.42 +0 -0
  121. package/dist/node_modules/sharp/vendor/{8.10.6 → 8.11.3/linux-x64}/platform.json +0 -0
  122. package/dist/node_modules/sharp/vendor/8.11.3/linux-x64/versions.json +30 -0
  123. package/dist/node_modules/simple-get/.github/dependabot.yml +15 -0
  124. package/dist/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  125. package/dist/node_modules/simple-get/README.md +17 -3
  126. package/dist/node_modules/simple-get/index.js +9 -0
  127. package/dist/node_modules/simple-get/package.json +27 -13
  128. package/dist/package-lock.json +54 -54
  129. package/dist/package.json +11 -11
  130. package/package.json +12 -12
  131. package/src/__test__/tile.style.json.test.ts +40 -0
  132. package/src/__test__/xyz.test.ts +43 -41
  133. package/src/cli/dump.ts +2 -2
  134. package/src/index.ts +10 -0
  135. package/src/routes/esri/rest.ts +90 -0
  136. package/src/routes/imagery.ts +52 -0
  137. package/src/routes/response.ts +4 -0
  138. package/src/routes/tile.json.ts +44 -0
  139. package/src/routes/tile.style.json.ts +77 -0
  140. package/src/routes/tile.ts +11 -186
  141. package/src/routes/tile.wmts.ts +59 -0
  142. package/src/routes/tile.xyz.ts +30 -0
  143. package/src/tile.set.raster.ts +4 -1
  144. package/src/tile.set.vector.ts +1 -1
  145. package/tsconfig.tsbuildinfo +1 -1
  146. package/dist/node_modules/color-name/.eslintrc.json +0 -43
  147. package/dist/node_modules/color-name/test.js +0 -7
  148. package/dist/node_modules/node-abi/.travis.yml +0 -17
  149. package/dist/node_modules/node-abi/node_modules/semver/CHANGELOG.md +0 -39
  150. package/dist/node_modules/node-abi/node_modules/semver/LICENSE +0 -15
  151. package/dist/node_modules/node-abi/node_modules/semver/README.md +0 -412
  152. package/dist/node_modules/node-abi/node_modules/semver/bin/semver +0 -160
  153. package/dist/node_modules/node-abi/node_modules/semver/package.json +0 -60
  154. package/dist/node_modules/node-abi/node_modules/semver/range.bnf +0 -16
  155. package/dist/node_modules/node-abi/node_modules/semver/semver.js +0 -1483
  156. package/dist/node_modules/node-addon-api/CHANGELOG.md +0 -722
  157. package/dist/node_modules/sharp/build/Release/sharp.node +0 -0
  158. package/dist/node_modules/sharp/vendor/8.10.6/versions.json +0 -31
@@ -1,27 +1,27 @@
1
1
  {
2
- "_from": "sharp@^0.28.3",
3
- "_id": "sharp@0.28.3",
2
+ "_from": "sharp@^0.29.3",
3
+ "_id": "sharp@0.29.3",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-21GEP45Rmr7q2qcmdnjDkNP04Ooh5v0laGS5FDpojOO84D1DJwUijLiSq8XNNM6e8aGXYtoYRh3sVNdm8NodMA==",
5
+ "_integrity": "sha512-fKWUuOw77E4nhpyzCCJR1ayrttHoFHBT2U/kR/qEMRhvPEcluG4BKj324+SCO1e84+knXHwhJ1HHJGnUt4ElGA==",
6
6
  "_location": "/sharp",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
9
9
  "type": "range",
10
10
  "registry": true,
11
- "raw": "sharp@^0.28.3",
11
+ "raw": "sharp@^0.29.3",
12
12
  "name": "sharp",
13
13
  "escapedName": "sharp",
14
- "rawSpec": "^0.28.3",
14
+ "rawSpec": "^0.29.3",
15
15
  "saveSpec": null,
16
- "fetchSpec": "^0.28.3"
16
+ "fetchSpec": "^0.29.3"
17
17
  },
18
18
  "_requiredBy": [
19
19
  "#USER",
20
20
  "/"
21
21
  ],
22
- "_resolved": "https://registry.npmjs.org/sharp/-/sharp-0.28.3.tgz",
23
- "_shasum": "ecd74cefd020bee4891bb137c9850ee2ce277a8b",
24
- "_spec": "sharp@^0.28.3",
22
+ "_resolved": "https://registry.npmjs.org/sharp/-/sharp-0.29.3.tgz",
23
+ "_shasum": "0da183d626094c974516a48fab9b3e4ba92eb5c2",
24
+ "_spec": "sharp@^0.29.3",
25
25
  "_where": "/home/runner/work/basemaps/basemaps/packages/lambda-tiler/dist",
26
26
  "author": {
27
27
  "name": "Lovell Fuller",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "binary": {
31
31
  "napi_versions": [
32
- 3
32
+ 5
33
33
  ]
34
34
  },
35
35
  "bugs": {
@@ -43,9 +43,9 @@
43
43
  ]
44
44
  },
45
45
  "config": {
46
- "libvips": "8.10.6",
46
+ "libvips": "8.11.3",
47
47
  "runtime": "napi",
48
- "target": 3
48
+ "target": 5
49
49
  },
50
50
  "contributors": [
51
51
  {
@@ -339,37 +339,45 @@
339
339
  {
340
340
  "name": "Brad Parham",
341
341
  "email": "baparham@gmail.com"
342
+ },
343
+ {
344
+ "name": "Taneli Vatanen",
345
+ "email": "taneli.vatanen@gmail.com"
346
+ },
347
+ {
348
+ "name": "Joris Dugué",
349
+ "email": "zaruike10@gmail.com"
342
350
  }
343
351
  ],
344
352
  "dependencies": {
345
- "color": "^3.1.3",
353
+ "color": "^4.0.1",
346
354
  "detect-libc": "^1.0.3",
347
- "node-addon-api": "^3.2.0",
348
- "prebuild-install": "^6.1.2",
355
+ "node-addon-api": "^4.2.0",
356
+ "prebuild-install": "^7.0.0",
349
357
  "semver": "^7.3.5",
350
- "simple-get": "^3.1.0",
358
+ "simple-get": "^4.0.0",
351
359
  "tar-fs": "^2.1.1",
352
360
  "tunnel-agent": "^0.6.0"
353
361
  },
354
362
  "deprecated": false,
355
363
  "description": "High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images",
356
364
  "devDependencies": {
357
- "async": "^3.2.0",
365
+ "async": "^3.2.2",
358
366
  "cc": "^3.0.1",
359
367
  "decompress-zip": "^0.3.3",
360
368
  "documentation": "^13.2.5",
361
369
  "exif-reader": "^1.0.3",
362
370
  "icc": "^2.0.0",
363
371
  "license-checker": "^25.0.1",
364
- "mocha": "^8.4.0",
365
- "mock-fs": "^4.14.0",
372
+ "mocha": "^9.1.3",
373
+ "mock-fs": "^5.1.2",
366
374
  "nyc": "^15.1.0",
367
- "prebuild": "^10.0.1",
375
+ "prebuild": "^11.0.0",
368
376
  "rimraf": "^3.0.2",
369
- "semistandard": "^16.0.0"
377
+ "semistandard": "^16.0.1"
370
378
  },
371
379
  "engines": {
372
- "node": ">=10"
380
+ "node": ">=12.13.0"
373
381
  },
374
382
  "files": [
375
383
  "binding.gyp",
@@ -389,6 +397,7 @@
389
397
  "tiff",
390
398
  "gif",
391
399
  "svg",
400
+ "jp2",
392
401
  "dzi",
393
402
  "image",
394
403
  "resize",
@@ -423,5 +432,5 @@
423
432
  "mocha"
424
433
  ]
425
434
  },
426
- "version": "0.28.3"
435
+ "version": "0.29.3"
427
436
  }
@@ -92,6 +92,9 @@ namespace sharp {
92
92
  }
93
93
  // Raw pixel input
94
94
  if (HasAttr(input, "rawChannels")) {
95
+ descriptor->rawDepth = static_cast<VipsBandFormat>(
96
+ vips_enum_from_nick(nullptr, VIPS_TYPE_BAND_FORMAT,
97
+ AttrAsStr(input, "rawDepth").data()));
95
98
  descriptor->rawChannels = AttrAsUint32(input, "rawChannels");
96
99
  descriptor->rawWidth = AttrAsUint32(input, "rawWidth");
97
100
  descriptor->rawHeight = AttrAsUint32(input, "rawHeight");
@@ -154,6 +157,10 @@ namespace sharp {
154
157
  bool IsGif(std::string const &str) {
155
158
  return EndsWith(str, ".gif") || EndsWith(str, ".GIF");
156
159
  }
160
+ bool IsJp2(std::string const &str) {
161
+ return EndsWith(str, ".jp2") || EndsWith(str, ".jpx") || EndsWith(str, ".j2k") || EndsWith(str, ".j2c")
162
+ || EndsWith(str, ".JP2") || EndsWith(str, ".JPX") || EndsWith(str, ".J2K") || EndsWith(str, ".J2C");
163
+ }
157
164
  bool IsTiff(std::string const &str) {
158
165
  return EndsWith(str, ".tif") || EndsWith(str, ".tiff") || EndsWith(str, ".TIF") || EndsWith(str, ".TIFF");
159
166
  }
@@ -187,6 +194,7 @@ namespace sharp {
187
194
  case ImageType::WEBP: id = "webp"; break;
188
195
  case ImageType::TIFF: id = "tiff"; break;
189
196
  case ImageType::GIF: id = "gif"; break;
197
+ case ImageType::JP2: id = "jp2"; break;
190
198
  case ImageType::SVG: id = "svg"; break;
191
199
  case ImageType::HEIF: id = "heif"; break;
192
200
  case ImageType::PDF: id = "pdf"; break;
@@ -223,6 +231,8 @@ namespace sharp {
223
231
  { "VipsForeignLoadGifBuffer", ImageType::GIF },
224
232
  { "VipsForeignLoadNsgifFile", ImageType::GIF },
225
233
  { "VipsForeignLoadNsgifBuffer", ImageType::GIF },
234
+ { "VipsForeignLoadJp2kBuffer", ImageType::JP2 },
235
+ { "VipsForeignLoadJp2kFile", ImageType::JP2 },
226
236
  { "VipsForeignLoadSvgFile", ImageType::SVG },
227
237
  { "VipsForeignLoadSvgBuffer", ImageType::SVG },
228
238
  { "VipsForeignLoadHeifFile", ImageType::HEIF },
@@ -231,6 +241,8 @@ namespace sharp {
231
241
  { "VipsForeignLoadPdfBuffer", ImageType::PDF },
232
242
  { "VipsForeignLoadMagickFile", ImageType::MAGICK },
233
243
  { "VipsForeignLoadMagickBuffer", ImageType::MAGICK },
244
+ { "VipsForeignLoadMagick7File", ImageType::MAGICK },
245
+ { "VipsForeignLoadMagick7Buffer", ImageType::MAGICK },
234
246
  { "VipsForeignLoadOpenslide", ImageType::OPENSLIDE },
235
247
  { "VipsForeignLoadPpmFile", ImageType::PPM },
236
248
  { "VipsForeignLoadFits", ImageType::FITS },
@@ -282,6 +294,7 @@ namespace sharp {
282
294
  imageType == ImageType::WEBP ||
283
295
  imageType == ImageType::MAGICK ||
284
296
  imageType == ImageType::GIF ||
297
+ imageType == ImageType::JP2 ||
285
298
  imageType == ImageType::TIFF ||
286
299
  imageType == ImageType::HEIF ||
287
300
  imageType == ImageType::PDF;
@@ -297,7 +310,7 @@ namespace sharp {
297
310
  if (descriptor->rawChannels > 0) {
298
311
  // Raw, uncompressed pixel data
299
312
  image = VImage::new_from_memory(descriptor->buffer, descriptor->bufferLength,
300
- descriptor->rawWidth, descriptor->rawHeight, descriptor->rawChannels, VIPS_FORMAT_UCHAR);
313
+ descriptor->rawWidth, descriptor->rawHeight, descriptor->rawChannels, descriptor->rawDepth);
301
314
  if (descriptor->rawChannels < 3) {
302
315
  image.get_image()->Type = VIPS_INTERPRETATION_B_W;
303
316
  } else {
@@ -505,6 +518,17 @@ namespace sharp {
505
518
  return copy;
506
519
  }
507
520
 
521
+ /*
522
+ Remove animation properties from image.
523
+ */
524
+ VImage RemoveAnimationProperties(VImage image) {
525
+ VImage copy = image.copy();
526
+ copy.remove(VIPS_META_PAGE_HEIGHT);
527
+ copy.remove("delay");
528
+ copy.remove("loop");
529
+ return copy;
530
+ }
531
+
508
532
  /*
509
533
  Does this image have a non-default density?
510
534
  */
@@ -586,6 +610,33 @@ namespace sharp {
586
610
  return warning;
587
611
  }
588
612
 
613
+ /*
614
+ Attach an event listener for progress updates, used to detect timeout
615
+ */
616
+ void SetTimeout(VImage image, int const seconds) {
617
+ if (seconds > 0) {
618
+ VipsImage *im = image.get_image();
619
+ if (im->progress_signal == NULL) {
620
+ int *timeout = VIPS_NEW(im, int);
621
+ *timeout = seconds;
622
+ g_signal_connect(im, "eval", G_CALLBACK(VipsProgressCallBack), timeout);
623
+ vips_image_set_progress(im, TRUE);
624
+ }
625
+ }
626
+ }
627
+
628
+ /*
629
+ Event listener for progress updates, used to detect timeout
630
+ */
631
+ void VipsProgressCallBack(VipsImage *im, VipsProgress *progress, int *timeout) {
632
+ // printf("VipsProgressCallBack progress=%d run=%d timeout=%d\n", progress->percent, progress->run, *timeout);
633
+ if (*timeout > 0 && progress->run >= *timeout) {
634
+ vips_image_set_kill(im, TRUE);
635
+ vips_error("timeout", "%d%% complete", progress->percent);
636
+ *timeout = 0;
637
+ }
638
+ }
639
+
589
640
  /*
590
641
  Calculate the (left, top) coordinates of the output image
591
642
  within the input image, applying the given gravity during an embed.
@@ -754,23 +805,27 @@ namespace sharp {
754
805
  /*
755
806
  Convert RGBA value to another colourspace
756
807
  */
757
- std::vector<double> GetRgbaAsColourspace(std::vector<double> const rgba, VipsInterpretation const interpretation) {
808
+ std::vector<double> GetRgbaAsColourspace(std::vector<double> const rgba,
809
+ VipsInterpretation const interpretation, bool premultiply) {
758
810
  int const bands = static_cast<int>(rgba.size());
759
- if (bands < 3 || interpretation == VIPS_INTERPRETATION_sRGB || interpretation == VIPS_INTERPRETATION_RGB) {
811
+ if (bands < 3) {
760
812
  return rgba;
761
- } else {
762
- VImage pixel = VImage::new_matrix(1, 1);
763
- pixel.set("bands", bands);
764
- pixel = pixel.new_from_image(rgba);
765
- pixel = pixel.colourspace(interpretation, VImage::option()->set("source_space", VIPS_INTERPRETATION_sRGB));
766
- return pixel(0, 0);
767
813
  }
814
+ VImage pixel = VImage::new_matrix(1, 1);
815
+ pixel.set("bands", bands);
816
+ pixel = pixel
817
+ .new_from_image(rgba)
818
+ .colourspace(interpretation, VImage::option()->set("source_space", VIPS_INTERPRETATION_sRGB));
819
+ if (premultiply) {
820
+ pixel = pixel.premultiply();
821
+ }
822
+ return pixel(0, 0);
768
823
  }
769
824
 
770
825
  /*
771
826
  Apply the alpha channel to a given colour
772
827
  */
773
- std::tuple<VImage, std::vector<double>> ApplyAlpha(VImage image, std::vector<double> colour) {
828
+ std::tuple<VImage, std::vector<double>> ApplyAlpha(VImage image, std::vector<double> colour, bool premultiply) {
774
829
  // Scale up 8-bit values to match 16-bit input image
775
830
  double const multiplier = sharp::Is16Bit(image.interpretation()) ? 256.0 : 1.0;
776
831
  // Create alphaColour colour
@@ -794,7 +849,7 @@ namespace sharp {
794
849
  alphaColour.push_back(colour[3] * multiplier);
795
850
  }
796
851
  // Ensure alphaColour colour uses correct colourspace
797
- alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation());
852
+ alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply);
798
853
  // Add non-transparent alpha channel, if required
799
854
  if (colour[3] < 255.0 && !HasAlpha(image)) {
800
855
  image = image.bandjoin(
@@ -824,4 +879,5 @@ namespace sharp {
824
879
  }
825
880
  return image;
826
881
  }
882
+
827
883
  } // namespace sharp
@@ -25,9 +25,9 @@
25
25
  // Verify platform and compiler compatibility
26
26
 
27
27
  #if (VIPS_MAJOR_VERSION < 8) || \
28
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 10) || \
29
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 10 && VIPS_MICRO_VERSION < 6)
30
- #error "libvips version 8.10.6+ is required - please see https://sharp.pixelplumbing.com/install"
28
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 11) || \
29
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 11 && VIPS_MICRO_VERSION < 3)
30
+ #error "libvips version 8.11.3+ is required - please see https://sharp.pixelplumbing.com/install"
31
31
  #endif
32
32
 
33
33
  #if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))
@@ -54,6 +54,7 @@ namespace sharp {
54
54
  size_t bufferLength;
55
55
  bool isBuffer;
56
56
  double density;
57
+ VipsBandFormat rawDepth;
57
58
  int rawChannels;
58
59
  int rawWidth;
59
60
  int rawHeight;
@@ -78,6 +79,7 @@ namespace sharp {
78
79
  bufferLength(0),
79
80
  isBuffer(FALSE),
80
81
  density(72.0),
82
+ rawDepth(VIPS_FORMAT_UCHAR),
81
83
  rawChannels(0),
82
84
  rawWidth(0),
83
85
  rawHeight(0),
@@ -114,6 +116,7 @@ namespace sharp {
114
116
  JPEG,
115
117
  PNG,
116
118
  WEBP,
119
+ JP2,
117
120
  TIFF,
118
121
  GIF,
119
122
  SVG,
@@ -140,6 +143,7 @@ namespace sharp {
140
143
  bool IsJpeg(std::string const &str);
141
144
  bool IsPng(std::string const &str);
142
145
  bool IsWebp(std::string const &str);
146
+ bool IsJp2(std::string const &str);
143
147
  bool IsGif(std::string const &str);
144
148
  bool IsTiff(std::string const &str);
145
149
  bool IsHeic(std::string const &str);
@@ -206,6 +210,11 @@ namespace sharp {
206
210
  */
207
211
  VImage SetAnimationProperties(VImage image, int pageHeight, std::vector<int> delay, int loop);
208
212
 
213
+ /*
214
+ Remove animation properties from image.
215
+ */
216
+ VImage RemoveAnimationProperties(VImage image);
217
+
209
218
  /*
210
219
  Does this image have a non-default density?
211
220
  */
@@ -241,6 +250,16 @@ namespace sharp {
241
250
  */
242
251
  std::string VipsWarningPop();
243
252
 
253
+ /*
254
+ Attach an event listener for progress updates, used to detect timeout
255
+ */
256
+ void SetTimeout(VImage image, int const timeoutSeconds);
257
+
258
+ /*
259
+ Event listener for progress updates, used to detect timeout
260
+ */
261
+ void VipsProgressCallBack(VipsImage *image, VipsProgress *progress, int *timeoutSeconds);
262
+
244
263
  /*
245
264
  Calculate the (left, top) coordinates of the output image
246
265
  within the input image, applying the given gravity during an embed.
@@ -286,12 +305,13 @@ namespace sharp {
286
305
  /*
287
306
  Convert RGBA value to another colourspace
288
307
  */
289
- std::vector<double> GetRgbaAsColourspace(std::vector<double> const rgba, VipsInterpretation const interpretation);
308
+ std::vector<double> GetRgbaAsColourspace(std::vector<double> const rgba,
309
+ VipsInterpretation const interpretation, bool premultiply);
290
310
 
291
311
  /*
292
312
  Apply the alpha channel to a given colour
293
313
  */
294
- std::tuple<VImage, std::vector<double>> ApplyAlpha(VImage image, std::vector<double> colour);
314
+ std::tuple<VImage, std::vector<double>> ApplyAlpha(VImage image, std::vector<double> colour, bool premultiply);
295
315
 
296
316
  /*
297
317
  Removes alpha channel, if any.
@@ -110,19 +110,6 @@ VSource::new_from_options( const char *options )
110
110
  return( out );
111
111
  }
112
112
 
113
- VOption *
114
- VOption::set( const char *name, const VSource value )
115
- {
116
- Pair *pair = new Pair( name );
117
-
118
- pair->input = true;
119
- g_value_init( &pair->value, VIPS_TYPE_SOURCE );
120
- g_value_set_object( &pair->value, value.get_source() );
121
- options.push_back( pair );
122
-
123
- return( this );
124
- }
125
-
126
113
  VTarget
127
114
  VTarget::new_to_descriptor( int descriptor )
128
115
  {
@@ -162,17 +149,4 @@ VTarget::new_to_memory()
162
149
  return( out );
163
150
  }
164
151
 
165
- VOption *
166
- VOption::set( const char *name, const VTarget value )
167
- {
168
- Pair *pair = new Pair( name );
169
-
170
- pair->input = true;
171
- g_value_init( &pair->value, VIPS_TYPE_TARGET );
172
- g_value_set_object( &pair->value, value.get_target() );
173
- options.push_back( pair );
174
-
175
- return( this );
176
- }
177
-
178
152
  VIPS_NAMESPACE_END
@@ -51,6 +51,12 @@
51
51
 
52
52
  VIPS_NAMESPACE_START
53
53
 
54
+ /**
55
+ * \namespace vips
56
+ *
57
+ * General docs for the vips namespace.
58
+ */
59
+
54
60
  std::vector<double>
55
61
  to_vectorv( int n, ... )
56
62
  {
@@ -140,6 +146,20 @@ VOption::set( const char *name, int value )
140
146
  return( this );
141
147
  }
142
148
 
149
+ // input guint64
150
+ VOption *
151
+ VOption::set( const char *name, guint64 value )
152
+ {
153
+ Pair *pair = new Pair( name );
154
+
155
+ pair->input = true;
156
+ g_value_init( &pair->value, G_TYPE_UINT64 );
157
+ g_value_set_uint64( &pair->value, value );
158
+ options.push_back( pair );
159
+
160
+ return( this );
161
+ }
162
+
143
163
  // input double
144
164
  VOption *
145
165
  VOption::set( const char *name, double value )
@@ -167,35 +187,37 @@ VOption::set( const char *name, const char *value )
167
187
  return( this );
168
188
  }
169
189
 
170
- // input image
190
+ // input vips object (image, source, target, etc. etc.)
171
191
  VOption *
172
- VOption::set( const char *name, const VImage value )
192
+ VOption::set( const char *name, const VObject value )
173
193
  {
174
194
  Pair *pair = new Pair( name );
195
+ VipsObject *object = value.get_object();
196
+ GType type = G_OBJECT_TYPE( object );
175
197
 
176
198
  pair->input = true;
177
- g_value_init( &pair->value, VIPS_TYPE_IMAGE );
178
- g_value_set_object( &pair->value, value.get_image() );
199
+ g_value_init( &pair->value, type );
200
+ g_value_set_object( &pair->value, object );
179
201
  options.push_back( pair );
180
202
 
181
203
  return( this );
182
204
  }
183
205
 
184
- // input double array
206
+ // input int array
185
207
  VOption *
186
- VOption::set( const char *name, std::vector<double> value )
208
+ VOption::set( const char *name, std::vector<int> value )
187
209
  {
188
210
  Pair *pair = new Pair( name );
189
211
 
190
- double *array;
212
+ int *array;
191
213
  unsigned int i;
192
214
 
193
215
  pair->input = true;
194
216
 
195
- g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE );
196
- vips_value_set_array_double( &pair->value, NULL,
217
+ g_value_init( &pair->value, VIPS_TYPE_ARRAY_INT );
218
+ vips_value_set_array_int( &pair->value, NULL,
197
219
  static_cast< int >( value.size() ) );
198
- array = vips_value_get_array_double( &pair->value, NULL );
220
+ array = vips_value_get_array_int( &pair->value, NULL );
199
221
 
200
222
  for( i = 0; i < value.size(); i++ )
201
223
  array[i] = value[i];
@@ -205,21 +227,21 @@ VOption::set( const char *name, std::vector<double> value )
205
227
  return( this );
206
228
  }
207
229
 
208
- // input int array
230
+ // input double array
209
231
  VOption *
210
- VOption::set( const char *name, std::vector<int> value )
232
+ VOption::set( const char *name, std::vector<double> value )
211
233
  {
212
234
  Pair *pair = new Pair( name );
213
235
 
214
- int *array;
236
+ double *array;
215
237
  unsigned int i;
216
238
 
217
239
  pair->input = true;
218
240
 
219
- g_value_init( &pair->value, VIPS_TYPE_ARRAY_INT );
220
- vips_value_set_array_int( &pair->value, NULL,
241
+ g_value_init( &pair->value, VIPS_TYPE_ARRAY_DOUBLE );
242
+ vips_value_set_array_double( &pair->value, NULL,
221
243
  static_cast< int >( value.size() ) );
222
- array = vips_value_get_array_int( &pair->value, NULL );
244
+ array = vips_value_get_array_double( &pair->value, NULL );
223
245
 
224
246
  for( i = 0; i < value.size(); i++ )
225
247
  array[i] = value[i];
@@ -619,6 +641,22 @@ VImage::new_from_source( VSource source, const char *option_string,
619
641
  return( out );
620
642
  }
621
643
 
644
+ VImage
645
+ VImage::new_from_memory_steal( void *data, size_t size,
646
+ int width, int height, int bands, VipsBandFormat format )
647
+ {
648
+ VipsImage *image;
649
+
650
+ if( !(image = vips_image_new_from_memory( data, size,
651
+ width, height, bands, format )) )
652
+ throw( VError() );
653
+
654
+ g_signal_connect( image, "postclose",
655
+ G_CALLBACK( vips_image_free_buffer ), data);
656
+
657
+ return( VImage( image ) );
658
+ }
659
+
622
660
  VImage
623
661
  VImage::new_matrix( int width, int height )
624
662
  {
@@ -60,17 +60,4 @@ VInterpolate::new_from_name( const char *name, VOption *options )
60
60
  return( out );
61
61
  }
62
62
 
63
- VOption *
64
- VOption::set( const char *name, const VInterpolate value )
65
- {
66
- Pair *pair = new Pair( name );
67
-
68
- pair->input = true;
69
- g_value_init( &pair->value, VIPS_TYPE_INTERPOLATE );
70
- g_value_set_object( &pair->value, value.get_interpolate() );
71
- options.push_back( pair );
72
-
73
- return( this );
74
- }
75
-
76
63
  VIPS_NAMESPACE_END