1.3.1 • Published 7 years ago

rc-cropper v1.3.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

rc-cropper

An react component wrapping the Cropperjs.

Cropperjs Docs

Installation

Install via npm

npm install --save rc-cropper

Example

Inspired by react-cropper

import React, {Component} from 'react'
import Cropper from 'rc-cropper'
class Demo extends Component {
  crop(){
    const canvas = this.refs.cropper.getCroppedCanvas()
    const url = canvas.toDataURL() // image url
    const blob = canvas.toBlob(blob => {
      // upload the blob or do anything else
    })
  }

  render() {
    const options = {
      aspectRatio: 16 / 9
    }
    return (
      <Cropper
        ref='cropper'
        src='http://fengyuanchen.github.io/cropper/images/picture.jpg'
        options={options} />
    )
  }
}

Props

nametypedefaultdescription
srcstringimage src
classNamestringcustom class name
localeobjectfor i18n
zoomStepnumber0.2zoom step
moveStepnumber2pxmove step
rotateStepnumber45degrotate step
onReadyfunctioncallback when the cropper is ready
showActionsboolfalsewhether show action buttons, support zoom/move/rotate
outputImgSizeobjectspecify the output canvas size, format: {width: , height: }
containerSizeLimitobject{ maxWidth: 500, maxHeight: 500, minWidth: 50, minHeight: 50}the size limitation of image container
cropBoxEditablebooltrueWhether the cropbox width and height can edit by input. If outputImgSize is set, this property would be invaild
optionsobjectoptions for cropperjs

Note:

  • If outputImgSize is specified and no aspectRatio specified in options, rc-cropper will caculate the aspectRatio based on outputImgSize automatically. aspectRation = outputImgSize.width / outputImgSize.height
1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago