ランキングに戻る

fengyuanchen/cropper

JavaScript

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

image-cropperimage-processingcropperjqueryjquery-plugin
スター成長
スター
7.7k
フォーク
1.7k
週間成長
Issue
0
2k4k6k
2014年3月2018年4月2022年6月2026年7月
成果物npmnpm install cropper
README

Cropper

Build Status Downloads Version Dependencies

A simple jQuery image cropping plugin. As of v4.0.0, the core code of Cropper is replaced with Cropper.js.

  • Demo
  • Cropper.js - JavaScript image cropper (recommended)
  • jquery-cropper - A jQuery plugin wrapper for Cropper.js (recommended for jQuery users to use this instead of Cropper)

Main

dist/
├── cropper.css
├── cropper.min.css   (compressed)
├── cropper.js        (UMD)
├── cropper.min.js    (UMD, compressed)
├── cropper.common.js (CommonJS, default)
└── cropper.esm.js    (ES Module)

Getting started

Installation

npm install cropper jquery

Include files:

<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<link  href="/path/to/cropper.css" rel="stylesheet">
<script src="/path/to/cropper.js"></script>

Usage

Initialize with $.fn.cropper method.

<!-- Wrap the image or canvas element with a block element (container) -->
<div>
  <img id="image" src="picture.jpg">
</div>
/* Limit image width to avoid overflow the container */
img {
  max-width: 100%; /* This rule is very important, please do not ignore this! */
}
var $image = $('#image');

$image.cropper({
  aspectRatio: 16 / 9,
  crop: function(event) {
    console.log(event.detail.x);
    console.log(event.detail.y);
    console.log(event.detail.width);
    console.log(event.detail.height);
    console.log(event.detail.rotate);
    console.log(event.detail.scaleX);
    console.log(event.detail.scaleY);
  }
});

// Get the Cropper.js instance after initialized
var cropper = $image.data('cropper');

Options

See the available options of Cropper.js.

$('img').cropper(options);

Methods

See the available methods of Cropper.js.

$('img').once('ready', function () {
  $(this).cropper('method', argument1, , argument2, ..., argumentN);
});

Events

See the available events of Cropper.js.

$('img').on('event', handler);

No conflict

If you have to use other plugin with the same namespace, just call the $.fn.cropper.noConflict method to revert to it.

<script src="other-plugin.js"></script>
<script src="cropper.js"></script>
<script>
  $.fn.cropper.noConflict();
  // Code that uses other plugin's "$('img').cropper" can follow here.
</script>

Browser support

It is the same as the browser support of Cropper.js. As a jQuery plugin, you also need to see the jQuery Browser Support.

Contributing

Please read through our contributing guidelines.

Versioning

Maintained under the Semantic Versioning guidelines.

License

MIT © Chen Fengyuan

関連リポジトリ
fengyuanchen/cropperjs

JavaScript image cropper.

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

一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库

JavaMavenApache License 2.0takephotoandroid
devio.org/tags/
7.2k1.5k
pqpo/SmartCropper

🔥 A library for cropping image in a smart way that can identify the border and correct the cropped image. 智能图片裁剪框架。自动识别边框,手动调节选区,使用透视变换裁剪并矫正选区;适用于身份证,名片,文档等照片的裁剪。

JavaMavensmartcropperhed-net
pqpo.me/2017/09/11/opencv-border-recognition/
4.1k760
Foliotek/Croppie

A Javascript Image Cropper

JavaScriptnpmMIT Licensejavascript-image-croppercroppie
foliotek.github.io/Croppie
2.6k863
steelkiwi/cropiwa

📐 Configurable Custom Crop widget for Android

JavaMavencropcrop-image
steelkiwi.com
2.2k323
MattKetmo/darkroomjs

Extensible image editing tool in your browser

JavaScriptnpmMIT Licenseimage-processingimage-editing
mattketmo.github.io/darkroomjs
1.5k411
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
hnvn/flutter_image_cropper

A Flutter plugin for Android and iOS supports cropping images

Dartflutterflutter-plugin
1.1k477
zhanziyang/vue-croppa

A simple straightforward customizable mobile-friendly image cropper for Vue 2.0.

Vuevuecropper
zhanziyang.github.io/vue-croppa/
967128