mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Doc refresh, changelog and dead code removal for #977
This commit is contained in:
@@ -42,52 +42,27 @@ const kernel = {
|
||||
lanczos3: 'lanczos3'
|
||||
};
|
||||
|
||||
/**
|
||||
* Enlargement interpolators.
|
||||
* @member
|
||||
* @private
|
||||
*/
|
||||
const interpolator = {
|
||||
nearest: 'nearest',
|
||||
bilinear: 'bilinear',
|
||||
bicubic: 'bicubic',
|
||||
nohalo: 'nohalo',
|
||||
lbb: 'lbb',
|
||||
locallyBoundedBicubic: 'lbb',
|
||||
vsqbs: 'vsqbs',
|
||||
vertexSplitQuadraticBasisSpline: 'vsqbs'
|
||||
};
|
||||
|
||||
/**
|
||||
* Resize image to `width` x `height`.
|
||||
* By default, the resized image is centre cropped to the exact size specified.
|
||||
*
|
||||
* Possible reduction kernels are:
|
||||
* Possible kernels are:
|
||||
* - `nearest`: Use [nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation).
|
||||
* - `cubic`: Use a [Catmull-Rom spline](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).
|
||||
* - `lanczos2`: Use a [Lanczos kernel](https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel) with `a=2`.
|
||||
* - `lanczos3`: Use a Lanczos kernel with `a=3` (the default).
|
||||
*
|
||||
* Possible enlargement interpolators are:
|
||||
* - `nearest`: Use [nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation).
|
||||
* - `bilinear`: Use [bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation), faster than bicubic but with less smooth results.
|
||||
* - `vertexSplitQuadraticBasisSpline`: Use the smoother [VSQBS interpolation](https://github.com/jcupitt/libvips/blob/master/libvips/resample/vsqbs.cpp#L48) to prevent "staircasing" when enlarging.
|
||||
* - `bicubic`: Use [bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) (the default).
|
||||
* - `locallyBoundedBicubic`: Use [LBB interpolation](https://github.com/jcupitt/libvips/blob/master/libvips/resample/lbb.cpp#L100), which prevents some "[acutance](http://en.wikipedia.org/wiki/Acutance)" but typically reduces performance by a factor of 2.
|
||||
* - `nohalo`: Use [Nohalo interpolation](http://eprints.soton.ac.uk/268086/), which prevents acutance but typically reduces performance by a factor of 3.
|
||||
*
|
||||
* @example
|
||||
* sharp(inputBuffer)
|
||||
* .resize(200, 300, {
|
||||
* kernel: sharp.kernel.lanczos2,
|
||||
* interpolator: sharp.interpolator.nohalo
|
||||
* kernel: sharp.kernel.nearest
|
||||
* })
|
||||
* .background('white')
|
||||
* .embed()
|
||||
* .toFile('output.tiff')
|
||||
* .then(function() {
|
||||
* // output.tiff is a 200 pixels wide and 300 pixels high image
|
||||
* // containing a lanczos2/nohalo scaled version, embedded on a white canvas,
|
||||
* // containing a nearest-neighbour scaled version, embedded on a white canvas,
|
||||
* // of the image data in inputBuffer
|
||||
* });
|
||||
*
|
||||
@@ -95,7 +70,7 @@ const interpolator = {
|
||||
* @param {Number} [height] - pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.
|
||||
* @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.fastShrinkOnLoad=true] - take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moiré pattern on some images.
|
||||
* @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}
|
||||
@@ -129,20 +104,11 @@ function resize (width, height, options) {
|
||||
throw is.invalidParameterError('kernel', 'valid kernel name', options.kernel);
|
||||
}
|
||||
}
|
||||
// Interpolator
|
||||
if (is.defined(options.interpolator)) {
|
||||
if (is.string(interpolator[options.interpolator])) {
|
||||
this.options.interpolator = interpolator[options.interpolator];
|
||||
} else {
|
||||
throw is.invalidParameterError('interpolator', 'valid interpolator name', options.interpolator);
|
||||
}
|
||||
}
|
||||
// Centre sampling
|
||||
options.centreSampling = is.bool(options.centerSampling) ? options.centerSampling : options.centreSampling;
|
||||
if (is.defined(options.centreSampling)) {
|
||||
this._setBooleanOption('centreSampling', options.centreSampling);
|
||||
}
|
||||
|
||||
// Shrink on load
|
||||
if (is.defined(options.fastShrinkOnLoad)) {
|
||||
this._setBooleanOption('fastShrinkOnLoad', options.fastShrinkOnLoad);
|
||||
@@ -310,5 +276,4 @@ module.exports = function (Sharp) {
|
||||
Sharp.gravity = gravity;
|
||||
Sharp.strategy = strategy;
|
||||
Sharp.kernel = kernel;
|
||||
Sharp.interpolator = interpolator;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user