sharp 0.31.1 → 0.31.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/lib/resize.js CHANGED
@@ -111,7 +111,7 @@ function isResizeExpected (options) {
111
111
  *
112
112
  * Some of these values are based on the [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property.
113
113
  *
114
- * When using a `fit` of `cover` or `contain`, the default **position** is `centre`. Other options are:
114
+ * When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are:
115
115
  * - `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.
116
116
  * - `sharp.gravity`: `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` or `centre`.
117
117
  * - `sharp.strategy`: `cover` only, dynamically crop using either the `entropy` or `attention` strategy.
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.31.1",
4
+ "version": "0.31.2",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -92,7 +92,7 @@
92
92
  "clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
93
93
  "test": "npm run test-lint && npm run test-unit && npm run test-licensing",
94
94
  "test-lint": "semistandard && cpplint",
95
- "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha --slow=1000 --timeout=20000 ./test/unit/*.js",
95
+ "test-unit": "nyc --reporter=lcov --reporter=text --check-coverage --branches=100 mocha --slow=1000 --timeout=30000 ./test/unit/*.js",
96
96
  "test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"",
97
97
  "test-leak": "./test/leak/leak.sh",
98
98
  "docs-build": "documentation lint lib && node docs/build && node docs/search-index/build",
@@ -133,7 +133,7 @@
133
133
  "detect-libc": "^2.0.1",
134
134
  "node-addon-api": "^5.0.0",
135
135
  "prebuild-install": "^7.1.1",
136
- "semver": "^7.3.7",
136
+ "semver": "^7.3.8",
137
137
  "simple-get": "^4.0.1",
138
138
  "tar-fs": "^2.1.1",
139
139
  "tunnel-agent": "^0.6.0"
@@ -146,8 +146,8 @@
146
146
  "extract-zip": "^2.0.1",
147
147
  "icc": "^2.0.0",
148
148
  "license-checker": "^25.0.1",
149
- "mocha": "^10.0.0",
150
- "mock-fs": "^5.1.4",
149
+ "mocha": "^10.1.0",
150
+ "mock-fs": "^5.2.0",
151
151
  "nyc": "^15.1.0",
152
152
  "prebuild": "^11.0.4",
153
153
  "rimraf": "^3.0.2",
@@ -155,19 +155,19 @@
155
155
  },
156
156
  "license": "Apache-2.0",
157
157
  "config": {
158
- "libvips": "8.13.2",
158
+ "libvips": "8.13.3",
159
159
  "integrity": {
160
- "darwin-arm64v8": "sha512-4tsE/HMQDT9srV/ovSJlr7IxKnhvH9qpArCAf5Xpb/uNcAiT7BcZ+HYwX2lbf3UY8REB1TR4ThEL/lmPnzMUHw==",
161
- "darwin-x64": "sha512-D4ZSvlgLpf+KzKB2OD+K8NWl0JKzzIbvWwIjjwBycIHTMkaiams3Kp/AQ/bKudqof02Ks6LtP0X4XWvCaoRoUA==",
162
- "linux-arm64v8": "sha512-9ZvUM2NBluhoeUz9X7/zJ48xJ5d7KzI1cO6lsiv4HKo5fOYw/vEY28XodFJzhyfu9NuKxh3Hs9FtoQGNvvAFkw==",
163
- "linux-armv6": "sha512-vu0R8DF0k7KseU62fzrJadHNk5oeJriFLVn3KxCKEfV+Wkj7rX4lQhiPmOuD7/wRcUY+GGdoZ52vysDwMQhfzA==",
164
- "linux-armv7": "sha512-UdfhJTjGFgrwc3Kaos5G1ZAK2+t/16Prtnl6FAT+m7cG5EXzYAqzgvk4qtakAH7UTnVe8MUgOfbTLt0YiRpfsg==",
165
- "linux-x64": "sha512-sv92VpPyN+3oBv0vi4wDjx51demGdtyhEjd+vDfC3h8S/RSuIUE9Pt/+dBFuf+iv9tRdIq9hH9vzAvsLVy6NYg==",
166
- "linuxmusl-arm64v8": "sha512-TjhK/wHAS/m55l46T8PZ0qvlK+PKYFZGTQfh+c9aG8/z1v/VtG7TQOLNmPWfg0SFDTkXV7YqnJCqvgYLmJPZUg==",
167
- "linuxmusl-x64": "sha512-/su96pn/H9+lDdnlM1xB2whWEoeEDJICFp/RNRJb0+bJPJhnL/IDVIhF4VnVNBq/9AlldBWii3hqMq5rY2eEAA==",
168
- "win32-arm64v8": "sha512-UnSmwCcx3F5u4UOXyrdwTdYsuMK/RtQYc+1y+QxqIkBHiSL7dOlTIH/vKOSQvSaDQTPqxVLFt3wkMN1U7LZwyg==",
169
- "win32-ia32": "sha512-KH/H6vpx5lJ6NEzLQmwxU/QnDg8p1Jxd+WKaPiyWmXq/HpwyKrZhi3WDoyKD4fLwnlfhAXEfVLZbUbhX21pDpQ==",
170
- "win32-x64": "sha512-Xim5F21pqx7MuVQViaQNhSz24zWIiKHC9bm4KCdi7q/ytbvdMhm6bzWDI/mvFGNjI62NRB2SBkTTaqwJvM/pUg=="
160
+ "darwin-arm64v8": "sha512-xFgYt7CtQSZcWoyUdzPTDNHbioZIrZSEU+gkMxzH4Cgjhi4/N49UsonnIZhKQoTBGloAqEexHeMx4rYTQ2Kgvw==",
161
+ "darwin-x64": "sha512-6SivWKzu15aUMMohe0wg7sNYMPETVnOe40BuWsnKOgzl3o5FpQqNSgs+68Mi8Za3Qti9/DaR+H/fyD0x48Af2w==",
162
+ "linux-arm64v8": "sha512-b+iI9V/ehgDabXYRQcvqa5CEysh+1FQsgFmYc358StCrJCDahwNmsQdsiH1GOVd5WaWh5wHUGByPwMmFOO16Aw==",
163
+ "linux-armv6": "sha512-zRP2F+EiustLE4bXSH8AHCxwfemh9d+QuvmPjira/HL6uJOUuA7SyQgVV1TPwTQle2ioCNnKPm7FEB/MAiT+ug==",
164
+ "linux-armv7": "sha512-6OCChowE5lBXXXAZrnGdA9dVktg7UdODEBpE5qTroiAJYZv4yXRMgyDFYajok7du2NTgoklhxGk8d9+4vGv5hg==",
165
+ "linux-x64": "sha512-OTmlmP2r8ozGKdB96X+K5oQE1ojVZanqLqqKlwDpEnfixyIaDGYbVzcjWBNGU3ai/26bvkaCkjynnc2ecYcsuA==",
166
+ "linuxmusl-arm64v8": "sha512-Qh5Wi+bkKTohFYHzSPssfjMhIkD6z6EHbVmnwmWSsgY9zsUBStFp6+mKcNTQfP5YM5Mz06vJOkLHX2OzEr5TzA==",
167
+ "linuxmusl-x64": "sha512-DwB4Fs3+ISw9etaLCANkueZDdk758iOS+wNp4TKZkHdq0al6B/3Pk7OHLR8a9E3H6wYDD328u++dcJzip5tacA==",
168
+ "win32-arm64v8": "sha512-96r3W+O4BtX602B1MtxU5Ru4lKzRRTZqM4OQEBJ//TNL3fiCZdd9agD+RQBjaeR4KFIyBSt3F7IE425ZWmxz+w==",
169
+ "win32-ia32": "sha512-qfN1MsfQGek1QQd1UNW7JT+5K5Ne1suFQ2GpgpYm3JLSpIve/tz2vOGEGzvTVssOBADJvAkTDFt+yIi3PgU9pA==",
170
+ "win32-x64": "sha512-eb3aAmjbVVBVRbiYgebQwoxkAt69WI8nwmKlilSQ3kWqoc0pXfIe322rF2UR8ebbISCGvYRUfzD2r1k92RXISQ=="
171
171
  },
172
172
  "runtime": "napi",
173
173
  "target": 7
package/src/common.h CHANGED
@@ -26,8 +26,8 @@
26
26
 
27
27
  #if (VIPS_MAJOR_VERSION < 8) || \
28
28
  (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 13) || \
29
- (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 13 && VIPS_MICRO_VERSION < 2)
30
- #error "libvips version 8.13.2+ is required - please see https://sharp.pixelplumbing.com/install"
29
+ (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION == 13 && VIPS_MICRO_VERSION < 3)
30
+ #error "libvips version 8.13.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)))
package/src/pipeline.cc CHANGED
@@ -81,35 +81,47 @@ class PipelineWorker : public Napi::AsyncWorker {
81
81
  int pageHeight = sharp::GetPageHeight(image);
82
82
 
83
83
  // Calculate angle of rotation
84
- VipsAngle rotation;
85
- bool flip = FALSE;
86
- bool flop = FALSE;
84
+ VipsAngle rotation = VIPS_ANGLE_D0;
85
+ VipsAngle autoRotation = VIPS_ANGLE_D0;
86
+ bool autoFlip = FALSE;
87
+ bool autoFlop = FALSE;
87
88
  if (baton->useExifOrientation) {
88
89
  // Rotate and flip image according to Exif orientation
89
- std::tie(rotation, flip, flop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
90
+ std::tie(autoRotation, autoFlip, autoFlop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
91
+ image = sharp::RemoveExifOrientation(image);
90
92
  } else {
91
93
  rotation = CalculateAngleRotation(baton->angle);
92
94
  }
93
95
 
94
96
  // Rotate pre-extract
95
97
  bool const shouldRotateBefore = baton->rotateBeforePreExtract &&
96
- (rotation != VIPS_ANGLE_D0 || flip || flop || baton->rotationAngle != 0.0);
98
+ (rotation != VIPS_ANGLE_D0 || autoRotation != VIPS_ANGLE_D0 ||
99
+ autoFlip || baton->flip || autoFlop || baton->flop ||
100
+ baton->rotationAngle != 0.0);
97
101
 
98
102
  if (shouldRotateBefore) {
99
- if (rotation != VIPS_ANGLE_D0) {
100
- image = image.rot(rotation);
103
+ if (autoRotation != VIPS_ANGLE_D0) {
104
+ image = image.rot(autoRotation);
105
+ autoRotation = VIPS_ANGLE_D0;
101
106
  }
102
- if (flip) {
107
+ if (autoFlip) {
103
108
  image = image.flip(VIPS_DIRECTION_VERTICAL);
109
+ autoFlip = FALSE;
110
+ } else if (baton->flip) {
111
+ image = image.flip(VIPS_DIRECTION_VERTICAL);
112
+ baton->flip = FALSE;
104
113
  }
105
- if (flop) {
114
+ if (autoFlop) {
115
+ image = image.flip(VIPS_DIRECTION_HORIZONTAL);
116
+ autoFlop = FALSE;
117
+ } else if (baton->flop) {
106
118
  image = image.flip(VIPS_DIRECTION_HORIZONTAL);
119
+ baton->flop = FALSE;
107
120
  }
108
- if (rotation != VIPS_ANGLE_D0 || flip || flop) {
109
- image = sharp::RemoveExifOrientation(image);
121
+ if (rotation != VIPS_ANGLE_D0) {
122
+ image = image.rot(rotation);
123
+ rotation = VIPS_ANGLE_D0;
110
124
  }
111
- flop = FALSE;
112
- flip = FALSE;
113
125
  if (baton->rotationAngle != 0.0) {
114
126
  MultiPageUnsupported(nPages, "Rotate");
115
127
  std::vector<double> background;
@@ -150,7 +162,9 @@ class PipelineWorker : public Napi::AsyncWorker {
150
162
  int targetResizeHeight = baton->height;
151
163
 
152
164
  // Swap input output width and height when rotating by 90 or 270 degrees
153
- bool swap = !baton->rotateBeforePreExtract && (rotation == VIPS_ANGLE_D90 || rotation == VIPS_ANGLE_D270);
165
+ bool swap = !baton->rotateBeforePreExtract &&
166
+ (rotation == VIPS_ANGLE_D90 || rotation == VIPS_ANGLE_D270 ||
167
+ autoRotation == VIPS_ANGLE_D90 || autoRotation == VIPS_ANGLE_D270);
154
168
 
155
169
  // Shrink to pageHeight, so we work for multi-page images
156
170
  std::tie(hshrink, vshrink) = sharp::ResolveShrink(
@@ -367,30 +381,21 @@ class PipelineWorker : public Napi::AsyncWorker {
367
381
  ->set("kernel", baton->kernel));
368
382
  }
369
383
 
384
+ // Auto-rotate post-extract
385
+ if (autoRotation != VIPS_ANGLE_D0) {
386
+ image = image.rot(autoRotation);
387
+ }
370
388
  // Flip (mirror about Y axis)
371
- if (baton->flip || flip) {
389
+ if (baton->flip || autoFlip) {
372
390
  image = image.flip(VIPS_DIRECTION_VERTICAL);
373
- image = sharp::RemoveExifOrientation(image);
374
391
  }
375
-
376
392
  // Flop (mirror about X axis)
377
- if (baton->flop || flop) {
393
+ if (baton->flop || autoFlop) {
378
394
  image = image.flip(VIPS_DIRECTION_HORIZONTAL);
379
- image = sharp::RemoveExifOrientation(image);
380
395
  }
381
-
382
396
  // Rotate post-extract 90-angle
383
- if (!baton->rotateBeforePreExtract && rotation != VIPS_ANGLE_D0) {
397
+ if (rotation != VIPS_ANGLE_D0) {
384
398
  image = image.rot(rotation);
385
- if (flip) {
386
- image = image.flip(VIPS_DIRECTION_VERTICAL);
387
- flip = FALSE;
388
- }
389
- if (flop) {
390
- image = image.flip(VIPS_DIRECTION_HORIZONTAL);
391
- flop = FALSE;
392
- }
393
- image = sharp::RemoveExifOrientation(image);
394
399
  }
395
400
 
396
401
  // Join additional color channels to the image