function _pipeline (callback) {
  if (typeof callback === 'function') {
    // output=file/buffer
    if (this._isStreamInput()) {
      // output=file/buffer, input=stream
      this.on('finish', () => {
        this._flattenBufferIn();
        sharp.pipeline(this.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
      this.once('finish', () => {
        this._flattenBufferIn();
        sharp.pipeline(this.options, (err, data, info) => {
          if (err) {
            this.emit('error', err);
          } else {
            this.emit('info', info);
            this.push(data);
          }
          this.push(null);
          this.emit('close');
        });
      });
      if (this.streamInFinished) {
        this.emit('finish');
      }
    } else {
      // output=stream, input=file/buffer
      sharp.pipeline(this.options, (err, data, info) => {
        if (err) {
          this.emit('error', err);
        } else {
          this.emit('info', info);
          this.push(data);
        }
        this.push(null);
        this.emit('close');
      });
    }
    return this;
  } else {
    // output=promise
    if (this._isStreamInput()) {
      // output=promise, input=stream
      return new Promise((resolve, reject) => {
        this.once('finish', () => {
          this._flattenBufferIn();
          sharp.pipeline(this.options, (err, data, info) => {
            if (err) {
              reject(err);
            } else {
              if (this.options.resolveWithObject) {
                resolve({ data, info });
              } else {
                resolve(data);
              }
            }
          });
        });
      });
    } else {
      // output=promise, input=file/buffer
      return new Promise((resolve, reject) => {
        sharp.pipeline(this.options, (err, data, info) => {
          if (err) {
            reject(err);
          } else {
            if (this.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
@private
Invoke the C ++ image processing pipeline Supports callback stream and promise variants @private
function _pipeline (callback) {
  if (typeof callback === 'function') {
    if (this._isStreamInput()) {
      , input=stream
      this.on('finish', () => {
        this._flattenBufferIn();
        sharp.pipeline(this.options, callback);
      });
    } else {
      , input=file/buffer
      sharp.pipeline(this.options, callback);
    }
    return this;
  } else if (this.options.streamOut) {
    if (this._isStreamInput()) {
      , input=stream
      this.once('finish', () => {
        this._flattenBufferIn();
        sharp.pipeline(this.options, (err, data, info) => {
          if (err) {
            this.emit('error', err);
          } else {
            this.emit('info', info);
            this.push(data);
          }
          this.push(null);
          this.emit('close');
        });
      });
      if (this.streamInFinished) {
        this.emit('finish');
      }
    } else {
      , input=file/buffer
      sharp.pipeline(this.options, (err, data, info) => {
        if (err) {
          this.emit('error', err);
        } else {
          this.emit('info', info);
          this.push(data);
        }
        this.push(null);
        this.emit('close');
      });
    }
    return this;
  } else {
    if (this._isStreamInput()) {
      , input=stream
      return new Promise((resolve, reject) => {
        this.once('finish', () => {
          this._flattenBufferIn();
          sharp.pipeline(this.options, (err, data, info) => {
            if (err) {
              reject(err);
            } else {
              if (this.options.resolveWithObject) {
                resolve({ data, info });
              } else {
                resolve(data);
              }
            }
          });
        });
      });
    } else {
      , input=file/buffer
      return new Promise((resolve, reject) => {
        sharp.pipeline(this.options, (err, data, info) => {
          if (err) {
            reject(err);
          } else {
            if (this.options.resolveWithObject) {
              resolve({ data: data, info: info });
            } else {
              resolve(data);
            }
          }
        });
      });
    }
  }
}
function _pipeline ( callback ) { if ( typeof callback === 'function' ) { if ( this . _isStreamInput ( ) ) { this . on ( 'finish' , ( ) => { this . _flattenBufferIn ( ) ; sharp . pipeline ( this . options , callback ) ; } ) ; } else { sharp . pipeline ( this . options , callback ) ; } return this ; } else if ( this . options . streamOut ) { if ( this . _isStreamInput ( ) ) { this . once ( 'finish' , ( ) => { this . _flattenBufferIn ( ) ; sharp . pipeline ( this . options , ( err , data , info ) => { if ( err ) { this . emit ( 'error' , err ) ; } else { this . emit ( 'info' , info ) ; this . push ( data ) ; } this . push ( null ) ; this . emit ( 'close' ) ; } ) ; } ) ; if ( this . streamInFinished ) { this . emit ( 'finish' ) ; } } else { sharp . pipeline ( this . options , ( err , data , info ) => { if ( err ) { this . emit ( 'error' , err ) ; } else { this . emit ( 'info' , info ) ; this . push ( data ) ; } this . push ( null ) ; this . emit ( 'close' ) ; } ) ; } return this ; } else { if ( this . _isStreamInput ( ) ) { return new Promise ( ( resolve , reject ) => { this . once ( 'finish' , ( ) => { this . _flattenBufferIn ( ) ; sharp . pipeline ( this . options , ( err , data , info ) => { if ( err ) { reject ( err ) ; } else { if ( this . options . resolveWithObject ) { resolve ( { data , info } ) ; } else { resolve ( data ) ; } } } ) ; } ) ; } ) ; } else { return new Promise ( ( resolve , reject ) => { sharp . pipeline ( this . options , ( err , data , info ) => { if ( err ) { reject ( err ) ; } else { if ( this . 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 @private
// output=file/buffer // output=file/buffer, input=stream // output=file/buffer, input=file/buffer // output=stream // output=stream, input=stream // output=stream, input=file/buffer // output=promise // output=promise, input=stream // output=promise, input=file/buffer