function extend (extend) {
  if (is.integer(extend) && extend > 0) {
    this.options.extendTop = extend;
    this.options.extendBottom = extend;
    this.options.extendLeft = extend;
    this.options.extendRight = extend;
  } else if (
    is.object(extend) &&
    is.integer(extend.top) && extend.top >= 0 &&
    is.integer(extend.bottom) && extend.bottom >= 0 &&
    is.integer(extend.left) && extend.left >= 0 &&
    is.integer(extend.right) && extend.right >= 0
  ) {
    this.options.extendTop = extend.top;
    this.options.extendBottom = extend.bottom;
    this.options.extendLeft = extend.left;
    this.options.extendRight = extend.right;
    this._setColourOption('extendBackground', extend.background);
  } else {
    throw new Error('Invalid edge extension ' + extend);
  }
  return this;
}
function extend (extend) {
  if (is.integer(extend) && extend > 0) {
    this.options.extendTop = extend;
    this.options.extendBottom = extend;
    this.options.extendLeft = extend;
    this.options.extendRight = extend;
  } else if (
    is.object(extend) &&
    is.integer(extend.top) && extend.top >= 0 &&
    is.integer(extend.bottom) && extend.bottom >= 0 &&
    is.integer(extend.left) && extend.left >= 0 &&
    is.integer(extend.right) && extend.right >= 0
  ) {
    this.options.extendTop = extend.top;
    this.options.extendBottom = extend.bottom;
    this.options.extendLeft = extend.left;
    this.options.extendRight = extend.right;
    this._setColourOption('extendBackground', extend.background);
  } else {
    throw new Error('Invalid edge extension ' + extend);
  }
  return this;
}
function extend ( extend ) { if ( is . integer ( extend ) && extend > 0 ) { this . options . extendTop = extend ; this . options . extendBottom = extend ; this . options . extendLeft = extend ; this . options . extendRight = extend ; } else if ( is . object ( extend ) && is . integer ( extend . top ) && extend . top >= 0 && is . integer ( extend . bottom ) && extend . bottom >= 0 && is . integer ( extend . left ) && extend . left >= 0 && is . integer ( extend . right ) && extend . right >= 0 ) { this . options . extendTop = extend . top ; this . options . extendBottom = extend . bottom ; this . options . extendLeft = extend . left ; this . options . extendRight = extend . right ; this . _setColourOption ( 'extendBackground' , extend . background ) ; } else { throw new Error ( 'Invalid edge extension ' + extend ) ; } return this ; }
Extends/pads the edges of the image with the provided background colour.
This operation will always occur after resizing and extraction, if any.

@example
// Resize to 140 pixels wide, then add 10 transparent pixels
// to the top, left and right edges and 20 to the bottom edge
sharp(input)
.resize(140)
.extend({
top: 10,
bottom: 20,
left: 10,
right: 10,
background: { r: 0, g: 0, b: 0, alpha: 0 }
})
...

@param {(Number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts
@param {Number} [extend.top]
@param {Number} [extend.left]
@param {Number} [extend.bottom]
@param {Number} [extend.right]
@param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.
@returns {Sharp}
@throws {Error} Invalid parameters
Extends / pads the edges of the image with the provided background colour . This operation will always occur after resizing and extraction if any .
Extend the edge container