mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Base maximum output dimensions on limitation of format
This commit is contained in:
12
lib/input.js
12
lib/input.js
@@ -35,8 +35,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
if (is.defined(inputOptions.raw)) {
|
||||
if (
|
||||
is.object(inputOptions.raw) &&
|
||||
is.integer(inputOptions.raw.width) && is.inRange(inputOptions.raw.width, 1, this.constructor.maximum.width) &&
|
||||
is.integer(inputOptions.raw.height) && is.inRange(inputOptions.raw.height, 1, this.constructor.maximum.height) &&
|
||||
is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 &&
|
||||
is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 &&
|
||||
is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4)
|
||||
) {
|
||||
inputDescriptor.rawWidth = inputOptions.raw.width;
|
||||
@@ -50,8 +50,8 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
if (is.defined(inputOptions.create)) {
|
||||
if (
|
||||
is.object(inputOptions.create) &&
|
||||
is.integer(inputOptions.create.width) && is.inRange(inputOptions.create.width, 1, this.constructor.maximum.width) &&
|
||||
is.integer(inputOptions.create.height) && is.inRange(inputOptions.create.height, 1, this.constructor.maximum.height) &&
|
||||
is.integer(inputOptions.create.width) && inputOptions.create.width > 0 &&
|
||||
is.integer(inputOptions.create.height) && inputOptions.create.height > 0 &&
|
||||
is.integer(inputOptions.create.channels) && is.inRange(inputOptions.create.channels, 3, 4) &&
|
||||
is.defined(inputOptions.create.background)
|
||||
) {
|
||||
@@ -239,12 +239,12 @@ function limitInputPixels (limit) {
|
||||
if (limit === false) {
|
||||
limit = 0;
|
||||
} else if (limit === true) {
|
||||
limit = this.constructor.maximum.pixels;
|
||||
limit = Math.pow(0x3FFF, 2);
|
||||
}
|
||||
if (is.integer(limit) && limit >= 0) {
|
||||
this.options.limitInputPixels = limit;
|
||||
} else {
|
||||
throw new Error('Invalid pixel limit (0 to ' + this.constructor.maximum.pixels + ') ' + limit);
|
||||
throw is.invalidParameterError('limitInputPixels', 'integer', limit);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user