0.0.7 • Published 3 years ago

@astvision/antd-img-crop v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

antd-img-crop

An image cropper for Ant Design Upload.

npm npm npm bundle size GitHub

English | 简体中文

Demo

Live demo

Install

yarn add antd-img-crop

Usage

import ImgCrop from 'antd-img-crop';
import { Upload } from 'antd';

const Demo = () => (
  <ImgCrop>
    <Upload>+ Add image</Upload>
  </ImgCrop>
);

Props

PropTypeDefaultDescription
aspectnumber1 / 1Aspect of crop area , width / height
shapestring'rect'Shape of crop area, 'rect' or 'round'
gridbooleanfalseShow grid of crop area (third-lines)
qualitynumber0.4Image quality, 0 ~ 1
fillColorstringwhiteFill color when cropped image smaller than canvas
zoombooleantrueEnable zoom for image
rotatebooleanfalseEnable rotate for image
minZoomnumber1Minimum zoom factor
maxZoomnumber3Maximum zoom factor
modalTitlestring'Edit image'Title of modal
modalWidthnumber | string520Width of modal in pixels number or percentages
modalOkstring'OK'Text of confirm button of modal
modalCancelstring'Cancel'Text of cancel button of modal
beforeCropfunction-Call before modal open, if return false, it'll not open
cropperPropsobject-Props of react-easy-crop (* existing props cannot be overridden)

Styles

To prevent overwriting the custom styles to antd, antd-img-crop does not import the style files of components.

Therefore, if your project configured babel-plugin-import, and not use Modal or Slider, you need to import the styles yourself:

import 'antd/es/modal/style';
import 'antd/es/slider/style';

License

MIT License (c) nanxiaobei