4.12.3 • Published 11 months ago

42-antd-img-crop v4.12.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

antd-img-crop

An image cropper for Ant Design Upload

npm npm npm bundle size GitHub npm type definitions

English | 简体中文

Install

pnpm add antd-img-crop
# or
yarn add antd-img-crop
# or
npm i antd-img-crop

Usage

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

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

Edit antd-img-crop

Props

PropTypeDefaultDescription
qualitynumber0.4Cropped image quality, 0 to 1
fillColorstring'white'Fill color for cropped image
zoomSliderbooleantrueEnable zoom adjustment
rotationSliderbooleanfalseEnable rotation adjustment
aspectSliderbooleanfalseEnable aspect adjustment
showResetbooleanfalseShow reset button to reset zoom rotation aspect
resetTextstringResetReset button text
aspectnumber1 / 1Aspect of crop area , width / height
minZoomnumber1Minimum zoom factor
maxZoomnumber3Maximum zoom factor
cropShapestring'rect'Shape of crop area, 'rect' or 'round'
showGridbooleanfalseShow grid of crop area (third-lines)
cropperPropsobject-react-easy-crop props (* existing props cannot be overridden)
modalClassNamestring''Modal classname
modalTitlestring'Edit image'Modal title
modalWidthnumberstringModal width
modalOkstringOk button text
modalCancelstringCancel button text
onModalOkfunction-Ok button callback
onModalCancelfunction-Cancel button, modal mask, top right "x" callback
modalPropsobjectAnt Design Modal props (* existing props cannot be overridden)
beforeCropfunction-Upload button callback, if return false or reject, modal will not open

FAQ

ConfigProvider not work?

Try to set libraryDirectory('es' or 'lib') to babel-plugin-import config, see which one will work.

module.exports = {
  plugins: [
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
};

No style? (only antd<=v4)

If you use antd<=v4 + babel-plugin-import, and no Modal or Slider were imported, please import these styles manually:

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

License

MIT License (c) nanxiaobei

FUTAKE

Try FUTAKE in WeChat. A mini app for your inspiration moments. 🌈

npm.io