diff --git a/docs/changelog.md b/docs/changelog.md index 3e9f41db..5353abc7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -9,7 +9,10 @@ Requires libvips v8.8.0. * Remove `overlayWith` previously deprecated in v0.22.0. * Drop support for Node.js versions 6 and 11. - [#1212](https://github.com/lovell/sharp/issues/1674) + [#1674](https://github.com/lovell/sharp/issues/1674) + +* Allow use of failOnError option with Stream-based input. + [#1691](https://github.com/lovell/sharp/issues/1691) ### v0.22 - "*uptake*" diff --git a/lib/input.js b/lib/input.js index 7a7e2982..a94ff029 100644 --- a/lib/input.js +++ b/lib/input.js @@ -19,7 +19,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) { } else if (is.plainObject(input) && !is.defined(inputOptions)) { // Plain Object descriptor, e.g. create inputOptions = input; - if (is.plainObject(inputOptions.raw)) { + if (is.plainObject(inputOptions.raw) || is.bool(inputOptions.failOnError)) { // Raw Stream inputDescriptor.buffer = []; } diff --git a/test/unit/failOnError.js b/test/unit/failOnError.js index c30afc94..c2ce2141 100644 --- a/test/unit/failOnError.js +++ b/test/unit/failOnError.js @@ -1,6 +1,7 @@ 'use strict'; const assert = require('assert'); +const fs = require('fs'); const sharp = require('../../'); const fixtures = require('../fixtures'); @@ -72,4 +73,10 @@ describe('failOnError', function () { done(err.message.includes('VipsJpeg: Premature end of JPEG file') ? undefined : err); }); }); + + it('handles stream-based input', function () { + const writable = sharp({ failOnError: false }); + fs.createReadStream(fixtures.inputJpgTruncated).pipe(writable); + return writable.toBuffer(); + }); });