惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - John Liu

C#中处理SQL Server中的空的DateTime型字段 推荐一个不错的国外html5模板网站 SQL SERVERR中未公开的存储过程sp_MSforeachtable - John Liu .net 4.0 ValidateRequest="false" 无效 - John Liu 《数据库设计指南》学习笔记一:设计数据库之前 巧用case when 解决多条件模糊查询问题 安装vs2010后新建项目FrameWork版本选择只有4.0的解决方案 SQL Server直接执行.sql文件 【转自大家论坛】jQuery 1.4: 15个你应该知道的新特性 - John Liu 小技巧:Response.Redirect(...,true/false) [转]100多个很有用的JavaScript函数以及基础写法大集合 思维导图,相见恨晚 微软提供的web.config文件的加密方式,掩耳盗铃! 开始专注数据库:动态Sql,自定义函数 将sql server表中的数据导出为inert into语句的形式 js进行图片的等比缩放(转自yayayaangel的百度空间) - John Liu - 博客园 金额数字的格式化(转自mimimo的百度空间) web.config文件加密 - John Liu - 博客园 使用sql语句建立与删除链接服务器及执行数据库操作
jQuery的图像裁剪插件Jcrop的简单使用
John Liu · 2009-05-21 · via 博客园 - John Liu

     目前做的这个项目中要用到用户头像功能,领导说最好是做成用户上传一个图片后可以用图像裁剪的方法自己选择头像。同事推荐了Jcrop这个插件,到它的官方站点http://deepliquid.com/content/Jcrop.html下载了最新版的压缩包,压缩包中包括了Jcrop的几个demo文件,关键的Jcrop.js文件和jQuery.Jcrop.css文件。基本上来说参照它的几个demo文件就可以学会使用这个插件了。晚上正好学习研究了下,现简单总结如下,也方便下英文不好的朋友们。
     使用插件必须条件:引入jQuery.js文件,引入jQuery.Jcrop.js文件,引入JQuery.Jcrop.css文件。

     1.最基本使用方法
     html代码部分: 

<img src="demo_files/flowers.gif" id="demoImage"/>

     js部分:

$(
    
function()
    {
       $(
"#demoImage").Jcrop();
    }
);

      这样就可以在图片上进行裁剪了。
      2.得到选中区域的坐标以及回调函数
      html代码部分如下:

<img src="demo_files/flowers.jpg" id="demoImage" />
    
<label>x1</label><input type="text" id="txtX1" />
    
<label>y1</label><input type="text" id="txtY1" />
    
<label>x2</label><input type="text" id="txtX2" />
    
<label>y2</label><input type="text" id="txtY2" />
    
<label>width</label><input type="text" id="txtWidth" />
    
<label>height</label><input type="text" id="txtHeight" />

      js代码部分如下:

$(
            
function() {
                
//事件处理
                $("#demoImage").Jcrop(
                {
                    onChange:showCoords,    
//当选择区域变化的时候,执行对应的回调函数
                    onSelect:showCoords     //当选中区域的时候,执行对应的回调函数
                }
                );
            }
        );
            
function showCoords(c) {
                $(
"#txtX1").val(c.x);       //得到选中区域左上角横坐标
                $("#txtY1").val(c.y);       //得到选中区域左上角纵坐标
                $("#txtX2").val(c.x2);      //得到选中区域右下角横坐标
                $("#txtY2").val(c.y2);      //得到选中区域右下角纵坐标
                $("#txtWidth").val(c.w);    //得到选中区域的宽度
                $("#txtHeight").val(c.h);   //得到选中区域的高度
            }

       3.常用选项设置
       aspectRatio:选中区域按宽/高比,为1表示正方形。
       minSize:最小的宽,高值。
       maxSize:最大的宽,高值。
       setSelect:设置初始选中区域。
       bgColor:背景颜色
       bgOpacity:背景透明度。
       allowResize:是否允许改变选中区域大小。
       allowMove:是否允许移动选中区域。
       举例如下:

$(
            
function() {                
                $(
"#demoImage").Jcrop({
                            aspectRatio: 
1,             //选中区域宽高比为1,即选中区域为正方形     
                            bgColor:"#ccc",             //裁剪时背景颜色设为灰色
                            bgOpacity:0.1,              //透明度设为0.1
                            allowResize:false,          //不允许改变选中区域的大小
                            setSelect:[0,0,100,100]     //初始化选中区域
                            }
                        );        
            }
        );

        4.api用法

var api = $.Jcrop("#demoImage");
api.disable();                      
//设置为禁用裁剪效果
api.enable();                       //设置为启用裁剪效果
api.setOptions({allowResize:false});//设置相应配置
api.setSelect([0,0,100,100]);       //设置选中区域