mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Nest format-specific constructor params (deprecate at top-level)
- `subifd` -> `tiff.subifd` - `level` -> `openSlide.level` - `pdfBackground` -> `pdf.background`
This commit is contained in:
39
lib/input.js
39
lib/input.js
@@ -230,32 +230,49 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
throw is.invalidParameterError('page', 'integer between 0 and 100000', inputOptions.page);
|
||||
}
|
||||
}
|
||||
// Multi-level input (OpenSlide)
|
||||
if (is.defined(inputOptions.level)) {
|
||||
// OpenSlide specific options
|
||||
if (is.object(inputOptions.openSlide) && is.defined(inputOptions.openSlide.level)) {
|
||||
if (is.integer(inputOptions.openSlide.level) && is.inRange(inputOptions.openSlide.level, 0, 256)) {
|
||||
inputDescriptor.level = inputOptions.openSlide.level;
|
||||
} else {
|
||||
throw is.invalidParameterError('openSlide.level', 'integer between 0 and 256', inputOptions.openSlide.level);
|
||||
}
|
||||
} else if (is.defined(inputOptions.level)) {
|
||||
// Deprecated
|
||||
if (is.integer(inputOptions.level) && is.inRange(inputOptions.level, 0, 256)) {
|
||||
inputDescriptor.level = inputOptions.level;
|
||||
} else {
|
||||
throw is.invalidParameterError('level', 'integer between 0 and 256', inputOptions.level);
|
||||
}
|
||||
}
|
||||
// Sub Image File Directory (TIFF)
|
||||
if (is.defined(inputOptions.subifd)) {
|
||||
// TIFF specific options
|
||||
if (is.object(inputOptions.tiff) && is.defined(inputOptions.tiff.subifd)) {
|
||||
if (is.integer(inputOptions.tiff.subifd) && is.inRange(inputOptions.tiff.subifd, -1, 100000)) {
|
||||
inputDescriptor.subifd = inputOptions.tiff.subifd;
|
||||
} else {
|
||||
throw is.invalidParameterError('tiff.subifd', 'integer between -1 and 100000', inputOptions.tiff.subifd);
|
||||
}
|
||||
} else if (is.defined(inputOptions.subifd)) {
|
||||
// Deprecated
|
||||
if (is.integer(inputOptions.subifd) && is.inRange(inputOptions.subifd, -1, 100000)) {
|
||||
inputDescriptor.subifd = inputOptions.subifd;
|
||||
} else {
|
||||
throw is.invalidParameterError('subifd', 'integer between -1 and 100000', inputOptions.subifd);
|
||||
}
|
||||
}
|
||||
// PDF background colour
|
||||
if (is.defined(inputOptions.pdfBackground)) {
|
||||
// PDF specific options
|
||||
if (is.object(inputOptions.pdf) && is.defined(inputOptions.pdf.background)) {
|
||||
inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdf.background);
|
||||
} else if (is.defined(inputOptions.pdfBackground)) {
|
||||
// Deprecated
|
||||
inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdfBackground);
|
||||
}
|
||||
// JP2 oneshot
|
||||
if (is.defined(inputOptions.jp2Oneshot)) {
|
||||
if (is.bool(inputOptions.jp2Oneshot)) {
|
||||
inputDescriptor.jp2Oneshot = inputOptions.jp2Oneshot;
|
||||
// JPEG 2000 specific options
|
||||
if (is.object(inputOptions.jp2) && is.defined(inputOptions.jp2.oneshot)) {
|
||||
if (is.bool(inputOptions.jp2.oneshot)) {
|
||||
inputDescriptor.jp2Oneshot = inputOptions.jp2.oneshot;
|
||||
} else {
|
||||
throw is.invalidParameterError('jp2Oneshot', 'boolean', inputOptions.jp2Oneshot);
|
||||
throw is.invalidParameterError('jp2.oneshot', 'boolean', inputOptions.jp2.oneshot);
|
||||
}
|
||||
}
|
||||
// Create new image
|
||||
|
||||
Reference in New Issue
Block a user