Comparing version 0.5.0 to 0.5.1
62
index.js
@@ -18,6 +18,7 @@ /*jslint node: true */ | ||
sharpen: false, | ||
interpolator: 'bilinear', | ||
progressive: false, | ||
sequentialRead: false, | ||
quality: 80, | ||
compressionLevel: 6, | ||
quality: 80, | ||
compressionLevel: 6, | ||
output: '__jpeg' | ||
@@ -31,6 +32,6 @@ }; | ||
} else { | ||
throw 'Buffer is empty'; | ||
throw new Error('Buffer is empty'); | ||
} | ||
} else { | ||
throw 'Unsupported input ' + typeof input; | ||
throw new Error('Unsupported input ' + typeof input); | ||
} | ||
@@ -71,3 +72,3 @@ return this; | ||
} else { | ||
throw 'Unsupport angle (0, 90, 180, 270) ' + angle; | ||
throw new Error('Unsupported angle (0, 90, 180, 270) ' + angle); | ||
} | ||
@@ -92,2 +93,26 @@ return this; | ||
/* | ||
Use bilinear interpolation for the affine transformation (fastest, default) | ||
*/ | ||
Sharp.prototype.bilinearInterpolation = function() { | ||
this.options.interpolator = 'bilinear'; | ||
return this; | ||
}; | ||
/* | ||
Use bicubic interpolation for the affine transformation | ||
*/ | ||
Sharp.prototype.bicubicInterpolation = function() { | ||
this.options.interpolator = 'bicubic'; | ||
return this; | ||
}; | ||
/* | ||
Use Nohalo interpolation for the affine transformation | ||
*/ | ||
Sharp.prototype.nohaloInterpolation = function() { | ||
this.options.interpolator = 'nohalo'; | ||
return this; | ||
}; | ||
Sharp.prototype.progressive = function(progressive) { | ||
@@ -107,3 +132,3 @@ this.options.progressive = (typeof progressive === 'boolean') ? progressive : true; | ||
} else { | ||
throw 'Invalid quality (1 to 100) ' + quality; | ||
throw new Error('Invalid quality (1 to 100) ' + quality); | ||
} | ||
@@ -117,3 +142,3 @@ return this; | ||
} else { | ||
throw 'Invalid compressionLevel (-1 to 9) ' + compressionLevel; | ||
throw new Error('Invalid compressionLevel (-1 to 9) ' + compressionLevel); | ||
} | ||
@@ -130,3 +155,3 @@ return this; | ||
} else { | ||
throw 'Invalid width ' + width; | ||
throw new Error('Invalid width ' + width); | ||
} | ||
@@ -140,3 +165,3 @@ } | ||
} else { | ||
throw 'Invalid height ' + height; | ||
throw new Error('Invalid height ' + height); | ||
} | ||
@@ -152,6 +177,16 @@ } | ||
if (!output || output.length === 0) { | ||
callback('Invalid output'); | ||
var errOutputInvalid = new Error('Invalid output'); | ||
if (typeof callback === 'function') { | ||
callback(errOutputInvalid); | ||
} else { | ||
return Promise.reject(errOutputInvalid); | ||
} | ||
} else { | ||
if (this.options.fileIn === output) { | ||
callback('Cannot use same file for input and output'); | ||
var errOutputIsInput = new Error('Cannot use same file for input and output'); | ||
if (typeof callback === 'function') { | ||
callback(errOutputIsInput); | ||
} else { | ||
return Promise.reject(errOutputIsInput); | ||
} | ||
} else { | ||
@@ -165,3 +200,6 @@ return this._sharp(output, callback); | ||
// Deprecated to make way for future stream support - remove in v0.6.0 | ||
Sharp.prototype.write = Sharp.prototype.toFile; | ||
Sharp.prototype.write = require('util').deprecate( | ||
Sharp.prototype.toFile, | ||
'.write() is deprecated and will be removed in v0.6.0. Use .toFile() instead.' | ||
); | ||
@@ -168,0 +206,0 @@ Sharp.prototype.toBuffer = function(callback) { |
{ | ||
"name": "sharp", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"author": "Lovell Fuller <npm@lovell.info>", | ||
"contributors": [ | ||
"Pierre Inglebert <pierre.inglebert@gmail.com>" | ||
"Pierre Inglebert <pierre.inglebert@gmail.com>", | ||
"Jonathan Ong <jonathanrichardong@gmail.com>" | ||
], | ||
@@ -34,8 +35,8 @@ "description": "High performance Node.js module to resize JPEG, PNG and WebP images using the libvips library", | ||
"dependencies": { | ||
"nan": "^1.1.2", | ||
"bluebird": "^1.2.4" | ||
"nan": "^1.2.0", | ||
"bluebird": "^2.1.2" | ||
}, | ||
"devDependencies": { | ||
"imagemagick": "^0.1.3", | ||
"imagemagick-native": "^1.0.0", | ||
"imagemagick-native": "^1.1.1", | ||
"gm": "^1.16.0", | ||
@@ -42,0 +43,0 @@ "async": "^0.9.0", |
@@ -56,3 +56,3 @@ # sharp | ||
./bootstrap.sh | ||
./configure --enable-debug=no --enable-cxx=no --without-python --without-orc | ||
./configure --enable-debug=no --enable-cxx=yes --without-python --without-orc | ||
make | ||
@@ -104,4 +104,4 @@ sudo make install | ||
```javascript | ||
sharp(inputBuffer).resize(200, 300).embedWhite().toFile('output.tiff').then(function() { | ||
// output.tiff is a 200 pixels wide and 300 pixels high image containing a scaled | ||
sharp(inputBuffer).resize(200, 300).bicubicInterpolation().embedWhite().toFile('output.tiff').then(function() { | ||
// output.tiff is a 200 pixels wide and 300 pixels high image containing a bicubic scaled | ||
// version, embedded on a white canvas, of the image data in buffer | ||
@@ -181,2 +181,14 @@ }); | ||
### bilinearInterpolation() | ||
Use [bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation) for image resizing, the default (and fastest) interpolation if none is specified. | ||
### bicubicInterpolation() | ||
Use [bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) for image resizing. This typically reduces performance by 5%. | ||
### nohaloInterpolation() | ||
Use [Nohalo interpolation](http://eprints.soton.ac.uk/268086/) for image resizing. This typically reduces performance by a factor of 2. | ||
### progressive() | ||
@@ -226,3 +238,3 @@ | ||
### png(callback) | ||
### png([callback]) | ||
@@ -229,0 +241,0 @@ Write PNG image data to a Buffer. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50846
8
254
330
2
+ Addedbluebird@2.11.0(transitive)
- Removedbluebird@1.2.4(transitive)
Updatedbluebird@^2.1.2
Updatednan@^1.2.0