npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

antd-image-crop-upload

v1.0.10

Published

antd & image-crop 的结合

Downloads

10

Readme

AntdImageCropUpload

  • 结合了 antd 的 Upload 组件和 react-image-crop
    <!--使用方式和antd的Upload一致,仅在上传时增加图片的裁剪功能-->
    <AntdImageCropUpload> add </AntdImageCropUpload>

  • 入参在Upload的基础上增加了一些
export interface AntdImageCropUploadProps extends UploadProps {
  /** 裁剪前校验文件, 返回 false 则停止裁剪,不上传 */
  beforeCrop?: (file: RcFile, FileList: RcFile[]) => boolean;

  /** 裁剪框的初始参数 aspect: 是否固定裁剪框的比例 */
  initCrop?: {
    x: number; // 裁剪框坐标点
    y: number; 
    width?: number; // 裁剪框的大小 - (单位:%)
    height?: number;
    aspect?: number; // 宽高的比例 w / h (例如:320 / 280 )
  }
  
  /** 
   * 裁剪后的图片的物理宽高设置
   * 如果不设置则按原始尺寸的比例获取
   * 如果设置则裁剪后的图片将被拉伸为设置值
   * 注意,initCropp.aspect 会以targetImage设置的 w/h 为准
   */
  targetImage?: {
    width: number;
    height: number;
  }

  /** 
   * 是否只允许上传图片格式的文件
   * 默认为true,即只接受图片文件
   * 为false 时, 文件不经过裁剪,直接使用Upload的默认上传
   */
  imageOnly: boolean;

  /** 
   * 裁剪弹窗的props
   * props 中:visible, onOk, onCancel,okButtonProps 将受到控制
   */
  modalProps?: ModalProps;
}

注意!!!

  • 组件不支持自定义上传!

如果 beforeUpload 返回 false,其效果跟返回 Promise.reject() 是一样的

  • 允许裁剪的图片-只有符合的才能接受裁剪

const ImageTypeReg = /.(jpg|jpeg|png|gif)$/i;

  • 只允许一个一个文件上传