案例:前端图片截取功能

分布说明A:选择File本地选择的图片 B:根据需求按比例缩放图片 C:区域选择型操作

A: 选择图片

<input class="upfile" type="file" id="pictureUpload" name="pictureUpload">
<image id="SelectImage">

B: 如果选择的图片比较大,则按照需求缩放即可

function AutoResizeImage(TargetWidth, TargetHeight) {
var img = document.getElementById("SelectImage");
var IntWidth;
var IntHeight;
if (img.width > TargetWidth && img.height <= TargetHeight) {
IntWidth = TargetWidth;
IntHeight = (IntWidth * img.height) / img.width;
}
else if (img.width <= TargetWidth && img.height > TargetHeight) {
IntHeight = TargetHeight;
IntWidth = (IntHeight * img.width) / img.height;
}
else if (img.Width <= TargetWidth && img.height <= TargetHeight) {
IntHeight = img.width;
IntWidth = img.height;
}
else {
IntWidth = TargetWidth;
IntHeight = (IntWidth * img.height) / img.width;
if (IntHeight > TargetHeight)
{
IntHeight = TargetHeight;
IntWidth = (IntHeight * img.width) / img.height;
}
}
img.height = IntHeight;
img.width = IntWidth;
}

C: imgAreaSelect 作用是图片区域选择显示

例如图示:

 $(document).ready(function () {
//初始化选择图片区域的裁剪元素
$('#SelectImage').imgAreaSelect({
aspectRatio: '1:1',
handles: true,
fadeSpeed: 200,
onSelectChange: preview,
   minWidth:100,
   minHeight:100,
x1: 0,
y1: 0,
x2: 100,
y2: 100
});
});

jQuery imgAreaSelect Examples的更多相关文章

  1. 网站中集成jquery.imgareaselect实现图片的本地预览和选择截取

    imgAreaSelect 是由 Michal Wojciechowski开发的一款非常好用的jquery插件,实现了图片的截取功能.其文档和Demo也是很详尽的.大家可以到http://odynie ...

  2. 图片上传,图片剪切jquery.imgareaselect

    ---恢复内容开始--- <%@ page language="java" contentType="text/html; charset=UTF-8" ...

  3. 圖片裁剪大頭貼功能 - ASP.NET WebForm + jQuery + imgAreaSelect

    系統操作環境: ASP.NET WebForm .NET Framework 4.0 (C#) jQuery 1.7.1 imgAreaSelect 0.9.8 目錄結構: 與之前使用ASP.NET ...

  4. Uploadify & jQuery.imgAreaSelect 插件实现图片上传裁剪

    在网站中需要一个图片上传裁剪的功能,借鉴这篇文章 Ajax+PHP+jQuery图片截图上传 的指点,找到了jquery.imgAreaSelect这个不错插件,能对图片进行自定义区域选择并给出坐标, ...

  5. JQuery.imgAreaSelect 参数说明

    imgAreaSelect 参数说明: 参数 描述 aspectRatio 设定选取区域的显示比率,如:”4:3“ autoHide 如果设置为true,当选择区域选择结束时消失,默认值为:false ...

  6. jQuery 图片剪裁插件使用之 imgAreaSelect

    插件主页:http://odyniec.net/projects/imgareaselect/ 官方网站上说明支持的浏览器:The plugin works in all major browsers ...

  7. 利用jquery的imgAreaSelect插件实现图片裁剪示例

    http://www.cnblogs.com/mizzle/archive/2011/10/13/2209891.html 将用户上传的图片进行裁剪再保存是现在web2.0应用中常常处理的工作,现在借 ...

  8. 采用jquery的imgAreaSelect样品图像裁剪示范插件实现

    将用户上传的图片进行裁剪再保存是如今web2.0应用中经常处理的工作,如今借助jquery的imgareaselect插件再配合PHP的GD库就能够轻松的实现这个在曾经来说很棘手的功能. 我们来看看它 ...

  9. 关于jQuery插件imgAreaSelect基础讲解

    关于ImgAreaSelect,  是一jQuery插件,它支持用户通过鼠标拖曳选择图片的一部分,如图片拖曳.图片编辑等~~来具体看一下 1.先下载imgAreaSelect插件 下载地址: 英文:h ...

随机推荐

  1. php分享二十七:批量插入mysql

    一:思考 1:如果插入的某个字段大于数据库定义的长度了,数据库会怎么处理? 1>如果数据库引擎是myisam,则数据库会截断后插入,不报错 2>如果数据库引擎是innodb,则数据库会报 ...

  2. Netflix OSS、Spring Cloud还是Kubernetes? 都要吧!

    Netflix OSS是由Netflix公司主持开发的一套代码框架和库,目的是解决上了规模之后的分布式系统可能出现的一些有趣问题.对于当今时代的Java开发者们来说,Netflix OSS简直就是在云 ...

  3. 三星 S4 手机误删除相片(相册)后的恢复问题,仅记录处理过程,其它Android手机同样适用

    无意中删除了三星S4手机中相机的相册.过程是这样的,用手机拍了几张照片,觉得最后那张拍得不好,想删除,于是进入相册,看到有那张照片的图标,选择,删除,悲剧发生了! 这里得说三星的不好:在相册中,相册文 ...

  4. HDU 1431 素数回文

    有人问我这个问题. 个人感觉暴搜会TLE O(n*sqrt(n)).n=100000000:(推断素数用2~sqrt(n)+1 去除) 还是枚举好了. 枚举 1~10000,把他每一位存下来,回文数已 ...

  5. [svc]nginx优化

    nginx的25条优化

  6. HA&Federation【转】

    转自:http://blog.csdn.net/tutucute0000/article/details/39756123 从nameNode1.namenode2克隆出namenode3.namen ...

  7. canvas的图片绘制案例

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  8. JS操作MongoDB

    JavaScript处理MongoDB,更新数据: #!/bin/bash mongo=/home/zhangzhenghai/cluster/mongodb/bin/mongo if true; t ...

  9. JS实现文本框和文本域获取焦点focus()时,光标在本文的末尾

    <!-- <input type="text" id="test1" name="test1" value="test ...

  10. 【Linux】crontab 定时启动sh

    crontab -e 20点59分启动脚本 59 20 * * * sh /home/fzuir/xingye4crawl/endXingYe4Crawl.sh >/home/fzuir/xin ...