jquery.Jcrop API详解
来源:互联网 发布:mnist数据集 编辑:程序博客网 时间:2024/06/05 03:51
Jcrop是一个jQuery图片裁剪插件,它能为你的WEB应用程序快速简单地提供图片裁剪的功能。特点如下:
- 对所有图片均unobtrusively(无侵入的,保持DOM简洁)
- 支持宽高比例锁定
- 支持 minSize/maxSize设置
- 支持改变选区或移 动选区时的回调(Callback)
- 支持用键盘微调选区
- 通过API创建互动,比如动画效果
- 支持CSS样式
官网:http://jcrop.org/
可下载例子进行学习
基本使用方法如下:
一、在head部分(和之间)插入相关css和js文件。
<link rel="stylesheet" href="css/jquery.Jcrop.css"><script src="js/jquery.js"></script> <script src="js/jquery.Jcrop.js"></script>
二、在head部分插入回调函数等相关处理参数。
<script language="Javascript"> <!-- jQuery(function($){ // Create variables (in this scope) to hold the API and image size var jcrop_api, boundx, boundy; $('#cropbox').Jcrop({ minSize: [0,0], maxSize:[0,0], setSelect: [0,0,0,0], boxWidth:800, borderOpacity:0.3, keySupport:false, dragEdges:false, allowSelect:false, allowResize:false, bgOpacity:0.2, boundary:0, //allowMove:false, addClass: 'jcrop-handle', onSelect: updateCoords, }, function(){ // Use the API to get the real image size var bounds = this.getBounds(); boundx = bounds[0]; boundy = bounds[1]; // Store the API in the jcrop_api variable jcrop_api = this; }); function updateCoords(c) { $('#x').val(c.x); $('#y').val(c.y); $('#w').val(c.w); $('#h').val(c.h); }; function checkCoords() { if (parseInt($('#w').val())) return true; alert('请选择裁剪区域'); return false; }; });--></script>
三、给相关图片加上id以便识别。
<img id="cropbox" src="x.jpg">
这样就能实现最简单的裁剪效果,至于如何结合php等动态语句处理图片,在置顶的文章里已经给出了示例。
下表给出基本options参数设置:
下表是api方法
0 0
- jquery.Jcrop API详解
- jquery.Jcrop API详解
- jQuery Jcrop API参数说明(中文版)
- jQuery.jcrop 基本参数
- jQuery Jcrop 图像裁剪
- jQuery Jcrop 图像裁剪
- JQuery Jcrop—JQuery Jcrop 图像裁剪工具学习
- jQuery图片剪裁插件 Jcrop
- jquery插件图片裁剪jcrop
- thinkphp jquery剪切图片 Jcrop
- jQuery jcrop插件截图使用方法
- jQuery图片剪裁插件 Jcrop
- jQuery jcrop插件截图使用方法
- jQuery jcrop插件截图使用方法
- 实现图像剪裁 jquery.Jcrop
- jQuery 图像裁剪插件Jcrop
- mini_magick+jquery.Jcrop+jquery.form.min
- jQuery 上传头像插件Jcrop的实例
- yii2.0源码实现csrf验证
- 在C语言头文件中,#ifndef、#define、#endif的作用?
- Bitmap和Base64的相互转换
- GATT Profile 简介
- IOS检查版本更新
- jquery.Jcrop API详解
- Tinker 热修复 demo 使用指南
- static class 静态类(Java)
- spring事物配置,声明式事务管理和基于@Transactional注解的使用
- Unreal Engine 4 —— 使用ProceduralMeshComponent实现模型实时切割
- CentOS 关闭防火墙和SELINUX配置
- opacity兼容ie8
- /etc/ld.so.conf 动态库
- redis学习--基础1