react image crop
I have barely no time work on improve this project, needs collaborators for project maintenance.
A React.JS Image Cropper
Touch supported
Custom:
import {Cropper} from 'react-image-cropper'
styles are all inline
define Cropper with src, and ref to execute crop method
<Croppersrc="http://braavos.me/images/posts/college-rock/the-smiths.png"ref={ ref => { this.cropper = ref }}/>
image.src = this.cropper.crop()
const values = this.cropper.values()
values:
{// display valuesdisplay: {width, // frame widthheight, // frame heightx, // original x positiony, // original y positionimgWidth, // img widthimgHeight, // img height},// original valuesoriginal: {width, // frame widthheight, // frame heightx, // original x positiony, // original y positionimgWidth, // img widthimgHeight, // img height}}
(values) => onChange(values)
| prop | value |
|---|---|
| ratio | width / height |
| width | cropper frame width |
| height | cropper frame height |
| originX | cropper original position(x axis), accroding to image left |
| originY | cropper original position(Y axis), accroding to image top |
| fixedRatio | turn on/off fixed ratio (bool default true) |
| allowNewSelection | allow user to create a new selection instead of reusing initial selection (bool default true) |
| styles | specify styles to override inline styles |
| onImgLoad | specify fuction callback to run when the image completed loading |
| beforeImgload | specify function callback to run when the image size value is ready but image is not completed loading |
| onChange | triggred when dragging stop, get values of cropper |