cropper
A simple jQuery image cropping plugin.
Last updated 6 years ago by chenfengyuan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cropper 
SYNC missed versions from official npm registry.

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

Current Tags

  • 4.1.0                                ...           latest (6 years ago)

85 Versions

  • 4.1.0                                ...           6 years ago
  • 4.0.0                                ...           8 years ago
  • 4.0.0-beta                                ...           8 years ago
  • 4.0.0-alpha                                ...           8 years ago
  • 3.1.6                                ...           8 years ago
  • 3.1.5                                ...           8 years ago
  • 3.1.4                                ...           8 years ago
  • 3.1.3                                ...           8 years ago
  • 3.1.2                                ...           8 years ago
  • 3.1.1                                ...           8 years ago
  • 3.1.0                                ...           9 years ago
  • 3.0.0                                ...           9 years ago
  • 3.0.0-rc.3                                ...           9 years ago
  • 3.0.0-rc.2                                ...           9 years ago
  • 3.0.0-rc.1                                ...           9 years ago
  • 3.0.0-rc                                ...           9 years ago
  • 3.0.0-beta                                ...           9 years ago
  • 3.0.0-alpha.1                                ...           9 years ago
  • 3.0.0-alpha                                ...           9 years ago
  • 2.3.4                                ...           10 years ago
  • 2.3.3                                ...           10 years ago
  • 2.3.2                                ...           10 years ago
  • 2.3.1                                ...           10 years ago
  • 2.3.0                                ...           10 years ago
  • 2.2.5                                ...           10 years ago
  • 2.2.4                                ...           10 years ago
  • 2.2.3                                ...           10 years ago
  • 2.2.2                                ...           10 years ago
  • 2.2.1                                ...           10 years ago
  • 2.2.0                                ...           10 years ago
  • 2.1.0                                ...           10 years ago
  • 2.0.2                                ...           10 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.0.0                                ...           11 years ago
  • 1.0.0-rc.1                                ...           11 years ago
  • 0.11.1                                ...           11 years ago
  • 0.11.0                                ...           11 years ago
  • 0.10.1                                ...           11 years ago
  • 0.10.0                                ...           11 years ago
  • 0.9.3                                ...           11 years ago
  • 0.9.2                                ...           11 years ago
  • 0.9.1                                ...           11 years ago
  • 0.9.0                                ...           11 years ago
  • 0.8.0                                ...           11 years ago
  • 0.7.9                                ...           11 years ago
  • 0.7.8                                ...           11 years ago
  • 0.7.7                                ...           11 years ago
  • 0.7.6                                ...           11 years ago
  • 0.7.5                                ...           11 years ago
  • 0.7.4                                ...           11 years ago
  • 0.7.3                                ...           11 years ago
  • 0.7.2                                ...           11 years ago
  • 0.7.1                                ...           11 years ago
  • 0.7.0                                ...           11 years ago
  • 0.6.2                                ...           11 years ago
  • 0.6.1                                ...           12 years ago
  • 0.6.0                                ...           12 years ago
  • 0.5.5                                ...           12 years ago
  • 0.5.4                                ...           12 years ago
  • 0.5.3                                ...           12 years ago
  • 0.5.2                                ...           12 years ago
  • 0.5.1                                ...           12 years ago
  • 0.5.0                                ...           12 years ago
  • 0.4.4                                ...           12 years ago
  • 0.4.4-rc                                ...           12 years ago
  • 0.4.3-beta                                ...           12 years ago
  • 0.4.3-alpha                                ...           12 years ago
  • 0.4.2                                ...           12 years ago
  • 0.4.0                                ...           12 years ago
  • 0.3.9                                ...           12 years ago
  • 0.3.8                                ...           12 years ago
  • 0.3.7                                ...           12 years ago
  • 0.3.6                                ...           12 years ago
  • 0.3.5                                ...           12 years ago
  • 0.3.4                                ...           12 years ago
  • 0.3.3                                ...           12 years ago
  • 0.3.2                                ...           12 years ago
  • 0.3.1                                ...           12 years ago
  • 0.3.0                                ...           12 years ago
  • 0.2.4                                ...           12 years ago
  • 0.2.3                                ...           12 years ago
  • 0.2.2                                ...           12 years ago
  • 0.2.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 13
Last Month 6
Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |