jQuery的图片剪切插件2

简介: imgAreaSelect imgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image c...

imgAreaSelect

imgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as other user interface features, such as photo notes (like those on Flickr).

Plugin features:

  • Highly configurable
  • Customizable with CSS styling
  • Handles scaled images
  • Keyboard support for moving and resizing the selection
  • Supports callback functions
  • Provides API functions for easier integration with other application components
  • Lightweight — the packed version is less than 8KB

The plugin works in all major browsers, including Firefox 2+, Opera 9.5+, Google Chrome, Safari 3+, and Internet Explorer 6+.

Live Example

Click and drag on the image to select an area.

Selection Preview

Coordinates Dimensions
X1: Width:
Y1: Height:
X2:    
Y2:    

» See more examples

Quick Usage Instructions

Download the plugin, unzip it, and copy the JavaScript and CSS files to your website/application directory. Load the files in the <head> section of your HTML document.

<head>
  ...
<linkrel="stylesheet"type="text/css"href="css/imgareaselect-default.css"/><scripttype="text/javascript"src="scripts/jquery.min.js"></script><scripttype="text/javascript"src="scripts/jquery.imgareaselect.pack.js"></script>
  ...
</head>

Then, to enable selection on an image, wrap it in a jQuery object and call the imgAreaSelect() method:

<scripttype="text/javascript">
$(document).ready(function(){    $('img#photo').imgAreaSelect({
        handles:true,
        onSelectEnd: someFunction
    });});</script>

» Read documentation

Download

jquery.imgareaselect-0.9.8.zip – a zip archive containing the plugin source (packed version included), a minified version of jQuery, CSS and graphics files, and license text files.

For Developers

For web developers who want to extend/modify the plugin, here's a fully documented version of the source code:
jquery.imgareaselect.dev.js

License

Dual licensed under the MIT and GPL licenses.

Links

imgAreaSelect on jQuery Plugins

imgAreaSelect on GitHub

PHP & jQuery image upload and crop tutorial at WebMotionUK

Using imgAreaSelect and GD library to crop and create thumbnails at Leon Kessler's blog

AjaxCrop – Jquery and PHP Crop tool at Keith Levi Lumanog's blog

目录
相关文章
|
JavaScript
jQuery 自定义插件
jQuery 自定义插件
50 0
|
6月前
|
移动开发 JavaScript 前端开发
jQuery 安装
jQuery 安装
47 8
|
JavaScript 前端开发
推荐几个jquery实用的插件
虽然jquery在最近几年没有之前那几年火,但是有很多公司还是用它的,这里我向大家推荐几个实用的jquery插件。
|
JavaScript 敏捷开发 内存技术
|
Web App开发 前端开发 JavaScript
|
Web App开发 JavaScript 前端开发
|
前端开发 JavaScript
|
JavaScript 前端开发
jQuery 插件
# 全局插件模板 /**  * 封装全局函数的插件模板  */ ; (function($) {     $.extend({         "project": function(value) {             // 这里写插件代...
630 0
|
Web App开发 移动开发 JavaScript
2016年4月最佳的20款 jQuery 插件推荐
  这个列表包括20个我们觉得是最有用的免费的 jQuery 插件,它们都是最具创新性和最省时省力的解决方案,很多都是现代化的设计和开发中碰到的问题的处理方案。如果你熟悉下面列出的任何插件,请与我们的读者分享您的意见,或者如果您知道的我们还没有包括的话,请与我们分享在下面的评论部分。
1194 0