1.0.0 • Published 8 years ago

@f/crop-image v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

crop-image

Build status Git tag NPM version Code style

Crop an image using the browser's canvas element

Installation

$ npm install @f/crop-image

Usage

var cropImage = require('@f/crop-image')

function cropAndUpload (img, x, y, width, height) {
  const blob = cropImage(img, x, y, width, height)
  return upload(blob)
}

API

cropImage(arg)

  • img an <img> element
  • x the distance along the x axis to begin cropping
  • y the distance along the y axis to begin cropping
  • width the width of the section you want to crop
  • height the height of the section you want to crop
  • scaleWidth scale the final image up/down to this width (optional - defaults to width)
  • scaleHeight scale the final image up/down to this height (optional - defaults to height)

Returns: A blob containing the cropped image data

License

MIT