mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Base maximum output dimensions on limitation of format
This commit is contained in:
@@ -91,8 +91,8 @@ const interpolator = {
|
||||
* // of the image data in inputBuffer
|
||||
* });
|
||||
*
|
||||
* @param {Number} [width] - pixels wide the resultant image should be, between 1 and 16383 (0x3FFF). Use `null` or `undefined` to auto-scale the width to match the height.
|
||||
* @param {Number} [height] - pixels high the resultant image should be, between 1 and 16383. Use `null` or `undefined` to auto-scale the height to match the width.
|
||||
* @param {Number} [width] - pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.
|
||||
* @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.
|
||||
@@ -103,19 +103,19 @@ const interpolator = {
|
||||
*/
|
||||
function resize (width, height, options) {
|
||||
if (is.defined(width)) {
|
||||
if (is.integer(width) && is.inRange(width, 1, this.constructor.maximum.width)) {
|
||||
if (is.integer(width) && width > 0) {
|
||||
this.options.width = width;
|
||||
} else {
|
||||
throw is.invalidParameterError('width', `integer between 1 and ${this.constructor.maximum.width}`, width);
|
||||
throw is.invalidParameterError('width', 'positive integer', width);
|
||||
}
|
||||
} else {
|
||||
this.options.width = -1;
|
||||
}
|
||||
if (is.defined(height)) {
|
||||
if (is.integer(height) && is.inRange(height, 1, this.constructor.maximum.height)) {
|
||||
if (is.integer(height) && height > 0) {
|
||||
this.options.height = height;
|
||||
} else {
|
||||
throw is.invalidParameterError('height', `integer between 1 and ${this.constructor.maximum.height}`, height);
|
||||
throw is.invalidParameterError('height', 'positive integer', height);
|
||||
}
|
||||
} else {
|
||||
this.options.height = -1;
|
||||
|
||||
Reference in New Issue
Block a user