mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Detect empty input and throw a helpful error (#2687)
This commit is contained in:
@@ -30,9 +30,15 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
inputDescriptor.file = input;
|
||||
} else if (is.buffer(input)) {
|
||||
// Buffer
|
||||
if (input.length === 0) {
|
||||
throw Error('Input Buffer is empty');
|
||||
}
|
||||
inputDescriptor.buffer = input;
|
||||
} else if (is.uint8Array(input)) {
|
||||
// Uint8Array or Uint8ClampedArray
|
||||
if (input.length === 0) {
|
||||
throw Error('Input Bit Array is empty');
|
||||
}
|
||||
inputDescriptor.buffer = Buffer.from(input.buffer);
|
||||
} else if (is.plainObject(input) && !is.defined(inputOptions)) {
|
||||
// Plain Object descriptor, e.g. create
|
||||
|
||||
Reference in New Issue
Block a user