Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fengyuanchen/jquery-cropper
A jQuery plugin wrapper for Cropper.js.
https://github.com/fengyuanchen/jquery-cropper
cropper cropperjs image-cropper image-processing jquery jquery-plugin
Last synced: about 3 hours ago
JSON representation
A jQuery plugin wrapper for Cropper.js.
- Host: GitHub
- URL: https://github.com/fengyuanchen/jquery-cropper
- Owner: fengyuanchen
- License: mit
- Created: 2018-02-28T13:57:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-21T11:08:22.000Z (over 4 years ago)
- Last Synced: 2024-04-14T23:03:55.396Z (7 months ago)
- Topics: cropper, cropperjs, image-cropper, image-processing, jquery, jquery-plugin
- Language: JavaScript
- Homepage: https://fengyuanchen.github.io/jquery-cropper
- Size: 643 KB
- Stars: 681
- Watchers: 26
- Forks: 257
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# jquery-cropper
[![Build Status](https://img.shields.io/travis/fengyuanchen/jquery-cropper.svg)](https://travis-ci.org/fengyuanchen/jquery-cropper) [![Coverage Status](https://img.shields.io/codecov/c/github/fengyuanchen/jquery-cropper.svg)](https://codecov.io/gh/fengyuanchen/jquery-cropper) [![Downloads](https://img.shields.io/npm/dm/jquery-cropper.svg)](https://www.npmjs.com/package/jquery-cropper) [![Version](https://img.shields.io/npm/v/jquery-cropper.svg)](https://www.npmjs.com/package/jquery-cropper)
> A jQuery plugin wrapper for [Cropper.js](https://github.com/fengyuanchen/cropperjs).
- [Demo](https://fengyuanchen.github.io/jquery-cropper)
## Main
```text
dist/
├── jquery-cropper.js (UMD)
├── jquery-cropper.min.js (UMD, compressed)
├── jquery-cropper.common.js (CommonJS, default)
└── jquery-cropper.esm.js (ES Module)
```## Getting started
### Installation
```shell
npm install jquery-cropper jquery cropperjs
```Include files:
```html
```
### Usage
Initialize with `$.fn.cropper` method.
```html
``````css
/* Limit image width to avoid overflow the container */
img {
max-width: 100%; /* This rule is very important, please do not ignore this! */
}
``````js
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](https://github.com/fengyuanchen/cropperjs#options) of Cropper.js.
```js
$().cropper(options);
```## Methods
See the available [methods](https://github.com/fengyuanchen/cropperjs#methods) of Cropper.js.
```js
$().cropper('method', argument1, , argument2, ..., argumentN);
```## Events
See the available [events](https://github.com/fengyuanchen/cropperjs#events) of Cropper.js.
```js
$().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.
```html
$.fn.cropper.noConflict();
// Code that uses other plugin's "$().cropper" can follow here.```
## Browser support
It is the same as the [browser support of Cropper.js](https://github.com/fengyuanchen/cropperjs#browser-support). As a jQuery plugin, you also need to see the [jQuery Browser Support](https://jquery.com/browser-support/).
## Contributing
Please read through our [contributing guidelines](CONTRIBUTING.md).
## Versioning
Maintained under the [Semantic Versioning guidelines](https://semver.org/).
## License
[MIT](https://opensource.org/licenses/MIT) © [Chen Fengyuan](https://chenfengyuan.com/)