jcrop->http://deepliquid.com/content/Jcrop_Manual.html
Introduction
Jcrop is a powerful image cropping engine for jQuery.
It's been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing power and flexibility (or the weeks of coding, testing and debugging). Jcrop
also features clean, well-organized code that works well across most modern web browsers.
Here you'll find the documentation for Jcrop itself. This guide assumes that you have a basic knowledge of HTML and including files into a web page. At the end of the article, there are links to more advanced concepts and implementation
techniques.
Getting Started
In the page <head> you'll need to load the requisite files.That includes:
-
jQuery library
-
Jcrop Javascript
-
Jcrop CSS stylesheet
It should look something like this:
<script src="js/jquery.pack.js"></script>
<script src="js/jquery.Jcrop.pack.js"></script>
<link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" />
Please note:These are only example paths, you probablywillneed to adjust them when you actually use them, to match the location of the files on your server. Jcrop will not function properly if you don't.
Invocation
Let's suppose we have this image our markup:
<img src="flowers.jpg" id="cropbox" />
To convert this into a Jcrop widget, insert the following script:
<script language="Javascript">
jQuery(function() {
jQuery('#cropbox').Jcrop();
});
</script>
Jcrop's default behavior is activated.Since there are no event handlers attached, it won't do anything cool, but you can see how easy it is to implement Jcrop into your page.
See the Jcrop "hello world" example
Event Handlers
Jcrop's two primary event handlers areonChangeandonSelect.
onSelect
callback
|
Called when selection is completed |
onChange
callback
|
Called when the selection is moving |
Define an event handler function:
<script language="Javascript">
function showCoords(c)
{
// variables can be accessed here as
// c.x, c.y, c.x2, c.y2, c.w, c.h
};
</script>
Attach event handlers like this:
<script language="Javascript">
jQuery(function() {
jQuery('#cropbox').Jcrop({
onSelect: showCoords,
onChange: showCoords
});
});
</script>
This is a conventional jQuery syntax. Note that the last property does not have a comma following (also applies if there is only one property specified). Also be sure to leave off parenthesis on callback functions (you're referring
to the named function, not calling it).
See the simple event handler demo
Setting Options
Jcrop options allow you to alter appearance and behavior.
Option Name
Value Type
Description
Default
aspectRatio
|
decimal
|
Aspect ratio of w/h (e.g. 1 for square) |
n/a
|
minSize
|
array [ w, h ]
|
Minimum width/height, use 0 for unbounded dimension |
n/a
|
maxSize
|
array [ w, h ]
|
Maximum width/height, use 0 for unbounded dimension |
n/a
|
setSelect
|
array[ x, y, x2, y2 ] |
Set an initial selection area |
n/a
|
bgColor
|
color value
|
Set color of background container |
'black' |
bgOpacity
|
decimal0 - 1 |
Opacity of outer image when cropping |
.6 |
Set these options in the same way as event handlers.
Here's an example:
<script language="Javascript">
jQuery(function() {
jQuery('#cropbox').Jcrop({
onSelect: showCoords,
bgColor: 'black',
bgOpacity: .4,
setSelect: [ 100, 100, 50, 50 ],
aspectRatio: 16 / 9
});
});
</script>
Note a few things about the format of the options object:
-
Text values must be quoted (e.g. 'red', '#ccc', 'rgb(10,10,10)')
-
Numeric values, including decimals, should not be quoted.
-
setSelecttakes an array, here indicated as an array literal
-
aspectRatiomay be easiest to set by dividing width/height
-
The last option is not followed by a comma
Further Reading
分享到:
相关推荐
jQuery图片裁剪插件Jcrop.js</title> <link href="css/basic.css?3.1.64" rel="stylesheet" type="text/css" /> <link href="css/jquery.Jcrop.css?3.1.64" rel="stylesheet" type="text/css" />...
jQuery图像裁剪插件Jcrop.js是一款功能强大的jQuery图像裁剪插件,可以结合后端程序快速的实现图片裁剪的功能。
Jcrop是一款跨浏览器的jquery图片剪裁插件。它兼容非常古老的ie6浏览器,并提供多个配置参数,实现功能强大的图片剪裁功能。
Jcrop.js实现的一款功能强大的jQuery图片裁剪插件,可以结合后端程序快速的实现图像裁剪的功能,右侧有3个图像缩略图尺寸可选。
jQuery图像照片剪裁插件Jcrop中文演示 静态演示页面 从最简单的开始 — 默认的行为表现 基本处理程序 — 基本形式的结合 锁定纵横比/剪裁效果图预览 — 不错的效果示例 设置/动画选择(初级API) — 动画演示 API...
jQuery图像裁剪插件Jcrop js是一款功能强大的jQuery图像裁剪插件,可以结合后端程序快速的实现图片裁剪的功能。
图片裁剪插件JqueryJcrop兼容大数浏览器,测试无误,链接了中文参数说明详情见页面
jQuery图像裁剪插件Jcrop.js是一款功能强大的jQuery图像裁剪插件,可以结合后端程序快速的实现图片裁剪的功能。
Jcrop 基于jquery的图片裁剪插件.zip
Jcrop (官方的) - 图片裁剪jQuery插件
目前做的这个项目中要用到用户头像功能,领导说最好是做成用户上传一个图片后可以用图像裁剪的方法自己选择头像。
jquery Jcrop 是一个功能强大的 jQuery 图像裁剪插件,结合后端程序(例如:java)可以快速的实现图片裁剪的功能
今天从官方网址下载Jcrop插件使用,发现PHP那个截图页面运行错误,截得的图是黑黑的,经过一会儿,把问题修正了,现把修正版拿出来分享给大家,多多支持哦!
适应各浏览器图片裁剪无刷新上传js插件-Jcrop Jcrop js jquery C# asp.net 文件包括: WebForm1.aspx myupload.html jquery.Jcrop.min.css jquery.min.js jquery.Jcrop.min.js imageCropperUpload.js
js 的 jCrop 插件 配合 php 进行图片剪切以及上传!
一个基于和的本地图片裁剪插件。 ####License: ###为什么需要这玩意 目前很多的图片上传、裁剪都是基于服务器端的。比如Jcrop,在选择好图片后仅仅是做了一个裁剪的UI,然后发给后端起始位置、大小等参数,由后端来...
网页端 裁剪图片,不需要经过服务器。 这个是用 https://github.com/mailru/FileAPI 框架实现的。配合jcrop. 高级浏览器 使用 canvas 裁剪,ie6 7 8使用 flash过度。 核心代码: var el = $('input').get(0); ...
php结合jquery ajaxfileupload及jcrop插件实现无刷新上传,裁剪
jquery效果1: Jcrop-jquery图片裁剪插件 jExpand+samples jOuery动态下滑菜单