mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Expose libvips centre option, mimics *magick +0.5px convention
This commit is contained in:
@@ -102,6 +102,7 @@ const Sharp = function (input, options) {
|
||||
withoutEnlargement: false,
|
||||
kernel: 'lanczos3',
|
||||
interpolator: 'bicubic',
|
||||
centreSampling: false,
|
||||
// operations
|
||||
background: [0, 0, 0, 255],
|
||||
flatten: false,
|
||||
|
||||
@@ -115,14 +115,14 @@ const jpeg = function jpeg (options) {
|
||||
throw new Error('Invalid chromaSubsampling (4:2:0, 4:4:4) ' + options.chromaSubsampling);
|
||||
}
|
||||
}
|
||||
options.trellisQuantisation = options.trellisQuantisation || options.trellisQuantization;
|
||||
options.trellisQuantisation = is.bool(options.trellisQuantization) ? options.trellisQuantization : options.trellisQuantisation;
|
||||
if (is.defined(options.trellisQuantisation)) {
|
||||
this._setBooleanOption('jpegTrellisQuantisation', options.trellisQuantisation);
|
||||
}
|
||||
if (is.defined(options.overshootDeringing)) {
|
||||
this._setBooleanOption('jpegOvershootDeringing', options.overshootDeringing);
|
||||
}
|
||||
options.optimiseScans = is.bool(options.optimiseScans) ? options.optimiseScans : options.optimizeScans;
|
||||
options.optimiseScans = is.bool(options.optimizeScans) ? options.optimizeScans : options.optimiseScans;
|
||||
if (is.defined(options.optimiseScans)) {
|
||||
this._setBooleanOption('jpegOptimiseScans', options.optimiseScans);
|
||||
if (options.optimiseScans) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user