@f/crop-image
v1.0.0
Published
Crop an image using the browser's canvas element
Downloads
7
Readme
crop-image
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>
elementx
the distance along the x axis to begin croppingy
the distance along the y axis to begin croppingwidth
the width of the section you want to cropheight
the height of the section you want to cropscaleWidth
scale the final image up/down to this width (optional - defaults towidth
)scaleHeight
scale the final image up/down to this height (optional - defaults toheight
)
Returns: A blob containing the cropped image data
License
MIT