mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Remove functions previously deprecated in v0.21.0
background, crop, embed, ignoreAspectRatio, max, min, withoutEnlargement
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const deprecate = require('util').deprecate;
|
||||
const is = require('./is');
|
||||
|
||||
/**
|
||||
@@ -378,92 +377,6 @@ function trim (threshold) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Deprecated functions
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function crop (crop) {
|
||||
this.options.canvas = 'crop';
|
||||
if (!is.defined(crop)) {
|
||||
// Default
|
||||
this.options.position = gravity.center;
|
||||
} else if (is.integer(crop) && is.inRange(crop, 0, 8)) {
|
||||
// Gravity (numeric)
|
||||
this.options.position = crop;
|
||||
} else if (is.string(crop) && is.integer(gravity[crop])) {
|
||||
// Gravity (string)
|
||||
this.options.position = gravity[crop];
|
||||
} else if (is.integer(crop) && crop >= strategy.entropy) {
|
||||
// Strategy
|
||||
this.options.position = crop;
|
||||
} else if (is.string(crop) && is.integer(strategy[crop])) {
|
||||
// Strategy (string)
|
||||
this.options.position = strategy[crop];
|
||||
} else {
|
||||
throw is.invalidParameterError('crop', 'valid crop id/name/strategy', crop);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function embed (embed) {
|
||||
this.options.canvas = 'embed';
|
||||
if (!is.defined(embed)) {
|
||||
// Default
|
||||
this.options.position = gravity.center;
|
||||
} else if (is.integer(embed) && is.inRange(embed, 0, 8)) {
|
||||
// Gravity (numeric)
|
||||
this.options.position = embed;
|
||||
} else if (is.string(embed) && is.integer(gravity[embed])) {
|
||||
// Gravity (string)
|
||||
this.options.position = gravity[embed];
|
||||
} else {
|
||||
throw is.invalidParameterError('embed', 'valid embed id/name', embed);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function max () {
|
||||
this.options.canvas = 'max';
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function min () {
|
||||
this.options.canvas = 'min';
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function ignoreAspectRatio () {
|
||||
this.options.canvas = 'ignore_aspect';
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
*/
|
||||
function withoutEnlargement (withoutEnlargement) {
|
||||
this.options.withoutEnlargement = is.bool(withoutEnlargement) ? withoutEnlargement : true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate the Sharp prototype with resize-related functions.
|
||||
* @private
|
||||
@@ -481,11 +394,4 @@ module.exports = function (Sharp) {
|
||||
Sharp.kernel = kernel;
|
||||
Sharp.fit = fit;
|
||||
Sharp.position = position;
|
||||
// Deprecated functions, to be removed in v0.22.0
|
||||
Sharp.prototype.crop = deprecate(crop, 'crop(position) is deprecated, use resize({ fit: "cover", position }) instead');
|
||||
Sharp.prototype.embed = deprecate(embed, 'embed(position) is deprecated, use resize({ fit: "contain", position }) instead');
|
||||
Sharp.prototype.max = deprecate(max, 'max() is deprecated, use resize({ fit: "inside" }) instead');
|
||||
Sharp.prototype.min = deprecate(min, 'min() is deprecated, use resize({ fit: "outside" }) instead');
|
||||
Sharp.prototype.ignoreAspectRatio = deprecate(ignoreAspectRatio, 'ignoreAspectRatio() is deprecated, use resize({ fit: "fill" }) instead');
|
||||
Sharp.prototype.withoutEnlargement = deprecate(withoutEnlargement, 'withoutEnlargement() is deprecated, use resize({ withoutEnlargement: true }) instead');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user