# Cropper
> A simple jQuery image cropping plugin.
- [Website](https://fengyuanchen.github.io/cropper)
- [Cropper without jQuery](https://github.com/fengyuanchen/cropperjs)
[![Build Status Images](https://travis-ci.org/fengyuanchen/cropper.svg)](https://travis-ci.org/fengyuanchen/cropper)
## Table of contents
- [Features](#features)
- [Main](#main)
- [Getting started](#getting-started)
- [Options](#options)
- [Methods](#methods)
- [Events](#events)
- [No conflict](#no-conflict)
- [Browser support](#browser-support)
- [Contributing](#contributing)
- [Versioning](#versioning)
- [License](#license)
## Features
- Supports 39 [options](#options)
- Supports 27 [methods](#methods)
- Supports 7 [events](#events)
- Supports touch (mobile)
- Supports zooming
- Supports rotating
- Supports scaling (flipping)
- Supports multiple croppers
- Supports to crop on a canvas
- Supports to crop image in the browser-side by canvas
- Supports to translate Exif Orientation information
- Cross-browser support
## Main
```
dist/
├── cropper.css ( 5 KB)
├── cropper.min.css ( 4 KB)
├── cropper.js (79 KB)
└── cropper.min.js (28 KB)
```
## Getting started
### Quick start
Four quick start options are available:
- [Download the latest release](https://github.com/fengyuanchen/cropper/archive/master.zip).
- Clone the repository: `git clone https://github.com/fengyuanchen/cropper.git`.
- Install with [NPM](http://npmjs.org): `npm install cropper`.
- Install with [Bower](http://bower.io): `bower install cropper`.
### Installation
Include files:
```html
<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>
```
The [cdnjs](https://github.com/cdnjs/cdnjs) provides CDN support for Cropper's CSS and JavaScript. You can find the links [here](https://cdnjs.com/libraries/cropper).
### Usage
Initialize with `$.fn.cropper` method.
```html
<!-- Wrap the image or canvas element with a block element (container) -->
<div>
<img id="image" src="picture.jpg">
</div>
```
```css
/* Limit image width to avoid overflow the container */
img {
max-width: 100%; /* This rule is very important, please do not ignore this! */
}
```
```js
$('#image').cropper({
aspectRatio: 16 / 9,
crop: function(e) {
// Output the result data for cropping image.
console.log(e.x);
console.log(e.y);
console.log(e.width);
console.log(e.height);
console.log(e.rotate);
console.log(e.scaleX);
console.log(e.scaleY);
}
});
```
#### FAQ
See the [FAQ](FAQ.md) documentation.
#### Notes
- The size of the cropper inherits from the size of the image's parent element (wrapper), so be sure to wrap the image with a **visible block element**.
> If you are using cropper in a modal, you should initialize the cropper after the modal shown completely. Otherwise, you will not get a correct cropper.
- The outputted cropped data bases on the original image size, so you can use them to crop the image directly.
- If you try to start cropper on a cross-origin image, please make sure that your browser supports HTML5 [CORS settings attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes), and your image server supports the `Access-Control-Allow-Origin` option (see the [HTTP access control (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)).
#### Known issues
- [Known iOS resource limits](https://developer.apple.com/library/mac/documentation/AppleApplications/Reference/SafariWebContent/CreatingContentforSafarioniPhone/CreatingContentforSafarioniPhone.html): As iOS devices limit memory, the browser may crash when you are cropping a large image (iPhone camera resolution). To avoid this, you may resize the image first (below 1024px) before start a cropper.
- Known image size increase: When export the cropped image on browser-side with the `HTMLCanvasElement.toDataURL` method, the the exported image'size may be greater than the original image's. This is because the exported image'type is not the same as the original image's. So just pass the original image's type as the first parameter to `toDataURL` to fix this. For example, if the original type is JPEG, then use `$().cropper('getCroppedCanvas').toDataURL('image/jpeg')` to export image.
[⬆ back to top](#table-of-contents)
## Options
You may set cropper options with `$().cropper(options)`.
If you want to change the global default options, You may use `$.fn.cropper.setDefaults(options)`.
### viewMode
- Type: `Number`
- Default: `0`
- Options:
- `0`: the crop box is just within the container
- `1`: the crop box should be within the canvas
- `2`: the canvas should not be within the container
- `3`: the container should be within the canvas
Define the view mode of the cropper.
### dragMode
- Type: `String`
- Default: `'crop'`
- Options:
- `'crop'`: create a new crop box
- `'move'`: move the canvas
- `'none'`: do nothing
Define the dragging mode of the cropper.
### aspectRatio
- Type: `Number`
- Default: `NaN`
Set the aspect ratio of the crop box. By default, the crop box is free ratio.
### data
- Type: `Object`
- Default: `null`
The previous cropped data if you had stored, will be passed to `setData` method automatically.
### preview
- Type: `String` (**jQuery selector**)
- Default: `''`
Add extra elements (containers) for previewing.
**Notes:**
- The maximum width is the initial width of preview container.
- The maximum height is the initial height of preview container.
- If you set an `aspectRatio` option, be sure to set the preview container with the same aspect ratio.
- If preview is not getting properly displayed, set `overflow:hidden` to the preview container.
### responsive
- Type: `Boolean`
- Default: `true`
Re-render the cropper when resize the window.
### restore
- Type: `Boolean`
- Default: `true`
Restore the cropped area after resize the window.
### checkCrossOrigin
- Type: `Boolean`
- Default: `true`
Check if the current image is a cross-origin image.
If it is, when clone the image, a `crossOrigin` attribute will be added to the cloned image element and a timestamp will be added to the `src` attribute to reload the source image to avoid browser cache error.
By adding `crossOrigin` attribute to image will stop adding timestamp to image url, and stop reload of image.
### checkOrientation
- Type: `Boolean`
- Default: `true`
Check the current image's Exif Orientation information.
More exactly, read the Orientation value for rotating or flipping the image, and then override the Orientation value with `1` (the default value) to avoid some issues (#120, #509) on iOS devices.
**Note:** Don't trust this all the time as some JPG images have incorrect (not standard) Orientation values.
> Requires [Typed Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) support ([IE 10+](http://caniuse.com/typedarrays)).
### modal
- Type: `Boolean`
- Default: `true`
Show the black modal above the image and under the crop box.
### guides
- Type: `Boolean`
- Default: `true`
Show the dashed lines above the crop box.
### center
- Type: `Boolean`
- Default: `true`
Show the center indicator above the crop box.
### highlight
- Type: `Boolean`
- Default: `true`
Show the white modal above the crop box (highlight the crop box).
### background
- Type: `Boolean`
- Default: `true`
Show the grid background of the container.
### autoCrop
- Type: `Boolean`
- Default: `true`
Enable to crop the image automatically when initialize.
### autoCropArea
- Type: `Number`
- Default: `0.8` (80% of the image)
A number between 0 and 1. Define the automatic cropping area size (percentage).
### movable
- Type: `Boolean`
- Default: `true`
Enable to move the image.
### rotatable
- Type: `Boolean`
- Default:
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于 springboot 的大学生社团活动平台源码+数据库(高分毕业设计).zip 该项目是个人大作业高分项目源码,获得老师高度认可,都经过严格调试,确保可以运行!放心下载使用。 该项目资源主要针对相关专业的学生或从业者下载使用,也可作为期末课程设计、期末课程大作业等,具有较高的学习价值。 基于 springboot 的大学生社团活动平台源码+数据库(高分毕业设计).zip 该项目是个人大作业高分项目源码,获得老师高度认可,都经过严格调试,确保可以运行!放心下载使用。 该项目资源主要针对相关专业的学生或从业者下载使用,也可作为期末课程设计、期末课程大作业等,具有较高的学习价值。 基于 springboot 的大学生社团活动平台源码+数据库(高分毕业设计).zip 该项目是个人大作业高分项目源码,获得老师高度认可,都经过严格调试,确保可以运行!放心下载使用。 该项目资源主要针对相关专业的学生或从业者下载使用,也可作为期末课程设计、期末课程大作业等,具有较高的学习价值。 基于 springboot 的大学生社团活动平台源码+数据库(高分毕业设计).zip 该项目是个人大作业高分项目
资源推荐
资源详情
资源评论
收起资源包目录
基于 springboot 的大学生社团活动平台源码+数据库(高分毕业设计).zip (2000个子文件)
bootstrap.css 143KB
bootstrap.css 120KB
bootstrap.min.css 119KB
bootstrap.min.css 97KB
font-awesome.css 34KB
font-awesome.min.css 28KB
bootstrap-theme.css 25KB
bootstrap-theme.min.css 23KB
jasmine.css 19KB
select2.css 17KB
select2.min.css 15KB
bootstrap-theme.css 14KB
bootstrap-theme.min.css 13KB
normalize.css 8KB
smart_wizard_vertical.css 6KB
smart_wizard.css 6KB
qunit-1.23.1.css 5KB
cropper.css 5KB
mocha.css 5KB
dataTables.bootstrap.css 5KB
responsive.bootstrap.css 5KB
dataTables.bootstrap.min.css 4KB
cropper.min.css 4KB
responsive.bootstrap.min.css 4KB
ion.rangeSlider.css 3KB
pygments.css 3KB
ion.rangeSlider.skinHTML5.css 3KB
examples.css 3KB
ion.rangeSlider.skinModern.css 2KB
ion.rangeSlider.skinFlat.css 2KB
base.css 2KB
ion.rangeSlider.skinSimple.css 2KB
buttons.bootstrap.css 2KB
ion.rangeSlider.skinNice.css 2KB
demo_style.css 2KB
jquery-ui.min.css 2KB
buttons.bootstrap.min.css 2KB
switchery.css 1KB
switchery.css 994B
uwidget.css 860B
prettify-1.0.css 762B
switchery.min.css 682B
prettify.css 676B
parsley.css 629B
main.css 578B
morris.css 433B
fixedHeader.bootstrap.css 380B
fixedHeader.bootstrap.min.css 328B
starrr.css 162B
example.css 158B
legend.css 153B
reset.css 126B
svgstyle.css 106B
area2.html 88KB
timeScale.html 87KB
multipleGrid.html 86KB
core-prototypes.js.html 80KB
sugarpak.js.html 52KB
parsing_operators.js.html 51KB
ie8.html 50KB
i18n.js.html 46KB
parsing_translator.js.html 45KB
extras.js.html 43KB
format_parser.js.html 43KB
core.js.html 42KB
worldPopulationBubble.html 37KB
parsing_grammar.js.html 35KB
time_span.js.html 31KB
index.html 30KB
bmap.html 29KB
parser.js.html 28KB
announcements-4.0.html 27KB
visualMap-continuous.html 27KB
index.html 27KB
visualMap-opacity.html 26KB
index.html 25KB
effectScatter.html 24KB
heatmap-map.html 24KB
core-options.html 23KB
axes.html 22KB
time_period.js.html 22KB
candlestickConnect.html 21KB
index.html 20KB
index.html 20KB
media-finance.html 19KB
timeline-layout.html 17KB
geoScatter.html 17KB
mapWorld.html 17KB
geoLine.html 15KB
visualMap-layout.html 14KB
index.html 12KB
timeline-finance.html 12KB
gauge.html 12KB
dataZoom-axes.html 11KB
treemap-obama.html 11KB
dataZoom-axis-type.html 11KB
dataZoomHighPrecision.html 11KB
map.html 10KB
boxplot.html 10KB
dataZoom-rainfall-connect.html 10KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
盈梓的博客
- 粉丝: 7029
- 资源: 1584
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
- python-leetcode面试题解之第165比较版本号-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功