ランキングに戻る

react-cropper/react-cropper

TypeScriptreact-cropper.github.io/react-cropper/

Cropperjs as React component

croppercropperjsreact-cropperreact-componentsreactreactjscropcrop-image
スター成長
スター
2.1k
フォーク
272
週間成長
Issue
3
1k2k
2015年5月2019年1月2022年10月2026年7月
成果物npmnpm install react-cropper
README

react-cropper

Cropperjs as React component

NPM NPM NPM downloads Bundle Size minZip Bundle Size min License codecov

Demo

Click for a Demo

Docs

Installation

Install via npm

npm install --save react-cropper

You need cropper.css in your project which is from cropperjs. Since this project have dependency on cropperjs, it located in /node_modules/react-cropper/node_modules/cropperjs/dist/cropper.css or node_modules/cropperjs/dist/cropper.css for npm version 3.0.0 later

Quick Example

import React, { useRef } from "react";
import Cropper, { ReactCropperElement } from "react-cropper";
import "cropperjs/dist/cropper.css";

const Demo: React.FC = () => {
  const cropperRef = useRef<ReactCropperElement>(null);
  const onCrop = () => {
    const cropper = cropperRef.current?.cropper;
    console.log(cropper.getCroppedCanvas().toDataURL());
  };

  return (
    <Cropper
      src="https://raw.githubusercontent.com/roadmanfong/react-cropper/master/example/img/child.jpg"
      style={{ height: 400, width: "100%" }}
      // Cropper.js options
      initialAspectRatio={16 / 9}
      guides={false}
      crop={onCrop}
      ref={cropperRef}
    />
  );
};

Options

src

  • Type: string
  • Default: null
<Cropper src="http://fengyuanchen.github.io/cropper/images/picture.jpg" />

alt

  • Type: string
  • Default: picture

crossOrigin

  • Type: string
  • Default: null

dragMode

https://github.com/fengyuanchen/cropperjs#dragmode

scaleX

https://github.com/fengyuanchen/cropperjs#scalexscalex

scaleY

https://github.com/fengyuanchen/cropperjs#scalexscaley

enable

https://github.com/fengyuanchen/cropperjs#enable

disable

https://github.com/fengyuanchen/cropperjs#disable

zoomTo

https://github.com/fengyuanchen/cropperjs#zoomto

rotateTo

https://github.com/fengyuanchen/cropperjs#rotateto

Other options

Accept all options in the docs as properties.

Methods

Use the cropper instance from onInitialized to access cropperjs methods

Build

npm run build

Development

npm start

Author

Fong Kuanghuei

Maintainer

Shubhendu Shekhar

License

MIT

関連リポジトリ
fengyuanchen/cropperjs

JavaScript image cropper.

TypeScriptnpmMIT Licenseimage-cropperimage-processing
fengyuanchen.github.io/cropperjs/
13.9k2.4k
fengyuanchen/cropper

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-cropper

JavaScriptnpmMIT Licenseimage-cropperimage-processing
7.7k1.7k
ArthurHub/Android-Image-Cropper

Image Cropping Library for Android, optimized for Camera / Gallery.

JavaMavenApache License 2.0androidandroid-image-cropper
6.4k1.4k
TimOliver/TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects

Objective-CMIT Licensecropperimage
4.9k1k
xyxiao001/vue-cropper

A simple picture clipping plugin for vue

VueMIT Licensevuecropper
github.xyxiao.cn/vue-cropper/docs/vue3.html
4.6k707
ruslanskorb/RSKImageCropper

An image / photo crop view controller for iOS like in the Contacts app with support for landscape orientation.

Objective-CMIT Licensecropcropping
2.5k466
steelkiwi/cropiwa

📐 Configurable Custom Crop widget for Android

JavaMavencropcrop-image
steelkiwi.com
2.2k323
we-plugin/we-cropper

微信小程序图片裁剪工具

JavaScriptnpmMIT Licensecropperweapp
we-plugin.github.io/we-cropper/
2.2k446
CanHub/Android-Image-Cropper

Image Cropping Library for Android, optimised for Camera / Gallery.

KotlinApache License 2.0androidandroid-image-cropper
1.5k306
1977474741/image-cropper

💯一款功能强大的微信小程序图片裁剪插件

JavaScriptnpmMIT Licensecroppermpvue
github.com/wx-plugin/image-cropper
1.5k349
guoyingtao/Mantis

An iOS image cropping library for UIKit and SwiftUI, mimicking the Photos app — crop shapes, rotation, flip, perspective correction, undo/redo. iOS & Mac Catalyst.

SwiftMIT Licensecroppingswift
1.2k247
advanced-cropper/vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design

VueOthervuecropper
advanced-cropper.github.io/vue-advanced-cropper/
1.2k164