Class: Cropper

Cropper

Class for cropping an image.

Constructor

new Cropper(options)

Creates a Cropper instance with parameters passed as an object.

Available parameters are:

  • size {object} (required): the dimensions of the cropped, resized image. Must have 'width' and 'height' fields.
  • limit {integer}: the longest side that the cropping area will be limited to, resizing any larger images.
  • canvas {HTMLElement} (required): the cropping canvas element. Instantiation fails if not provided.
  • preview {HTMLElement} (required): the preview canvas element. Instantiation fails if not provided.
  • drawCrop {function} (optional): a function for drawing the cropping area given the canvas context and crop object.
drawCrop has the following prototype: drawCrop({canvas context}, {crop object}). The crop object has the form:

crop = {
  size: { x: Number, y: Number },
  pos: { x: Number, y: Number },
  handleSize: Number
}
Parameters:
Name Type Description
options object the parameters to be passed for instantiation
Source:

Methods

export(img)

Export the result to a given image tag.
Parameters:
Name Type Description
img HTMLElement the image tag to export the result to.
Source:

setImageSource(source)

Set the source image data for the cropper and get it running.
Parameters:
Name Type Description
source String the source of the image to crop.
Source:

Documentation generated by JSDoc 3.4.0 on Thu Jun 16 2016 10:32:28 GMT+0200 (CEST)