lib/input.js
function clone () {
  const that = this;
  // Clone existing options
  const clone = this.constructor.call();
  clone.options = Object.assign({}, this.options);
  // Pass 'finish' event to clone for Stream-based input
  if (this._isStreamInput()) {
    this.on('finish', function () {
      // Clone inherits input data
      that._flattenBufferIn();
      clone.options.bufferIn = that.options.bufferIn;
      clone.emit('finish');
    });
  }
  return clone;
}
function clone () {
  const that = this;
  // Clone existing options
  const clone = this.constructor.call();
  clone.options = Object.assign({}, this.options);
  // Pass 'finish' event to clone for Stream-based input
  if (this._isStreamInput()) {
    this.on('finish', function () {
      // Clone inherits input data
      that._flattenBufferIn();
      clone.options.bufferIn = that.options.bufferIn;
      clone.emit('finish');
    });
  }
  return clone;
}
function clone ( ) { const that = this ; // Clone existing options const clone = this . constructor . call ( ) ; clone . options = Object . assign ( { } , this . options ) ; // Pass 'finish' event to clone for Stream-based input if ( this . _isStreamInput ( ) ) { this . on ( 'finish' , function ( ) { // Clone inherits input data that . _flattenBufferIn ( ) ; clone . options . bufferIn = that . options . bufferIn ; clone . emit ( 'finish' ) ; } ) ; } return clone ; }
Take a "snapshot" of the Sharp instance, returning a new instance.
Cloned instances inherit the input of their parent instance.
This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.

@example
const pipeline = sharp().rotate();
pipeline.clone().resize(800, 600).pipe(firstWritableStream);
pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);
readableStream.pipe(pipeline);
// firstWritableStream receives auto-rotated, resized readableStream
// secondWritableStream receives auto-rotated, extracted region of readableStream

@returns {Sharp}
Take a snapshot of the Sharp instance returning a new instance . Cloned instances inherit the input of their parent instance . This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream .