mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add failOnError option to fail-fast on bad input image data (#976)
This commit is contained in:
committed by
Lovell Fuller
parent
382d476271
commit
b4d72bd544
10
lib/input.js
10
lib/input.js
@@ -9,7 +9,7 @@ const sharp = require('../build/Release/sharp.node');
|
||||
* @private
|
||||
*/
|
||||
function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
const inputDescriptor = {};
|
||||
const inputDescriptor = { failOnError: false };
|
||||
if (is.string(input)) {
|
||||
// filesystem
|
||||
inputDescriptor.file = input;
|
||||
@@ -26,6 +26,14 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
throw new Error('Unsupported input ' + typeof input);
|
||||
}
|
||||
if (is.object(inputOptions)) {
|
||||
// Fail on error
|
||||
if (is.defined(inputOptions.failOnError)) {
|
||||
if (is.bool(inputOptions.failOnError)) {
|
||||
inputDescriptor.failOnError = inputOptions.failOnError;
|
||||
} else {
|
||||
throw new Error('Invalid failOnError (boolean) ' + inputOptions.failOnError);
|
||||
}
|
||||
}
|
||||
// Density
|
||||
if (is.defined(inputOptions.density)) {
|
||||
if (is.integer(inputOptions.density) && is.inRange(inputOptions.density, 1, 2400)) {
|
||||
|
||||
Reference in New Issue
Block a user