sharp 0.18.1 → 0.18.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.js CHANGED
@@ -9,7 +9,7 @@ const got = require('got');
9
9
  const semver = require('semver');
10
10
  const tar = require('tar');
11
11
 
12
- const distBaseUrl = 'https://dl.bintray.com/lovell/sharp/';
12
+ const distBaseUrl = process.env.SHARP_DIST_BASE_URL || 'https://dl.bintray.com/lovell/sharp/';
13
13
 
14
14
  // Use NPM-provided environment variable where available, falling back to require-based method for Electron
15
15
  const minimumLibvipsVersion = process.env.npm_package_config_libvips || require('./package.json').config.libvips;
@@ -73,7 +73,7 @@ module.exports.download_vips = function () {
73
73
  // Ensure glibc >= 2.15
74
74
  const lddVersion = process.env.LDD_VERSION;
75
75
  if (lddVersion) {
76
- if (/(glibc|gnu libc|gentoo)/i.test(lddVersion)) {
76
+ if (/(glibc|gnu libc|gentoo|solus)/i.test(lddVersion)) {
77
77
  const glibcVersion = lddVersion ? lddVersion.split(/\n/)[0].split(' ').slice(-1)[0].trim() : '';
78
78
  if (glibcVersion && semver.lt(glibcVersion + '.0', '2.13.0')) {
79
79
  error('glibc version ' + glibcVersion + ' requires manual installation - please see http://sharp.dimens.io/en/stable/install/');
@@ -140,6 +140,8 @@ Use these TIFF options for output image.
140
140
  - `options.force` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** force TIFF output, otherwise attempt to use input format (optional, default `true`)
141
141
  - `options.compression` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** compression options: lzw, deflate, jpeg (optional, default `'jpeg'`)
142
142
  - `options.predictor` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** compression predictor options: none, horizontal, float (optional, default `'none'`)
143
+ - `options.xres` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** horizontal resolution in pixels/mm (optional, default `1.0`)
144
+ - `options.yres` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** vertical resolution in pixels/mm (optional, default `1.0`)
143
145
  - `options.squash` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** squash 8-bit images down to 1 bit (optional, default `false`)
144
146
 
145
147
 
package/docs/changelog.md CHANGED
@@ -4,6 +4,23 @@
4
4
 
5
5
  Requires libvips v8.5.5.
6
6
 
7
+ #### v0.18.2 - 1<sup>st</sup> July 2017
8
+
9
+ * Expose libvips' xres and yres properties for TIFF output.
10
+ [#828](https://github.com/lovell/sharp/pull/828)
11
+ [@YvesBos](https://github.com/YvesBos)
12
+
13
+ * Ensure flip and flop operations work with auto-rotate.
14
+ [#837](https://github.com/lovell/sharp/issues/837)
15
+ [@rexxars](https://github.com/rexxars)
16
+
17
+ * Allow binary download URL override via SHARP_DIST_BASE_URL env variable.
18
+ [#841](https://github.com/lovell/sharp/issues/841)
19
+
20
+ * Add support for Solus Linux.
21
+ [#857](https://github.com/lovell/sharp/pull/857)
22
+ [@ekremkaraca](https://github.com/ekremkaraca)
23
+
7
24
  #### v0.18.1 - 30<sup>th</sup> May 2017
8
25
 
9
26
  * Remove regression from #781 that could cause incorrect shrink calculation.
package/docs/install.md CHANGED
@@ -10,7 +10,7 @@ yarn add sharp
10
10
 
11
11
  ### Prerequisites
12
12
 
13
- * Node v4+
13
+ * Node v4.5.0+
14
14
  * C++11 compatible compiler such as gcc 4.8+, clang 3.0+ or MSVC 2013+
15
15
  * [node-gyp](https://github.com/TooTallNate/node-gyp#installation) and its dependencies (includes Python)
16
16
 
@@ -32,6 +32,7 @@ Most recent Linux-based operating systems with glibc running on x64 and ARMv6+ C
32
32
  * Archlinux
33
33
  * Raspbian Jessie
34
34
  * Amazon Linux 2016.03, 2016.09
35
+ * Solus
35
36
 
36
37
  To use a globally-installed version of libvips instead of the provided binaries,
37
38
  make sure it is at least the version listed under `config.libvips` in the `package.json` file
@@ -48,8 +49,17 @@ it is recommended to install a system-wide installation of libvips from source:
48
49
 
49
50
  https://github.com/jcupitt/libvips#building-libvips-from-a-source-tarball
50
51
 
51
- For Linux-based operating systems such as Alpine that use musl libc,
52
- the smaller stack size means libvips' cache should be disabled
52
+ #### Alpine Linux
53
+
54
+ libvips is available in the
55
+ [testing repository](https://pkgs.alpinelinux.org/packages?name=vips-dev):
56
+
57
+ ```sh
58
+ apk add vips-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
59
+ ```
60
+
61
+ The smaller stack size of musl libc means
62
+ libvips may need to be used without a cache
53
63
  via `sharp.cache(false)` to avoid a stack overflow.
54
64
 
55
65
  ### Mac OS
@@ -183,16 +193,27 @@ configuration file to prevent the use of coders known to be vulnerable.
183
193
  Set the `MAGICK_CONFIGURE_PATH` environment variable
184
194
  to the directory containing the `policy.xml` file.
185
195
 
186
- ### Licences
196
+ ### Pre-compiled libvips binaries
187
197
 
188
198
  If a global installation of libvips that meets the
189
199
  minimum version requirement cannot be found,
190
- this module will download a pre-compiled bundle of libvips
200
+ this module will attempt to download a pre-compiled bundle of libvips
191
201
  and its dependencies on Linux and Windows machines.
192
202
 
193
203
  Should you need to manually download and inspect these files,
194
204
  you can do so via https://dl.bintray.com/lovell/sharp/
195
205
 
206
+ Should you wish to install these from your own location,
207
+ set the `SHARP_DIST_BASE_URL` environment variable, e.g.
208
+
209
+ ```sh
210
+ SHARP_DIST_BASE_URL="https://hostname/path/" npm install sharp
211
+ ```
212
+
213
+ to use `https://hostname/path/libvips-x.y.z-platform.tar.gz`.
214
+
215
+ ### Licences
216
+
196
217
  This module is licensed under the terms of the
197
218
  [Apache 2.0 Licence](https://github.com/lovell/sharp/blob/master/LICENSE).
198
219
 
@@ -180,6 +180,8 @@ const Sharp = function (input, options) {
180
180
  tiffCompression: 'jpeg',
181
181
  tiffPredictor: 'none',
182
182
  tiffSquash: false,
183
+ tiffXres: 1.0,
184
+ tiffYres: 1.0,
183
185
  tileSize: 256,
184
186
  tileOverlap: 0,
185
187
  // Function to notify of libvips warnings
package/lib/output.js CHANGED
@@ -214,6 +214,8 @@ function webp (options) {
214
214
  * @param {Boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format
215
215
  * @param {Boolean} [options.compression='jpeg'] - compression options: lzw, deflate, jpeg
216
216
  * @param {Boolean} [options.predictor='none'] - compression predictor options: none, horizontal, float
217
+ * @param {Number} [options.xres=1.0] - horizontal resolution in pixels/mm
218
+ * @param {Number} [options.yres=1.0] - vertical resolution in pixels/mm
217
219
  * @param {Boolean} [options.squash=false] - squash 8-bit images down to 1 bit
218
220
  * @returns {Sharp}
219
221
  * @throws {Error} Invalid options
@@ -233,6 +235,21 @@ function tiff (options) {
233
235
  throw new Error('Invalid Value for squash ' + options.squash + ' Only Boolean Values allowed for options.squash.');
234
236
  }
235
237
  }
238
+ // resolution
239
+ if (is.object(options) && is.defined(options.xres)) {
240
+ if (is.number(options.xres)) {
241
+ this.options.tiffXres = options.xres;
242
+ } else {
243
+ throw new Error('Invalid Value for xres ' + options.xres + ' Only numeric values allowed for options.xres');
244
+ }
245
+ }
246
+ if (is.object(options) && is.defined(options.yres)) {
247
+ if (is.number(options.yres)) {
248
+ this.options.tiffYres = options.yres;
249
+ } else {
250
+ throw new Error('Invalid Value for yres ' + options.yres + ' Only numeric values allowed for options.yres');
251
+ }
252
+ }
236
253
  // compression
237
254
  if (is.defined(options) && is.defined(options.compression)) {
238
255
  if (is.string(options.compression) && is.inArray(options.compression, ['lzw', 'deflate', 'jpeg', 'none'])) {
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 and TIFF images",
4
- "version": "0.18.1",
4
+ "version": "0.18.2",
5
5
  "author": "Lovell Fuller <npm@lovell.info>",
6
6
  "homepage": "https://github.com/lovell/sharp",
7
7
  "contributors": [
@@ -68,20 +68,20 @@
68
68
  ],
69
69
  "dependencies": {
70
70
  "caw": "^2.0.0",
71
- "color": "^1.0.3",
72
- "got": "^7.0.0",
71
+ "color": "^2.0.0",
72
+ "got": "^7.1.0",
73
73
  "nan": "^2.6.2",
74
74
  "semver": "^5.3.0",
75
- "tar": "^3.1.3"
75
+ "tar": "^3.1.5"
76
76
  },
77
77
  "devDependencies": {
78
- "async": "^2.4.1",
78
+ "async": "^2.5.0",
79
79
  "cc": "^1.0.1",
80
80
  "documentation": "^4.0.0-rc.1",
81
81
  "exif-reader": "^1.0.2",
82
82
  "icc": "^1.0.0",
83
83
  "mocha": "^3.4.2",
84
- "nyc": "^10.3.2",
84
+ "nyc": "^11.0.3",
85
85
  "rimraf": "^2.6.1",
86
86
  "semistandard": "^11.0.0",
87
87
  "unzip": "^0.1.11"
@@ -91,7 +91,7 @@
91
91
  "libvips": "8.5.5"
92
92
  },
93
93
  "engines": {
94
- "node": ">=4"
94
+ "node": ">=4.5.0"
95
95
  },
96
96
  "semistandard": {
97
97
  "env": [
package/src/common.cc CHANGED
@@ -438,9 +438,11 @@ namespace sharp {
438
438
  // Southeast
439
439
  left = inWidth - outWidth;
440
440
  top = inHeight - outHeight;
441
+ break;
441
442
  case 7:
442
443
  // Southwest
443
444
  top = inHeight - outHeight;
445
+ break;
444
446
  case 8:
445
447
  // Northwest
446
448
  break;
package/src/pipeline.cc CHANGED
@@ -83,8 +83,11 @@ class PipelineWorker : public Nan::AsyncWorker {
83
83
  VipsAngle rotation;
84
84
  if (baton->useExifOrientation) {
85
85
  // Rotate and flip image according to Exif orientation
86
- // (ignore the requested rotation and flip)
87
- std::tie(rotation, baton->flip, baton->flop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
86
+ bool flip;
87
+ bool flop;
88
+ std::tie(rotation, flip, flop) = CalculateExifRotationAndFlip(sharp::ExifOrientation(image));
89
+ baton->flip = baton->flip || flip;
90
+ baton->flop = baton->flop || flop;
88
91
  } else {
89
92
  rotation = CalculateAngleRotation(baton->angle);
90
93
  }
@@ -808,7 +811,9 @@ class PipelineWorker : public Nan::AsyncWorker {
808
811
  ->set("Q", baton->tiffQuality)
809
812
  ->set("squash", baton->tiffSquash)
810
813
  ->set("compression", baton->tiffCompression)
811
- ->set("predictor", baton->tiffPredictor)));
814
+ ->set("predictor", baton->tiffPredictor)
815
+ ->set("xres", baton->tiffXres)
816
+ ->set("yres", baton->tiffYres)));
812
817
  baton->bufferOut = static_cast<char*>(area->data);
813
818
  baton->bufferOutLength = area->length;
814
819
  area->free_fn = nullptr;
@@ -904,7 +909,9 @@ class PipelineWorker : public Nan::AsyncWorker {
904
909
  ->set("Q", baton->tiffQuality)
905
910
  ->set("squash", baton->tiffSquash)
906
911
  ->set("compression", baton->tiffCompression)
907
- ->set("predictor", baton->tiffPredictor));
912
+ ->set("predictor", baton->tiffPredictor)
913
+ ->set("xres", baton->tiffXres)
914
+ ->set("yres", baton->tiffYres));
908
915
  baton->formatOut = "tiff";
909
916
  baton->channels = std::min(baton->channels, 3);
910
917
  } else if (baton->formatOut == "dz" || isDz || isDzZip) {
@@ -1277,6 +1284,8 @@ NAN_METHOD(pipeline) {
1277
1284
  baton->webpNearLossless = AttrTo<bool>(options, "webpNearLossless");
1278
1285
  baton->tiffQuality = AttrTo<uint32_t>(options, "tiffQuality");
1279
1286
  baton->tiffSquash = AttrTo<bool>(options, "tiffSquash");
1287
+ baton->tiffXres = AttrTo<double>(options, "tiffXres");
1288
+ baton->tiffYres = AttrTo<double>(options, "tiffYres");
1280
1289
  // tiff compression options
1281
1290
  baton->tiffCompression = static_cast<VipsForeignTiffCompression>(
1282
1291
  vips_enum_from_nick(nullptr, VIPS_TYPE_FOREIGN_TIFF_COMPRESSION,
package/src/pipeline.h CHANGED
@@ -109,6 +109,8 @@ struct PipelineBaton {
109
109
  VipsForeignTiffCompression tiffCompression;
110
110
  VipsForeignTiffPredictor tiffPredictor;
111
111
  bool tiffSquash;
112
+ double tiffXres;
113
+ double tiffYres;
112
114
  std::string err;
113
115
  bool withMetadata;
114
116
  int withMetadataOrientation;
@@ -182,6 +184,8 @@ struct PipelineBaton {
182
184
  tiffCompression(VIPS_FOREIGN_TIFF_COMPRESSION_JPEG),
183
185
  tiffPredictor(VIPS_FOREIGN_TIFF_PREDICTOR_NONE),
184
186
  tiffSquash(false),
187
+ tiffXres(1.0),
188
+ tiffYres(1.0),
185
189
  withMetadata(false),
186
190
  withMetadataOrientation(-1),
187
191
  convKernelWidth(0),