案例:前端图片截取功能

分布说明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. 面试题一:linux面试题

    2.4 写出一种排序算法(原理),并说出优化它的方法. 2.5 请简单阐述您最得意的开发之作 2.6 对于大流量的网站,您采用什么样的方法来解决各页面访问量统计问题 a. 确认服务器是否能支撑当前访问 ...

  2. php分享十五:php的数据库操作

    一:术语解释: What is an Extension? API和扩展不能理解为一个东西,因为扩展不一定暴露一个api给用户 The PDO MySQL driver extension, for ...

  3. 译: 3. Axis2快速入门指南

    本指南的目的是让您尽快使用Axis2开始创建服务和客户端.我们将采用一个简单的StockQuote服务,向您展示可以创建和部署它的一些不同方式,以及快速查看Axis2附带的一个或两个实用程序.然后,我 ...

  4. 深入理解Linux内核-I/O体系结构和设备驱动程序

    系统总线:1.链接CPU.RAM.I/O设备之间的数据流动.例如:PCI.ISA.EISA.MCA.SCSI.USB2.任何I\O设备有且仅能链接一条总线. I\O端口:1.每个连接到I\O总线上的设 ...

  5. (原) windows下autohotkey的快捷键脚本编写

    autohotkey 脚本很强大,可以接受传参.能各种程序逻辑控制.还可以把脚本转换成独立执行的EXE.(安装完后程序目录下有个小程序:Convert .ahk to .exe,直接UI上转换.)总之 ...

  6. Android,XML解析

    XML解析三种方式 DOM 通用性强,它会将XML文件的所有内容读取到内存中,然后允许您使用DOM API遍历XML树.检索所需的数据: 简单直观,但需要将文档读取到内存,并不太适合移动设备: SAX ...

  7. js模板引擎art-template使用方法

    art-template是款性能卓越的 js 模板引擎 https://aui.github.io/art-template/ 特性 拥有接近 JavaScript 渲染极限的的性能 调试友好:语法. ...

  8. electron 创建右键菜单

    1.引入模块 const Electron = require('electron'); const remote = Electron.remote; const Menu = remote.Men ...

  9. Context.startActivity出现AndroidRuntimeException

    转:http://hi.baidu.com/huaxinchang/item/e1a771cf4d424312b77a2416 昨天做了一个Activity的启动动画,效果是点击桌面图标先出现动画后启 ...

  10. Asp.net 从客户端中检测到有潜在危险的Request.Form值

    解决方法: 在Web.config文件里找到<httpRuntime>节点,然后修改requestValidationMode="2.0" 修改结果如下: <sy ...