案例:前端图片截取功能

分布说明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. private static final long serialVersionUID = 1L;

    作者:郭无心链接:https://www.zhihu.com/question/24852886/answer/117314768来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...

  2. 反转链表(不改变指针)JAVA版

    class ListNode { int val; ListNode next; ListNode(int x) { val = x; next = null; } } public class So ...

  3. mysql获得60天前unix时间示例

    在mysql中获取多少天前的unix时间的方法.首先根据now()获得当前时间,使用adddate()方法获得60天前时间,使用unix_timestamp()方法转换时间类型 select UNIX ...

  4. Modelsim se仿真Xilinx IPcore

    Modelsim se仿真Xilinx IPcore 方法:先写好do文件常规框架,根据modelsim报错再添加ise IP核库仿真文件.注:记得添加并仿真glbl.v全局控制仿真文件到sim/is ...

  5. 制做rpm包工具fpm安装

    安装ruby模块 [root@c01 ~]# yum install ruby rubygems ruby-devel -y # 查看当前使用的rubygems仓库 [root@c01 ~]# gem ...

  6. zabbix web 登录成功后提示(红色提示):zabbix server is not running:the information displayed may not be current

    原因是$ZBX_SERVER,我配了外网地址,这里应该配成内网的: # cat /etc/zabbix/web/zabbix.conf.php <?php // Zabbix GUI confi ...

  7. checkpoint and savepoint in FlinK

    https://info.lightbend.com/rs/558-NCX-702/images/preview-apache-flink.pdf https://www.microsoft.com/ ...

  8. angular学习笔记(三十)-指令(7)-compile和link(1)

    这篇主要讲解指令中的compile,以及它和link的微妙的关系. link函数在之前已经讲过了,而compile函数,它和link函数是不能共存的,如果定义了compile属性又定义link属性,那 ...

  9. [Windows Azure] How to use the Windows Azure Blob Storage Service in .NET

    How to use the Windows Azure Blob Storage Service in .NET version 1.7 version 2.0 This guide will de ...

  10. 【教程】Source Insight 关联 .S文件,汇编文件

    加载.s汇编文件 做ARM嵌入式开发时,有时得整汇编代码,但在SI里建立PROJECT并ADD TREE的时候,根据默认设置并不会把该TREE里面所有汇编文件都包含进来,默认只加了.inc和.asm后 ...