sharp 0.34.3-rc.1 → 0.34.4-rc.3
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/channel.js +2 -0
- package/lib/colour.js +1 -1
- package/lib/constructor.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/resize.js +7 -4
- package/package.json +39 -38
- package/src/binding.gyp +3 -4
- package/src/common.cc +1 -0
- package/src/common.h +2 -2
- package/src/metadata.cc +1 -1
- package/src/pipeline.cc +37 -43
- package/src/pipeline.h +2 -1
- package/src/sharp.cc +2 -4
package/lib/channel.js
CHANGED
|
@@ -74,6 +74,8 @@ function ensureAlpha (alpha) {
|
|
|
74
74
|
/**
|
|
75
75
|
* Extract a single channel from a multi-channel image.
|
|
76
76
|
*
|
|
77
|
+
* The output colourspace will be either `b-w` (8-bit) or `grey16` (16-bit).
|
|
78
|
+
*
|
|
77
79
|
* @example
|
|
78
80
|
* // green.jpg is a greyscale image containing the green channel of the input
|
|
79
81
|
* await sharp(input)
|
package/lib/colour.js
CHANGED
package/lib/constructor.js
CHANGED
|
@@ -230,7 +230,8 @@ const Sharp = function (input, options) {
|
|
|
230
230
|
angle: 0,
|
|
231
231
|
rotationAngle: 0,
|
|
232
232
|
rotationBackground: [0, 0, 0, 255],
|
|
233
|
-
|
|
233
|
+
rotateBefore: false,
|
|
234
|
+
orientBefore: false,
|
|
234
235
|
flip: false,
|
|
235
236
|
flop: false,
|
|
236
237
|
extendTop: 0,
|
package/lib/index.d.ts
CHANGED
package/lib/resize.js
CHANGED
|
@@ -107,7 +107,7 @@ const mapFitToCanvas = {
|
|
|
107
107
|
* @private
|
|
108
108
|
*/
|
|
109
109
|
function isRotationExpected (options) {
|
|
110
|
-
return (options.angle % 360) !== 0 || options.
|
|
110
|
+
return (options.angle % 360) !== 0 || options.rotationAngle !== 0;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -343,7 +343,7 @@ function resize (widthOrOptions, height, options) {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
if (isRotationExpected(this.options) && isResizeExpected(this.options)) {
|
|
346
|
-
this.options.
|
|
346
|
+
this.options.rotateBefore = true;
|
|
347
347
|
}
|
|
348
348
|
return this;
|
|
349
349
|
}
|
|
@@ -490,9 +490,12 @@ function extract (options) {
|
|
|
490
490
|
// Ensure existing rotation occurs before pre-resize extraction
|
|
491
491
|
if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {
|
|
492
492
|
if (this.options.widthPre === -1 || this.options.widthPost === -1) {
|
|
493
|
-
this.options.
|
|
493
|
+
this.options.rotateBefore = true;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
+
if (this.options.input.autoOrient) {
|
|
497
|
+
this.options.orientBefore = true;
|
|
498
|
+
}
|
|
496
499
|
return this;
|
|
497
500
|
}
|
|
498
501
|
|
|
@@ -566,7 +569,7 @@ function trim (options) {
|
|
|
566
569
|
}
|
|
567
570
|
}
|
|
568
571
|
if (isRotationExpected(this.options)) {
|
|
569
|
-
this.options.
|
|
572
|
+
this.options.rotateBefore = true;
|
|
570
573
|
}
|
|
571
574
|
return this;
|
|
572
575
|
}
|
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.34.
|
|
4
|
+
"version": "0.34.4-rc.3",
|
|
5
5
|
"author": "Lovell Fuller <npm@lovell.info>",
|
|
6
6
|
"homepage": "https://sharp.pixelplumbing.com",
|
|
7
7
|
"contributors": [
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"test-leak": "./test/leak/leak.sh",
|
|
102
102
|
"test-types": "tsd",
|
|
103
103
|
"package-from-local-build": "node npm/from-local-build.js",
|
|
104
|
+
"package-release-notes": "node npm/release-notes.js",
|
|
104
105
|
"docs-build": "node docs/build.mjs",
|
|
105
106
|
"docs-serve": "cd docs && npm start",
|
|
106
107
|
"docs-publish": "cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"
|
|
@@ -136,63 +137,63 @@
|
|
|
136
137
|
"vips"
|
|
137
138
|
],
|
|
138
139
|
"dependencies": {
|
|
139
|
-
"
|
|
140
|
-
"detect-libc": "^2.0
|
|
140
|
+
"@img/colour": "^1.0.0",
|
|
141
|
+
"detect-libc": "^2.1.0",
|
|
141
142
|
"semver": "^7.7.2"
|
|
142
143
|
},
|
|
143
144
|
"optionalDependencies": {
|
|
144
|
-
"@img/sharp-darwin-arm64": "0.34.
|
|
145
|
-
"@img/sharp-darwin-x64": "0.34.
|
|
146
|
-
"@img/sharp-libvips-darwin-arm64": "1.2.
|
|
147
|
-
"@img/sharp-libvips-darwin-x64": "1.2.
|
|
148
|
-
"@img/sharp-libvips-linux-arm": "1.2.
|
|
149
|
-
"@img/sharp-libvips-linux-arm64": "1.2.
|
|
150
|
-
"@img/sharp-libvips-linux-ppc64": "1.2.
|
|
151
|
-
"@img/sharp-libvips-linux-s390x": "1.2.
|
|
152
|
-
"@img/sharp-libvips-linux-x64": "1.2.
|
|
153
|
-
"@img/sharp-libvips-linuxmusl-arm64": "1.2.
|
|
154
|
-
"@img/sharp-libvips-linuxmusl-x64": "1.2.
|
|
155
|
-
"@img/sharp-linux-arm": "0.34.
|
|
156
|
-
"@img/sharp-linux-arm64": "0.34.
|
|
157
|
-
"@img/sharp-linux-ppc64": "0.34.
|
|
158
|
-
"@img/sharp-linux-s390x": "0.34.
|
|
159
|
-
"@img/sharp-linux-x64": "0.34.
|
|
160
|
-
"@img/sharp-linuxmusl-arm64": "0.34.
|
|
161
|
-
"@img/sharp-linuxmusl-x64": "0.34.
|
|
162
|
-
"@img/sharp-wasm32": "0.34.
|
|
163
|
-
"@img/sharp-win32-arm64": "0.34.
|
|
164
|
-
"@img/sharp-win32-ia32": "0.34.
|
|
165
|
-
"@img/sharp-win32-x64": "0.34.
|
|
145
|
+
"@img/sharp-darwin-arm64": "0.34.4-rc.3",
|
|
146
|
+
"@img/sharp-darwin-x64": "0.34.4-rc.3",
|
|
147
|
+
"@img/sharp-libvips-darwin-arm64": "1.2.2",
|
|
148
|
+
"@img/sharp-libvips-darwin-x64": "1.2.2",
|
|
149
|
+
"@img/sharp-libvips-linux-arm": "1.2.2",
|
|
150
|
+
"@img/sharp-libvips-linux-arm64": "1.2.2",
|
|
151
|
+
"@img/sharp-libvips-linux-ppc64": "1.2.2",
|
|
152
|
+
"@img/sharp-libvips-linux-s390x": "1.2.2",
|
|
153
|
+
"@img/sharp-libvips-linux-x64": "1.2.2",
|
|
154
|
+
"@img/sharp-libvips-linuxmusl-arm64": "1.2.2",
|
|
155
|
+
"@img/sharp-libvips-linuxmusl-x64": "1.2.2",
|
|
156
|
+
"@img/sharp-linux-arm": "0.34.4-rc.3",
|
|
157
|
+
"@img/sharp-linux-arm64": "0.34.4-rc.3",
|
|
158
|
+
"@img/sharp-linux-ppc64": "0.34.4-rc.3",
|
|
159
|
+
"@img/sharp-linux-s390x": "0.34.4-rc.3",
|
|
160
|
+
"@img/sharp-linux-x64": "0.34.4-rc.3",
|
|
161
|
+
"@img/sharp-linuxmusl-arm64": "0.34.4-rc.3",
|
|
162
|
+
"@img/sharp-linuxmusl-x64": "0.34.4-rc.3",
|
|
163
|
+
"@img/sharp-wasm32": "0.34.4-rc.3",
|
|
164
|
+
"@img/sharp-win32-arm64": "0.34.4-rc.3",
|
|
165
|
+
"@img/sharp-win32-ia32": "0.34.4-rc.3",
|
|
166
|
+
"@img/sharp-win32-x64": "0.34.4-rc.3"
|
|
166
167
|
},
|
|
167
168
|
"devDependencies": {
|
|
168
|
-
"@emnapi/runtime": "^1.
|
|
169
|
-
"@img/sharp-libvips-dev": "1.2.
|
|
170
|
-
"@img/sharp-libvips-dev-wasm32": "1.2.
|
|
171
|
-
"@img/sharp-libvips-win32-arm64": "1.2.
|
|
172
|
-
"@img/sharp-libvips-win32-ia32": "1.2.
|
|
173
|
-
"@img/sharp-libvips-win32-x64": "1.2.
|
|
169
|
+
"@emnapi/runtime": "^1.5.0",
|
|
170
|
+
"@img/sharp-libvips-dev": "1.2.2",
|
|
171
|
+
"@img/sharp-libvips-dev-wasm32": "1.2.2",
|
|
172
|
+
"@img/sharp-libvips-win32-arm64": "1.2.2",
|
|
173
|
+
"@img/sharp-libvips-win32-ia32": "1.2.2",
|
|
174
|
+
"@img/sharp-libvips-win32-x64": "1.2.2",
|
|
174
175
|
"@types/node": "*",
|
|
175
176
|
"cc": "^3.0.1",
|
|
176
|
-
"emnapi": "^1.
|
|
177
|
+
"emnapi": "^1.5.0",
|
|
177
178
|
"exif-reader": "^2.0.2",
|
|
178
179
|
"extract-zip": "^2.0.1",
|
|
179
180
|
"icc": "^3.0.0",
|
|
180
|
-
"jsdoc-to-markdown": "^9.1.
|
|
181
|
+
"jsdoc-to-markdown": "^9.1.2",
|
|
181
182
|
"license-checker": "^25.0.1",
|
|
182
|
-
"mocha": "^11.7.
|
|
183
|
-
"node-addon-api": "^8.
|
|
184
|
-
"node-gyp": "^11.2
|
|
183
|
+
"mocha": "^11.7.2",
|
|
184
|
+
"node-addon-api": "^8.5.0",
|
|
185
|
+
"node-gyp": "^11.4.2",
|
|
185
186
|
"nyc": "^17.1.0",
|
|
186
187
|
"semistandard": "^17.0.0",
|
|
187
188
|
"tar-fs": "^3.1.0",
|
|
188
|
-
"tsd": "^0.
|
|
189
|
+
"tsd": "^0.33.0"
|
|
189
190
|
},
|
|
190
191
|
"license": "Apache-2.0",
|
|
191
192
|
"engines": {
|
|
192
193
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
193
194
|
},
|
|
194
195
|
"config": {
|
|
195
|
-
"libvips": ">=8.17.
|
|
196
|
+
"libvips": ">=8.17.2"
|
|
196
197
|
},
|
|
197
198
|
"funding": {
|
|
198
199
|
"url": "https://opencollective.com/libvips"
|
package/src/binding.gyp
CHANGED
|
@@ -168,6 +168,7 @@
|
|
|
168
168
|
# Ensure runtime linking is relative to sharp.node
|
|
169
169
|
'-Wl,-rpath,\'@loader_path/../../sharp-libvips-<(platform_and_arch)/lib\'',
|
|
170
170
|
'-Wl,-rpath,\'@loader_path/../../../sharp-libvips-<(platform_and_arch)/<(sharp_libvips_version)/lib\'',
|
|
171
|
+
'-Wl,-rpath,\'@loader_path/../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
171
172
|
'-Wl,-rpath,\'@loader_path/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
172
173
|
'-Wl,-rpath,\'@loader_path/../../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',
|
|
173
174
|
'-Wl,-rpath,\'@loader_path/../../../../../@img-sharp-libvips-<(platform_and_arch)-npm-<(sharp_libvips_version)-<(sharp_libvips_yarn_locator)/node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\''
|
|
@@ -208,11 +209,9 @@
|
|
|
208
209
|
'-Oz',
|
|
209
210
|
'-sALLOW_MEMORY_GROWTH',
|
|
210
211
|
'-sENVIRONMENT=node',
|
|
211
|
-
'-sEXPORTED_FUNCTIONS=
|
|
212
|
+
'-sEXPORTED_FUNCTIONS=emnapiInit,_vips_shutdown,_uv_library_shutdown',
|
|
212
213
|
'-sNODERAWFS',
|
|
213
|
-
'-
|
|
214
|
-
'-sWASM_ASYNC_COMPILATION=0',
|
|
215
|
-
'-sWASM_BIGINT'
|
|
214
|
+
'-sWASM_ASYNC_COMPILATION=0'
|
|
216
215
|
],
|
|
217
216
|
'libraries': [
|
|
218
217
|
'<!@(PKG_CONFIG_PATH="<!(node -p "require(\'@img/sharp-libvips-dev-wasm32/lib\')")/pkgconfig" pkg-config --static --libs vips-cpp)'
|
package/src/common.cc
CHANGED
package/src/common.h
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
#if (VIPS_MAJOR_VERSION < 8) || \
|
|
18
18
|
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 17) || \
|
|
19
|
-
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 17 && VIPS_MICRO_VERSION <
|
|
20
|
-
#error "libvips version 8.17.
|
|
19
|
+
(VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 17 && VIPS_MICRO_VERSION < 2)
|
|
20
|
+
#error "libvips version 8.17.2+ is required - please see https://sharp.pixelplumbing.com/install"
|
|
21
21
|
#endif
|
|
22
22
|
|
|
23
23
|
#if defined(__has_include)
|
package/src/metadata.cc
CHANGED
|
@@ -261,11 +261,11 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|
|
261
261
|
info.Set("iptc", Napi::Buffer<char>::NewOrCopy(env, baton->iptc, baton->iptcLength, sharp::FreeCallback));
|
|
262
262
|
}
|
|
263
263
|
if (baton->xmpLength > 0) {
|
|
264
|
-
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
|
|
265
264
|
if (g_utf8_validate(static_cast<char const *>(baton->xmp), baton->xmpLength, nullptr)) {
|
|
266
265
|
info.Set("xmpAsString",
|
|
267
266
|
Napi::String::New(env, static_cast<char const *>(baton->xmp), baton->xmpLength));
|
|
268
267
|
}
|
|
268
|
+
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
|
|
269
269
|
}
|
|
270
270
|
if (baton->tifftagPhotoshopLength > 0) {
|
|
271
271
|
info.Set("tifftagPhotoshop",
|
package/src/pipeline.cc
CHANGED
|
@@ -92,31 +92,22 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
92
92
|
// Calculate angle of rotation
|
|
93
93
|
VipsAngle rotation = VIPS_ANGLE_D0;
|
|
94
94
|
VipsAngle autoRotation = VIPS_ANGLE_D0;
|
|
95
|
-
bool autoFlip = false;
|
|
96
95
|
bool autoFlop = false;
|
|
97
96
|
|
|
98
97
|
if (baton->input->autoOrient) {
|
|
99
98
|
// Rotate and flip image according to Exif orientation
|
|
100
|
-
std::tie(autoRotation,
|
|
101
|
-
image = sharp::RemoveExifOrientation(image);
|
|
99
|
+
std::tie(autoRotation, autoFlop) = CalculateExifRotationAndFlop(sharp::ExifOrientation(image));
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
rotation = CalculateAngleRotation(baton->angle);
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
baton->rotationAngle != 0.0);
|
|
111
|
-
|
|
112
|
-
if (shouldRotateBefore) {
|
|
113
|
-
image = sharp::StaySequential(image,
|
|
114
|
-
rotation != VIPS_ANGLE_D0 ||
|
|
115
|
-
autoRotation != VIPS_ANGLE_D0 ||
|
|
116
|
-
autoFlip ||
|
|
117
|
-
baton->flip ||
|
|
118
|
-
baton->rotationAngle != 0.0);
|
|
104
|
+
bool const shouldRotateBefore = baton->rotateBefore &&
|
|
105
|
+
(rotation != VIPS_ANGLE_D0 || baton->flip || baton->flop || baton->rotationAngle != 0.0);
|
|
106
|
+
bool const shouldOrientBefore = (shouldRotateBefore || baton->orientBefore) &&
|
|
107
|
+
(autoRotation != VIPS_ANGLE_D0 || autoFlop);
|
|
119
108
|
|
|
109
|
+
if (shouldOrientBefore) {
|
|
110
|
+
image = sharp::StaySequential(image, autoRotation != VIPS_ANGLE_D0);
|
|
120
111
|
if (autoRotation != VIPS_ANGLE_D0) {
|
|
121
112
|
if (autoRotation != VIPS_ANGLE_D180) {
|
|
122
113
|
MultiPageUnsupported(nPages, "Rotate");
|
|
@@ -124,14 +115,20 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
124
115
|
image = image.rot(autoRotation);
|
|
125
116
|
autoRotation = VIPS_ANGLE_D0;
|
|
126
117
|
}
|
|
127
|
-
if (
|
|
118
|
+
if (autoFlop) {
|
|
119
|
+
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
|
120
|
+
autoFlop = false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (shouldRotateBefore) {
|
|
125
|
+
image = sharp::StaySequential(image, rotation != VIPS_ANGLE_D0 || baton->flip || baton->rotationAngle != 0.0);
|
|
126
|
+
if (baton->flip) {
|
|
128
127
|
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
|
129
|
-
autoFlip = false;
|
|
130
128
|
baton->flip = false;
|
|
131
129
|
}
|
|
132
|
-
if (
|
|
130
|
+
if (baton->flop) {
|
|
133
131
|
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
|
|
134
|
-
autoFlop = false;
|
|
135
132
|
baton->flop = false;
|
|
136
133
|
}
|
|
137
134
|
if (rotation != VIPS_ANGLE_D0) {
|
|
@@ -146,6 +143,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
146
143
|
std::vector<double> background;
|
|
147
144
|
std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, false);
|
|
148
145
|
image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)).copy_memory();
|
|
146
|
+
baton->rotationAngle = 0.0;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
149
|
|
|
@@ -184,8 +182,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
184
182
|
// When auto-rotating by 90 or 270 degrees, swap the target width and
|
|
185
183
|
// height to ensure the behavior aligns with how it would have been if
|
|
186
184
|
// the rotation had taken place *before* resizing.
|
|
187
|
-
if (
|
|
188
|
-
(autoRotation == VIPS_ANGLE_D90 || autoRotation == VIPS_ANGLE_D270)) {
|
|
185
|
+
if (autoRotation == VIPS_ANGLE_D90 || autoRotation == VIPS_ANGLE_D270) {
|
|
189
186
|
std::swap(targetResizeWidth, targetResizeHeight);
|
|
190
187
|
}
|
|
191
188
|
|
|
@@ -207,7 +204,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
207
204
|
// - input colourspace is not specified;
|
|
208
205
|
bool const shouldPreShrink = (targetResizeWidth > 0 || targetResizeHeight > 0) &&
|
|
209
206
|
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold < 0.0 &&
|
|
210
|
-
baton->colourspacePipeline == VIPS_INTERPRETATION_LAST && !shouldRotateBefore;
|
|
207
|
+
baton->colourspacePipeline == VIPS_INTERPRETATION_LAST && !(shouldOrientBefore || shouldRotateBefore);
|
|
211
208
|
|
|
212
209
|
if (shouldPreShrink) {
|
|
213
210
|
// The common part of the shrink: the bit by which both axes must be shrunk
|
|
@@ -294,6 +291,9 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
294
291
|
throw vips::VError("Input SVG image exceeds 32767x32767 pixel limit");
|
|
295
292
|
}
|
|
296
293
|
}
|
|
294
|
+
if (baton->input->autoOrient) {
|
|
295
|
+
image = sharp::RemoveExifOrientation(image);
|
|
296
|
+
}
|
|
297
297
|
|
|
298
298
|
// Any pre-shrinking may already have been done
|
|
299
299
|
inputWidth = image.width();
|
|
@@ -396,7 +396,6 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
396
396
|
image = sharp::StaySequential(image,
|
|
397
397
|
autoRotation != VIPS_ANGLE_D0 ||
|
|
398
398
|
baton->flip ||
|
|
399
|
-
autoFlip ||
|
|
400
399
|
rotation != VIPS_ANGLE_D0);
|
|
401
400
|
// Auto-rotate post-extract
|
|
402
401
|
if (autoRotation != VIPS_ANGLE_D0) {
|
|
@@ -406,7 +405,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
406
405
|
image = image.rot(autoRotation);
|
|
407
406
|
}
|
|
408
407
|
// Mirror vertically (up-down) about the x-axis
|
|
409
|
-
if (baton->flip
|
|
408
|
+
if (baton->flip) {
|
|
410
409
|
image = image.flip(VIPS_DIRECTION_VERTICAL);
|
|
411
410
|
}
|
|
412
411
|
// Mirror horizontally (left-right) about the y-axis
|
|
@@ -513,7 +512,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
513
512
|
}
|
|
514
513
|
|
|
515
514
|
// Rotate post-extract non-90 angle
|
|
516
|
-
if (!baton->
|
|
515
|
+
if (!baton->rotateBefore && baton->rotationAngle != 0.0) {
|
|
517
516
|
MultiPageUnsupported(nPages, "Rotate");
|
|
518
517
|
image = sharp::StaySequential(image);
|
|
519
518
|
std::vector<double> background;
|
|
@@ -654,21 +653,16 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
654
653
|
if (composite->input->autoOrient) {
|
|
655
654
|
// Respect EXIF Orientation
|
|
656
655
|
VipsAngle compositeAutoRotation = VIPS_ANGLE_D0;
|
|
657
|
-
bool compositeAutoFlip = false;
|
|
658
656
|
bool compositeAutoFlop = false;
|
|
659
|
-
std::tie(compositeAutoRotation,
|
|
660
|
-
|
|
657
|
+
std::tie(compositeAutoRotation, compositeAutoFlop) =
|
|
658
|
+
CalculateExifRotationAndFlop(sharp::ExifOrientation(compositeImage));
|
|
661
659
|
|
|
662
660
|
compositeImage = sharp::RemoveExifOrientation(compositeImage);
|
|
663
|
-
compositeImage = sharp::StaySequential(compositeImage,
|
|
664
|
-
compositeAutoRotation != VIPS_ANGLE_D0 || compositeAutoFlip);
|
|
661
|
+
compositeImage = sharp::StaySequential(compositeImage, compositeAutoRotation != VIPS_ANGLE_D0);
|
|
665
662
|
|
|
666
663
|
if (compositeAutoRotation != VIPS_ANGLE_D0) {
|
|
667
664
|
compositeImage = compositeImage.rot(compositeAutoRotation);
|
|
668
665
|
}
|
|
669
|
-
if (compositeAutoFlip) {
|
|
670
|
-
compositeImage = compositeImage.flip(VIPS_DIRECTION_VERTICAL);
|
|
671
|
-
}
|
|
672
666
|
if (compositeAutoFlop) {
|
|
673
667
|
compositeImage = compositeImage.flip(VIPS_DIRECTION_HORIZONTAL);
|
|
674
668
|
}
|
|
@@ -1400,21 +1394,20 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|
|
1400
1394
|
Calculate the angle of rotation and need-to-flip for the given Exif orientation
|
|
1401
1395
|
By default, returns zero, i.e. no rotation.
|
|
1402
1396
|
*/
|
|
1403
|
-
std::tuple<VipsAngle, bool
|
|
1404
|
-
|
|
1397
|
+
std::tuple<VipsAngle, bool>
|
|
1398
|
+
CalculateExifRotationAndFlop(int const exifOrientation) {
|
|
1405
1399
|
VipsAngle rotate = VIPS_ANGLE_D0;
|
|
1406
|
-
bool flip = false;
|
|
1407
1400
|
bool flop = false;
|
|
1408
1401
|
switch (exifOrientation) {
|
|
1409
1402
|
case 6: rotate = VIPS_ANGLE_D90; break;
|
|
1410
1403
|
case 3: rotate = VIPS_ANGLE_D180; break;
|
|
1411
1404
|
case 8: rotate = VIPS_ANGLE_D270; break;
|
|
1412
|
-
case 2: flop = true; break;
|
|
1413
|
-
case 7:
|
|
1414
|
-
case 4: flop = true; rotate = VIPS_ANGLE_D180; break;
|
|
1415
|
-
case 5:
|
|
1405
|
+
case 2: flop = true; break;
|
|
1406
|
+
case 7: flop = true; rotate = VIPS_ANGLE_D270; break;
|
|
1407
|
+
case 4: flop = true; rotate = VIPS_ANGLE_D180; break;
|
|
1408
|
+
case 5: flop = true; rotate = VIPS_ANGLE_D90; break;
|
|
1416
1409
|
}
|
|
1417
|
-
return std::make_tuple(rotate,
|
|
1410
|
+
return std::make_tuple(rotate, flop);
|
|
1418
1411
|
}
|
|
1419
1412
|
|
|
1420
1413
|
/*
|
|
@@ -1639,7 +1632,8 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|
|
1639
1632
|
baton->angle = sharp::AttrAsInt32(options, "angle");
|
|
1640
1633
|
baton->rotationAngle = sharp::AttrAsDouble(options, "rotationAngle");
|
|
1641
1634
|
baton->rotationBackground = sharp::AttrAsVectorOfDouble(options, "rotationBackground");
|
|
1642
|
-
baton->
|
|
1635
|
+
baton->rotateBefore = sharp::AttrAsBool(options, "rotateBefore");
|
|
1636
|
+
baton->orientBefore = sharp::AttrAsBool(options, "orientBefore");
|
|
1643
1637
|
baton->flip = sharp::AttrAsBool(options, "flip");
|
|
1644
1638
|
baton->flop = sharp::AttrAsBool(options, "flop");
|
|
1645
1639
|
baton->extendTop = sharp::AttrAsInt32(options, "extendTop");
|
package/src/pipeline.h
CHANGED
package/src/sharp.cc
CHANGED
|
@@ -18,10 +18,8 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
18
18
|
vips_init("sharp");
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
|
|
24
|
-
}
|
|
21
|
+
g_log_set_handler("VIPS", static_cast<GLogLevelFlags>(G_LOG_LEVEL_WARNING),
|
|
22
|
+
static_cast<GLogFunc>(sharp::VipsWarningCallback), nullptr);
|
|
25
23
|
|
|
26
24
|
// Methods available to JavaScript
|
|
27
25
|
exports.Set("metadata", Napi::Function::New(env, metadata));
|