Expose libvips centre option, mimics *magick +0.5px convention

This commit is contained in:
Lovell Fuller
2016-11-04 18:16:16 +00:00
parent deb978bf57
commit 9911863441
9 changed files with 201 additions and 163 deletions

View File

@@ -94,6 +94,8 @@ const interpolator = {
* @param {Object} [options]
* @param {String} [options.kernel='lanczos3'] - the kernel to use for image reduction.
* @param {String} [options.interpolator='bicubic'] - the interpolator to use for image enlargement.
* @param {Boolean} [options.centreSampling=false] - use *magick centre sampling convention instead of corner sampling.
* @param {Boolean} [options.centerSampling=false] - alternative spelling of centreSampling.
* @returns {Sharp}
* @throws {Error} Invalid parameters
*/
@@ -133,6 +135,11 @@ const resize = function resize (width, height, options) {
throw new Error('Invalid interpolator ' + options.interpolator);
}
}
// Centre sampling
options.centreSampling = is.bool(options.centerSampling) ? options.centerSampling : options.centreSampling;
if (is.defined(options.centreSampling)) {
this._setBooleanOption('centreSampling', options.centreSampling);
}
}
return this;
};