@revizly/sharp 0.33.4-revizly4 → 0.33.4-revizly6
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 +3 -2
- package/lib/operation.js +11 -13
- package/package.json +7 -7
- package/src/operations.cc +16 -14
- package/src/operations.h +2 -2
- package/src/pipeline.cc +6 -5
- package/src/pipeline.h +2 -2
package/lib/index.d.ts
CHANGED
@@ -571,11 +571,11 @@ declare namespace sharp {
|
|
571
571
|
|
572
572
|
/**
|
573
573
|
* Recomb the image with the specified matrix.
|
574
|
-
* @param inputMatrix 3x3 Recombination matrix
|
574
|
+
* @param inputMatrix 3x3 Recombination matrix or 4x4 Recombination matrix
|
575
575
|
* @throws {Error} Invalid parameters
|
576
576
|
* @returns A sharp instance that can be used to chain operations
|
577
577
|
*/
|
578
|
-
recomb(inputMatrix: Matrix3x3): Sharp;
|
578
|
+
recomb(inputMatrix: Matrix3x3 | Matrix4x4): Sharp;
|
579
579
|
|
580
580
|
/**
|
581
581
|
* Transforms the image using brightness, saturation, hue rotation and lightness.
|
@@ -1730,6 +1730,7 @@ declare namespace sharp {
|
|
1730
1730
|
|
1731
1731
|
type Matrix2x2 = [[number, number], [number, number]];
|
1732
1732
|
type Matrix3x3 = [[number, number, number], [number, number, number], [number, number, number]];
|
1733
|
+
type Matrix4x4 = [[number, number, number, number], [number, number, number, number], [number, number, number, number], [number, number, number, number]];
|
1733
1734
|
}
|
1734
1735
|
|
1735
1736
|
export = sharp;
|
package/lib/operation.js
CHANGED
@@ -787,24 +787,22 @@ function linear (a, b) {
|
|
787
787
|
* // With this example input, a sepia filter has been applied
|
788
788
|
* });
|
789
789
|
*
|
790
|
-
* @param {Array<Array<number>>} inputMatrix - 3x3 Recombination matrix
|
790
|
+
* @param {Array<Array<number>>} inputMatrix - 3x3 or 4x4 Recombination matrix
|
791
791
|
* @returns {Sharp}
|
792
792
|
* @throws {Error} Invalid parameters
|
793
793
|
*/
|
794
794
|
function recomb (inputMatrix) {
|
795
|
-
if (!Array.isArray(inputMatrix)
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
795
|
+
if (!Array.isArray(inputMatrix)) {
|
796
|
+
throw is.invalidParameterError('inputMatrix', 'array', inputMatrix);
|
797
|
+
}
|
798
|
+
if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {
|
799
|
+
throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length);
|
800
|
+
}
|
801
|
+
const recombMatrix = inputMatrix.flat().map(Number);
|
802
|
+
if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {
|
803
|
+
throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length);
|
802
804
|
}
|
803
|
-
this.options.recombMatrix =
|
804
|
-
inputMatrix[0][0], inputMatrix[0][1], inputMatrix[0][2],
|
805
|
-
inputMatrix[1][0], inputMatrix[1][1], inputMatrix[1][2],
|
806
|
-
inputMatrix[2][0], inputMatrix[2][1], inputMatrix[2][2]
|
807
|
-
].map(Number);
|
805
|
+
this.options.recombMatrix = recombMatrix;
|
808
806
|
return this;
|
809
807
|
}
|
810
808
|
|
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.33.4-
|
4
|
+
"version": "0.33.4-revizly6",
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
7
7
|
"contributors": [
|
@@ -142,14 +142,14 @@
|
|
142
142
|
"semver": "^7.6.0"
|
143
143
|
},
|
144
144
|
"optionalDependencies": {
|
145
|
-
"@revizly/sharp-libvips-linux-arm64": "1.0.
|
146
|
-
"@revizly/sharp-libvips-linux-x64": "1.0.
|
145
|
+
"@revizly/sharp-libvips-linux-arm64": "1.0.7",
|
146
|
+
"@revizly/sharp-libvips-linux-x64": "1.0.7",
|
147
147
|
"@revizly/sharp-linux-arm64": "0.33.4-revizly3",
|
148
148
|
"@revizly/sharp-linux-x64": "0.33.4-revizly3"
|
149
149
|
},
|
150
150
|
"devDependencies": {
|
151
151
|
"@emnapi/runtime": "^1.2.0",
|
152
|
-
"@revizly/sharp-libvips-dev": "1.0.
|
152
|
+
"@revizly/sharp-libvips-dev": "1.0.7",
|
153
153
|
"@types/node": "*",
|
154
154
|
"async": "^3.2.5",
|
155
155
|
"cc": "^3.0.1",
|
@@ -159,13 +159,13 @@
|
|
159
159
|
"icc": "^3.0.0",
|
160
160
|
"jsdoc-to-markdown": "^8.0.1",
|
161
161
|
"license-checker": "^25.0.1",
|
162
|
-
"mocha": "^10.
|
162
|
+
"mocha": "^10.5.2",
|
163
163
|
"node-addon-api": "^8.0.0",
|
164
|
-
"nyc": "^
|
164
|
+
"nyc": "^17.0.0",
|
165
165
|
"prebuild": "^13.0.1",
|
166
166
|
"semistandard": "^17.0.0",
|
167
167
|
"tar-fs": "^3.0.6",
|
168
|
-
"tsd": "^0.31.
|
168
|
+
"tsd": "^0.31.1"
|
169
169
|
},
|
170
170
|
"license": "Apache-2.0",
|
171
171
|
"engines": {
|
package/src/operations.cc
CHANGED
@@ -164,10 +164,10 @@ namespace sharp {
|
|
164
164
|
*/
|
165
165
|
VImage Convolve(VImage image, int const width, int const height,
|
166
166
|
double const scale, double const offset,
|
167
|
-
std::
|
167
|
+
std::vector<double> const &kernel_v
|
168
168
|
) {
|
169
169
|
VImage kernel = VImage::new_from_memory(
|
170
|
-
kernel_v.
|
170
|
+
static_cast<void*>(const_cast<double*>(kernel_v.data())),
|
171
171
|
width * height * sizeof(double),
|
172
172
|
width,
|
173
173
|
height,
|
@@ -183,19 +183,21 @@ namespace sharp {
|
|
183
183
|
* Recomb with a Matrix of the given bands/channel size.
|
184
184
|
* Eg. RGB will be a 3x3 matrix.
|
185
185
|
*/
|
186
|
-
VImage Recomb(VImage image, std::
|
187
|
-
double
|
186
|
+
VImage Recomb(VImage image, std::vector<double> const& matrix) {
|
187
|
+
double* m = const_cast<double*>(matrix.data());
|
188
188
|
image = image.colourspace(VIPS_INTERPRETATION_sRGB);
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
189
|
+
if (matrix.size() == 9) {
|
190
|
+
return image
|
191
|
+
.recomb(image.bands() == 3
|
192
|
+
? VImage::new_matrix(3, 3, m, 9)
|
193
|
+
: VImage::new_matrixv(4, 4,
|
194
|
+
m[0], m[1], m[2], 0.0,
|
195
|
+
m[3], m[4], m[5], 0.0,
|
196
|
+
m[6], m[7], m[8], 0.0,
|
197
|
+
0.0, 0.0, 0.0, 1.0));
|
198
|
+
} else {
|
199
|
+
return image.recomb(VImage::new_matrix(4, 4, m, 16));
|
200
|
+
}
|
199
201
|
}
|
200
202
|
|
201
203
|
VImage Modulate(VImage image, double const brightness, double const saturation,
|
package/src/operations.h
CHANGED
@@ -53,7 +53,7 @@ namespace sharp {
|
|
53
53
|
* Convolution with a kernel.
|
54
54
|
*/
|
55
55
|
VImage Convolve(VImage image, int const width, int const height,
|
56
|
-
double const scale, double const offset, std::
|
56
|
+
double const scale, double const offset, std::vector<double> const &kernel_v);
|
57
57
|
|
58
58
|
/*
|
59
59
|
* Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.
|
@@ -95,7 +95,7 @@ namespace sharp {
|
|
95
95
|
* Recomb with a Matrix of the given bands/channel size.
|
96
96
|
* Eg. RGB will be a 3x3 matrix.
|
97
97
|
*/
|
98
|
-
VImage Recomb(VImage image, std::
|
98
|
+
VImage Recomb(VImage image, std::vector<double> const &matrix);
|
99
99
|
|
100
100
|
/*
|
101
101
|
* Modulate brightness, saturation, hue and lightness
|
package/src/pipeline.cc
CHANGED
@@ -609,7 +609,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
609
609
|
}
|
610
610
|
|
611
611
|
// Recomb
|
612
|
-
if (baton->recombMatrix
|
612
|
+
if (!baton->recombMatrix.empty()) {
|
613
613
|
image = sharp::Recomb(image, baton->recombMatrix);
|
614
614
|
}
|
615
615
|
|
@@ -1606,17 +1606,18 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|
1606
1606
|
baton->convKernelScale = sharp::AttrAsDouble(kernel, "scale");
|
1607
1607
|
baton->convKernelOffset = sharp::AttrAsDouble(kernel, "offset");
|
1608
1608
|
size_t const kernelSize = static_cast<size_t>(baton->convKernelWidth * baton->convKernelHeight);
|
1609
|
-
baton->convKernel
|
1609
|
+
baton->convKernel.resize(kernelSize);
|
1610
1610
|
Napi::Array kdata = kernel.Get("kernel").As<Napi::Array>();
|
1611
1611
|
for (unsigned int i = 0; i < kernelSize; i++) {
|
1612
1612
|
baton->convKernel[i] = sharp::AttrAsDouble(kdata, i);
|
1613
1613
|
}
|
1614
1614
|
}
|
1615
1615
|
if (options.Has("recombMatrix")) {
|
1616
|
-
baton->recombMatrix = std::unique_ptr<double[]>(new double[9]);
|
1617
1616
|
Napi::Array recombMatrix = options.Get("recombMatrix").As<Napi::Array>();
|
1618
|
-
|
1619
|
-
|
1617
|
+
unsigned int matrixElements = recombMatrix.Length();
|
1618
|
+
baton->recombMatrix.resize(matrixElements);
|
1619
|
+
for (unsigned int i = 0; i < matrixElements; i++) {
|
1620
|
+
baton->recombMatrix[i] = sharp::AttrAsDouble(recombMatrix, i);
|
1620
1621
|
}
|
1621
1622
|
}
|
1622
1623
|
baton->colourspacePipeline = sharp::AttrAsEnum<VipsInterpretation>(
|
package/src/pipeline.h
CHANGED
@@ -197,7 +197,7 @@ struct PipelineBaton {
|
|
197
197
|
std::unordered_map<std::string, std::string> withExif;
|
198
198
|
bool withExifMerge;
|
199
199
|
int timeoutSeconds;
|
200
|
-
std::
|
200
|
+
std::vector<double> convKernel;
|
201
201
|
int convKernelWidth;
|
202
202
|
int convKernelHeight;
|
203
203
|
double convKernelScale;
|
@@ -223,7 +223,7 @@ struct PipelineBaton {
|
|
223
223
|
VipsForeignDzDepth tileDepth;
|
224
224
|
std::string tileId;
|
225
225
|
std::string tileBasename;
|
226
|
-
std::
|
226
|
+
std::vector<double> recombMatrix;
|
227
227
|
|
228
228
|
PipelineBaton():
|
229
229
|
input(nullptr),
|