• This repository has been archived on 01/Aug/2020
  • Stars
    star
    7,759
  • Rank 4,661 (Top 0.1 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

cropperjs

JavaScript image cropper.
JavaScript
12,564
star
2

viewerjs

JavaScript image viewer.
JavaScript
7,526
star
3

compressorjs

JavaScript image compressor.
JavaScript
4,917
star
4

distpicker

⚠️ [Deprecated] No longer maintained. A simple jQuery plugin for picking provinces, cities and districts of China. (中国 / 省市区 / 三级联动 / 地址选择器)
JavaScript
1,638
star
5

datepicker

⚠️ [Deprecated] No longer maintained. A simple jQuery datepicker plugin.
JavaScript
1,165
star
6

vue-qrcode

QR code component for Vue.js
TypeScript
1,023
star
7

viewer

⚠️ [Deprecated] No longer maintained, please use https://github.com/fengyuanchen/jquery-viewer
JavaScript
1,017
star
8

photo-editor

A simple photo editing application.
Vue
920
star
9

jquery-cropper

A jQuery plugin wrapper for Cropper.js.
JavaScript
679
star
10

vue-countdown

Countdown component for Vue.js.
TypeScript
656
star
11

jquery-viewer

A jQuery plugin wrapper for Viewer.js.
JavaScript
319
star
12

pickerjs

⚠️ [Deprecated] No longer maintained. JavaScript date time picker.
JavaScript
312
star
13

vue-barcode

Bar code component for Vue.js
JavaScript
193
star
14

vue-carousel

Carousel component for Vue.js.
Vue
187
star
15

vue-number-input

Number input component for Vue.js.
TypeScript
173
star
16

vue-feather

Feather component for Vue.js.
TypeScript
144
star
17

simpleui

A simple UI framework for building simple web projects.
CSS
58
star
18

markdown-to-vue-loader

Markdown to Vue component loader for Webpack.
JavaScript
38
star
19

vue-countly

Countly plugin for Vue.js.
JavaScript
11
star
20

load-scripts

Dynamic scripts loading for modern browsers.
JavaScript
10
star
21

create-banner

Create a banner from a package.json file.
JavaScript
7
star
22

postcss-header

Add a header to a file.
JavaScript
3
star