function _pipeline (callback) {
  const that = this;
  if (typeof callback === 'function') {
    // output=file/buffer
    if (this._isStreamInput()) {
      // output=file/buffer, input=stream
      this.on('finish', function () {
        that._flattenBufferIn();
        sharp.pipeline(that.options, callback);
      });
    } else {
      // output=file/buffer, input=file/buffer
      sharp.pipeline(this.options, callback);
    }
    return this;
  } else if (this.options.streamOut) {
    // output=stream
    if (this._isStreamInput()) {
      // output=stream, input=stream
      if (this.streamInFinished) {
        this._flattenBufferIn();
        sharp.pipeline(this.options, function (err, data, info) {
          if (err) {
            that.emit('error', err);
          } else {
            that.emit('info', info);
            that.push(data);
          }
          that.push(null);
        });
      } else {
        this.on('finish', function () {
          that._flattenBufferIn();
          sharp.pipeline(that.options, function (err, data, info) {
            if (err) {
              that.emit('error', err);
            } else {
              that.emit('info', info);
              that.push(data);
            }
            that.push(null);
          });
        });
      }
    } else {
      // output=stream, input=file/buffer
      sharp.pipeline(this.options, function (err, data, info) {
        if (err) {
          that.emit('error', err);
        } else {
          that.emit('info', info);
          that.push(data);
        }
        that.push(null);
      });
    }
    return this;
  } else {
    // output=promise
    if (this._isStreamInput()) {
      // output=promise, input=stream
      return new Promise(function (resolve, reject) {
        that.on('finish', function () {
          that._flattenBufferIn();
          sharp.pipeline(that.options, function (err, data, info) {
            if (err) {
              reject(err);
            } else {
              if (that.options.resolveWithObject) {
                resolve({ data: data, info: info });
              } else {
                resolve(data);
              }
            }
          });
        });
      });
    } else {
      // output=promise, input=file/buffer
      return new Promise(function (resolve, reject) {
        sharp.pipeline(that.options, function (err, data, info) {
          if (err) {
            reject(err);
          } else {
            if (that.options.resolveWithObject) {
              resolve({ data: data, info: info });
            } else {
              resolve(data);
            }
          }
        });
      });
    }
  }
}
function _pipeline (callback) {
  const that = this;
  if (typeof callback === 'function') {
    // output=file/buffer
    if (this._isStreamInput()) {
      // output=file/buffer, input=stream
      this.on('finish', function () {
        that._flattenBufferIn();
        sharp.pipeline(that.options, callback);
      });
    } else {
      // output=file/buffer, input=file/buffer
      sharp.pipeline(this.options, callback);
    }
    return this;
  } else if (this.options.streamOut) {
    // output=stream
    if (this._isStreamInput()) {
      // output=stream, input=stream
      if (this.streamInFinished) {
        this._flattenBufferIn();
        sharp.pipeline(this.options, function (err, data, info) {
          if (err) {
            that.emit('error', err);
          } else {
            that.emit('info', info);
            that.push(data);
          }
          that.push(null);
        });
      } else {
        this.on('finish', function () {
          that._flattenBufferIn();
          sharp.pipeline(that.options, function (err, data, info) {
            if (err) {
              that.emit('error', err);
            } else {
              that.emit('info', info);
              that.push(data);
            }
            that.push(null);
          });
        });
      }
    } else {
      // output=stream, input=file/buffer
      sharp.pipeline(this.options, function (err, data, info) {
        if (err) {
          that.emit('error', err);
        } else {
          that.emit('info', info);
          that.push(data);
        }
        that.push(null);
      });
    }
    return this;
  } else {
    // output=promise
    if (this._isStreamInput()) {
      // output=promise, input=stream
      return new Promise(function (resolve, reject) {
        that.on('finish', function () {
          that._flattenBufferIn();
          sharp.pipeline(that.options, function (err, data, info) {
            if (err) {
              reject(err);
            } else {
              if (that.options.resolveWithObject) {
                resolve({ data: data, info: info });
              } else {
                resolve(data);
              }
            }
          });
        });
      });
    } else {
      // output=promise, input=file/buffer
      return new Promise(function (resolve, reject) {
        sharp.pipeline(that.options, function (err, data, info) {
          if (err) {
            reject(err);
          } else {
            if (that.options.resolveWithObject) {
              resolve({ data: data, info: info });
            } else {
              resolve(data);
            }
          }
        });
      });
    }
  }
}
function _pipeline ( callback ) { const that = this ; if ( typeof callback === 'function' ) { // output=file/buffer if ( this . _isStreamInput ( ) ) { // output=file/buffer, input=stream this . on ( 'finish' , function ( ) { that . _flattenBufferIn ( ) ; sharp . pipeline ( that . options , callback ) ; } ) ; } else { // output=file/buffer, input=file/buffer sharp . pipeline ( this . options , callback ) ; } return this ; } else if ( this . options . streamOut ) { // output=stream if ( this . _isStreamInput ( ) ) { // output=stream, input=stream if ( this . streamInFinished ) { this . _flattenBufferIn ( ) ; sharp . pipeline ( this . options , function ( err , data , info ) { if ( err ) { that . emit ( 'error' , err ) ; } else { that . emit ( 'info' , info ) ; that . push ( data ) ; } that . push ( null ) ; } ) ; } else { this . on ( 'finish' , function ( ) { that . _flattenBufferIn ( ) ; sharp . pipeline ( that . options , function ( err , data , info ) { if ( err ) { that . emit ( 'error' , err ) ; } else { that . emit ( 'info' , info ) ; that . push ( data ) ; } that . push ( null ) ; } ) ; } ) ; } } else { // output=stream, input=file/buffer sharp . pipeline ( this . options , function ( err , data , info ) { if ( err ) { that . emit ( 'error' , err ) ; } else { that . emit ( 'info' , info ) ; that . push ( data ) ; } that . push ( null ) ; } ) ; } return this ; } else { // output=promise if ( this . _isStreamInput ( ) ) { // output=promise, input=stream return new Promise ( function ( resolve , reject ) { that . on ( 'finish' , function ( ) { that . _flattenBufferIn ( ) ; sharp . pipeline ( that . options , function ( err , data , info ) { if ( err ) { reject ( err ) ; } else { if ( that . options . resolveWithObject ) { resolve ( { data : data , info : info } ) ; } else { resolve ( data ) ; } } } ) ; } ) ; } ) ; } else { // output=promise, input=file/buffer return new Promise ( function ( resolve , reject ) { sharp . pipeline ( that . options , function ( err , data , info ) { if ( err ) { reject ( err ) ; } else { if ( that . options . resolveWithObject ) { resolve ( { data : data , info : info } ) ; } else { resolve ( data ) ; } } } ) ; } ) ; } } }
Invoke the C++ image processing pipeline
Supports callback, stream and promise variants
@private
Invoke the C ++ image processing pipeline Supports callback stream and promise variants
Pipes the image into a single file