sharp 0.32.1 → 0.32.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 +3 -1
- package/lib/composite.js +1 -1
- package/lib/index.d.ts +2 -19
- package/lib/operation.js +8 -2
- package/lib/output.js +2 -2
- package/package.json +4 -4
- package/src/common.cc +4 -0
- package/src/pipeline.cc +13 -4
package/binding.gyp
CHANGED
|
@@ -70,7 +70,9 @@
|
|
|
70
70
|
}, {
|
|
71
71
|
'target_name': 'sharp-<(platform_and_arch)',
|
|
72
72
|
'defines': [
|
|
73
|
-
'NAPI_VERSION=7'
|
|
73
|
+
'NAPI_VERSION=7',
|
|
74
|
+
'NODE_ADDON_API_DISABLE_DEPRECATED',
|
|
75
|
+
'NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS'
|
|
74
76
|
],
|
|
75
77
|
'dependencies': [
|
|
76
78
|
'<!(node -p "require(\'node-addon-api\').gyp")',
|
package/lib/composite.js
CHANGED
|
@@ -46,7 +46,7 @@ const blend = {
|
|
|
46
46
|
* The images to composite must be the same size or smaller than the processed image.
|
|
47
47
|
* If both `top` and `left` options are provided, they take precedence over `gravity`.
|
|
48
48
|
*
|
|
49
|
-
* Any resize or
|
|
49
|
+
* Any resize, rotate or extract operations in the same processing pipeline
|
|
50
50
|
* will always be applied to the input image before composition.
|
|
51
51
|
*
|
|
52
52
|
* The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,
|
package/lib/index.d.ts
CHANGED
|
@@ -1350,9 +1350,9 @@ declare namespace sharp {
|
|
|
1350
1350
|
grayscale?: boolean | undefined;
|
|
1351
1351
|
}
|
|
1352
1352
|
|
|
1353
|
-
interface OverlayOptions {
|
|
1353
|
+
interface OverlayOptions extends SharpOptions {
|
|
1354
1354
|
/** Buffer containing image data, String containing the path to an image file, or Create object */
|
|
1355
|
-
input?: string | Buffer | { create: Create } | { text: CreateText } | undefined;
|
|
1355
|
+
input?: string | Buffer | { create: Create } | { text: CreateText } | { raw: CreateRaw } | undefined;
|
|
1356
1356
|
/** how to blend this image with the image below. (optional, default `'over'`) */
|
|
1357
1357
|
blend?: Blend | undefined;
|
|
1358
1358
|
/** gravity at which to place the overlay. (optional, default 'centre') */
|
|
@@ -1363,25 +1363,8 @@ declare namespace sharp {
|
|
|
1363
1363
|
left?: number | undefined;
|
|
1364
1364
|
/** set to true to repeat the overlay image across the entire image with the given gravity. (optional, default false) */
|
|
1365
1365
|
tile?: boolean | undefined;
|
|
1366
|
-
/** number representing the DPI for vector overlay image. (optional, default 72) */
|
|
1367
|
-
density?: number | undefined;
|
|
1368
|
-
/** describes overlay when using raw pixel data. */
|
|
1369
|
-
raw?: Raw | undefined;
|
|
1370
1366
|
/** Set to true to avoid premultipling the image below. Equivalent to the --premultiplied vips option. */
|
|
1371
1367
|
premultiplied?: boolean | undefined;
|
|
1372
|
-
/** Set to true to read all frames/pages of an animated image. (optional, default false). */
|
|
1373
|
-
animated?: boolean | undefined;
|
|
1374
|
-
/**
|
|
1375
|
-
* When to abort processing of invalid pixel data, one of (in order of sensitivity):
|
|
1376
|
-
* 'none' (least), 'truncated', 'error' or 'warning' (most), highers level imply lower levels, invalid metadata will always abort. (optional, default 'warning')
|
|
1377
|
-
*/
|
|
1378
|
-
failOn?: FailOnOptions | undefined;
|
|
1379
|
-
/**
|
|
1380
|
-
* Do not process input images where the number of pixels (width x height) exceeds this limit.
|
|
1381
|
-
* Assumes image dimensions contained in the input metadata can be trusted.
|
|
1382
|
-
* An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF). (optional, default 268402689)
|
|
1383
|
-
*/
|
|
1384
|
-
limitInputPixels?: number | boolean | undefined;
|
|
1385
1368
|
}
|
|
1386
1369
|
|
|
1387
1370
|
interface TileOptions {
|
package/lib/operation.js
CHANGED
|
@@ -80,9 +80,13 @@ function rotate (angle, options) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* Mirror the image vertically (up-down) about the x-axis.
|
|
84
|
+
* This always occurs before rotation, if any.
|
|
85
|
+
*
|
|
84
86
|
* The use of `flip` implies the removal of the EXIF `Orientation` tag, if any.
|
|
85
87
|
*
|
|
88
|
+
* This operation does not work correctly with multi-page images.
|
|
89
|
+
*
|
|
86
90
|
* @example
|
|
87
91
|
* const output = await sharp(input).flip().toBuffer();
|
|
88
92
|
*
|
|
@@ -95,7 +99,9 @@ function flip (flip) {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
/**
|
|
98
|
-
*
|
|
102
|
+
* Mirror the image horizontally (left-right) about the y-axis.
|
|
103
|
+
* This always occurs before rotation, if any.
|
|
104
|
+
*
|
|
99
105
|
* The use of `flop` implies the removal of the EXIF `Orientation` tag, if any.
|
|
100
106
|
*
|
|
101
107
|
* @example
|
package/lib/output.js
CHANGED
|
@@ -29,7 +29,7 @@ const formats = new Map([
|
|
|
29
29
|
['jxl', 'jxl']
|
|
30
30
|
]);
|
|
31
31
|
|
|
32
|
-
const jp2Regex = /\.jp[2x]|j2[kc]$/i;
|
|
32
|
+
const jp2Regex = /\.(jp[2x]|j2[kc])$/i;
|
|
33
33
|
|
|
34
34
|
const errJp2Save = () => new Error('JP2 output requires libvips with support for OpenJPEG');
|
|
35
35
|
|
|
@@ -75,7 +75,7 @@ function toFile (fileOut, callback) {
|
|
|
75
75
|
err = new Error('Missing output file path');
|
|
76
76
|
} else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {
|
|
77
77
|
err = new Error('Cannot use same file for input and output');
|
|
78
|
-
} else if (jp2Regex.test(fileOut) && !this.constructor.format.jp2k.output.file) {
|
|
78
|
+
} else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
79
79
|
err = errJp2Save();
|
|
80
80
|
}
|
|
81
81
|
if (err) {
|
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.
|
|
4
|
+
"version": "0.32.2",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://github.com/lovell/sharp",
|
|
7
7
|
"contributors": [
|
|
@@ -136,9 +136,9 @@
|
|
|
136
136
|
"detect-libc": "^2.0.1",
|
|
137
137
|
"node-addon-api": "^6.1.0",
|
|
138
138
|
"prebuild-install": "^7.1.1",
|
|
139
|
-
"semver": "^7.5.
|
|
139
|
+
"semver": "^7.5.4",
|
|
140
140
|
"simple-get": "^4.0.1",
|
|
141
|
-
"tar-fs": "^
|
|
141
|
+
"tar-fs": "^3.0.4",
|
|
142
142
|
"tunnel-agent": "^0.6.0"
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"mocha": "^10.2.0",
|
|
154
154
|
"mock-fs": "^5.2.0",
|
|
155
155
|
"nyc": "^15.1.0",
|
|
156
|
-
"prebuild": "
|
|
156
|
+
"prebuild": "lovell/prebuild#add-nodejs-20-drop-nodejs-10-and-12",
|
|
157
157
|
"semistandard": "^16.0.1",
|
|
158
158
|
"tsd": "^0.28.1"
|
|
159
159
|
},
|
package/src/common.cc
CHANGED
|
@@ -669,6 +669,10 @@ namespace sharp {
|
|
|
669
669
|
if (image.width() > 65535 || height > 65535) {
|
|
670
670
|
throw vips::VError("Processed image is too large for the GIF format");
|
|
671
671
|
}
|
|
672
|
+
} else if (imageType == ImageType::HEIF) {
|
|
673
|
+
if (image.width() > 16384 || height > 16384) {
|
|
674
|
+
throw vips::VError("Processed image is too large for the HEIF format");
|
|
675
|
+
}
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
678
|
|
package/src/pipeline.cc
CHANGED
|
@@ -79,6 +79,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
79
79
|
// Rotate and flip image according to Exif orientation
|
|
80
80
|
std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
|
|
81
81
|
image = sharp::RemoveExifOrientation(image);
|
|
82
|
+
if (baton->input->access == VIPS_ACCESS_SEQUENTIAL && (autoRotation != VIPS_ANGLE_D0 || autoFlip)) {
|
|
83
|
+
image = image.copy_memory();
|
|
84
|
+
}
|
|
82
85
|
} else {
|
|
83
86
|
rotation = CalculateAngleRotation(baton->angle);
|
|
84
87
|
}
|
|
@@ -116,7 +119,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
116
119
|
MultiPageUnsupported(nPages, "Rotate");
|
|
117
120
|
std::vector<double> background;
|
|
118
121
|
std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, FALSE);
|
|
119
|
-
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background));
|
|
122
|
+
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)).copy_memory();
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
125
|
|
|
@@ -380,11 +383,11 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
380
383
|
if (autoRotation != VIPS_ANGLE_D0) {
|
|
381
384
|
image = image.rot(autoRotation);
|
|
382
385
|
}
|
|
383
|
-
//
|
|
386
|
+
// Mirror vertically (up-down) about the x-axis
|
|
384
387
|
if (baton->flip || autoFlip) {
|
|
385
388
|
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
|
386
389
|
}
|
|
387
|
-
//
|
|
390
|
+
// Mirror horizontally (left-right) about the y-axis
|
|
388
391
|
if (baton->flop || autoFlop) {
|
|
389
392
|
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
|
390
393
|
}
|
|
@@ -399,6 +402,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
399
402
|
sharp::ImageType joinImageType = sharp::ImageType::UNKNOWN;
|
|
400
403
|
|
|
401
404
|
for (unsigned int i = 0; i < baton->joinChannelIn.size(); i++) {
|
|
405
|
+
baton->joinChannelIn[i]->access = baton->input->access;
|
|
402
406
|
std::tie(joinImage, joinImageType) = sharp::OpenInput(baton->joinChannelIn[i]);
|
|
403
407
|
joinImage = sharp::EnsureColourspace(joinImage, baton->colourspaceInput);
|
|
404
408
|
image = image.bandjoin(joinImage);
|
|
@@ -473,7 +477,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
473
477
|
|
|
474
478
|
image = image.smartcrop(baton->width, baton->height, VImage::option()
|
|
475
479
|
->set("interesting", baton->position == 16 ? VIPS_INTERESTING_ENTROPY : VIPS_INTERESTING_ATTENTION)
|
|
480
|
+
#if (VIPS_MAJOR_VERSION >= 8 && VIPS_MINOR_VERSION >= 15)
|
|
476
481
|
->set("premultiplied", shouldPremultiplyAlpha)
|
|
482
|
+
#endif
|
|
477
483
|
->set("attention_x", &attention_x)
|
|
478
484
|
->set("attention_y", &attention_y));
|
|
479
485
|
baton->hasCropOffset = true;
|
|
@@ -608,6 +614,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
608
614
|
for (Composite *composite : baton->composite) {
|
|
609
615
|
VImage compositeImage;
|
|
610
616
|
sharp::ImageType compositeImageType = sharp::ImageType::UNKNOWN;
|
|
617
|
+
composite->input->access = baton->input->access;
|
|
611
618
|
std::tie(compositeImage, compositeImageType) = sharp::OpenInput(composite->input);
|
|
612
619
|
compositeImage = sharp::EnsureColourspace(compositeImage, baton->colourspaceInput);
|
|
613
620
|
// Verify within current dimensions
|
|
@@ -706,6 +713,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
706
713
|
if (baton->boolean != nullptr) {
|
|
707
714
|
VImage booleanImage;
|
|
708
715
|
sharp::ImageType booleanImageType = sharp::ImageType::UNKNOWN;
|
|
716
|
+
baton->boolean->access = baton->input->access;
|
|
709
717
|
std::tie(booleanImage, booleanImageType) = sharp::OpenInput(baton->boolean);
|
|
710
718
|
booleanImage = sharp::EnsureColourspace(booleanImage, baton->colourspaceInput);
|
|
711
719
|
image = sharp::Boolean(image, booleanImage, baton->booleanOp);
|
|
@@ -933,6 +941,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
933
941
|
} else if (baton->formatOut == "heif" ||
|
|
934
942
|
(baton->formatOut == "input" && inputImageType == sharp::ImageType::HEIF)) {
|
|
935
943
|
// Write HEIF to buffer
|
|
944
|
+
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
|
936
945
|
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
|
937
946
|
VipsArea *area = reinterpret_cast<VipsArea*>(image.heifsave_buffer(VImage::option()
|
|
938
947
|
->set("strip", !baton->withMetadata)
|
|
@@ -1122,6 +1131,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1122
1131
|
} else if (baton->formatOut == "heif" || (mightMatchInput && isHeif) ||
|
|
1123
1132
|
(willMatchInput && inputImageType == sharp::ImageType::HEIF)) {
|
|
1124
1133
|
// Write HEIF to file
|
|
1134
|
+
sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
|
|
1125
1135
|
image = sharp::RemoveAnimationProperties(image).cast(VIPS_FORMAT_UCHAR);
|
|
1126
1136
|
image.heifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
|
|
1127
1137
|
->set("strip", !baton->withMetadata)
|
|
@@ -1673,7 +1683,6 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|
|
1673
1683
|
baton->angle != 0 ||
|
|
1674
1684
|
baton->rotationAngle != 0.0 ||
|
|
1675
1685
|
baton->tileAngle != 0 ||
|
|
1676
|
-
baton->useExifOrientation ||
|
|
1677
1686
|
baton->flip ||
|
|
1678
1687
|
baton->claheWidth != 0 ||
|
|
1679
1688
|
!baton->affineMatrix.empty()
|