New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rc-cropper

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-cropper

Cropper as React components

latest
Source
npmnpm
Version
1.3.1
Version published
Weekly downloads
13
550%
Maintainers
1
Weekly downloads
 
Created
Source

rc-cropper

An react component wrapping the Cropperjs.

Cropperjs Docs

  • Image Cropper

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

Keywords

react

FAQs

Package last updated on 27 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts