<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.imgareaselect.pack.js"></script>
<script type="text/javascript" src="js/test.js"></script>
<script type="text/javascript">
function preview(img, selection) {
if (!selection.width || !selection.height)
return;
var scaleX = 88 / selection.width;
var scaleY = 88 / selection.height;
$('#preview1 img').css({
width: Math.round(scaleX * 300),
height: Math.round(scaleY * 300),
marginLeft: -Math.round(scaleX * selection.x1),
marginTop: -Math.round(scaleY * selection.y1)
});
scaleX = 64 / selection.width;
scaleY = 64 / selection.height;
$('#preview2 img').css({
width: Math.round(scaleX * 300),
height: Math.round(scaleY * 300),
marginLeft: -Math.round(scaleX * selection.x1),
marginTop: -Math.round(scaleY * selection.y1)
});
scaleX = 40 / selection.width;
scaleY = 40 / selection.height;
$('#preview img').css({
width: Math.round(scaleX * 300),
height: Math.round(scaleY * 300),
marginLeft: -Math.round(scaleX * selection.x1),
marginTop: -Math.round(scaleY * selection.y1)
});
$('#x1').val(selection.x1);
$('#y1').val(selection.y1);
$('#x2').val(selection.x2);
$('#y2').val(selection.y2);
$('#w').val(selection.width);
$('#h').val(selection.height);
}
$(function () {
$('#photo').imgAreaSelect({ aspectRatio: '1:1', handles: true,
fadeSpeed: 200, onSelectChange: preview, show: true,x1:0,y1:0, x2:88,y2:88});
});
</script>
</head>
<body>
<h2>Live Example</h2>
<div class="container demo">
<div style="float: left; width: 50%;">
<p class="instructions">
Click and drag on the image to select an area.
</p>
<input type="file" id="upload" onchange="PreviewImage('Preview',this,300,300);" />
<p></p>
<div class="frame" style="margin: 0 0.3em; width: 300px; height: 300px;">
<img id="photo" src="image/flower2.jpg" />
</div>
</div>
<div style="float: left; width: 50%;">
<p style="font-size: 110%; font-weight: bold; padding-left: 0.1em;">
Selection Preview
</p>
<div class="frame"
style="margin: 0 1em; width: 88px; height: 88px;">
<div id="preview1" style="width: 88px; height: 88px; overflow: hidden;">
<img src="image/flower2.jpg" style="width: 88px; height: 88px;" />
</div>
</div>
<br/>
<div class="frame"
style="margin: 0 1em; width: 64px; height: 64px;">
<div id="preview2" style="width: 64px; height: 64px; overflow: hidden;">
<img src="image/flower2.jpg" style="width: 64px; height: 64px;" />
</div>
</div>
<br />
<div class="frame"
style="margin: 0 1em; width: 40px; height: 40px;">
<div id="preview" style="width: 40px; height: 40px; overflow: hidden;">
<img src="image/flower2.jpg" style="width: 40px; height: 40px;" />
</div>
</div>
<br/>
<table style="margin-top: 1em;">
<thead>
<tr>
<th colspan="2" style="font-size: 110%; font-weight: bold; text-align: left; padding-left: 0.1em;">
Coordinates
</th>
<th colspan="2" style="font-size: 110%; font-weight: bold; text-align: left; padding-left: 0.1em;">
Dimensions
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 10%;"><b>X<sub>1</sub>:</b></td>
<td style="width: 30%;"><input type="text" id="x1" value="-" /></td>
<td style="width: 20%;"><b>Width:</b></td>
<td><input type="text" value="-" id="w" /></td>
</tr>
<tr>
<td><b>Y<sub>1</sub>:</b></td>
<td><input type="text" id="y1" value="-" /></td>
<td><b>Height:</b></td>
<td><input type="text" id="h" value="-" /></td>
</tr>
<tr>
<td><b>X<sub>2</sub>:</b></td>
<td><input type="text" id="x2" value="-" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td><b>Y<sub>2</sub>:</b></td>
<td><input type="text" id="y2" value="-" /></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
分享到:
相关推荐
jquery.imgareaselect-0.8.min.js
jquery.imgareaselect-0.9.2封装jquery.imgareaselect-0.9.2封装jquery.imgareaselect-0.9.2封装
这是利用jquery的imgareaselect进行截图的插件,使用代码请看我博客
jquery.imgareaselect-0.9.10图片裁切插件下载,可把上传的图片进行裁剪再保存,在以前来说非常棘手的问题,现在借助jquery的imgareaselect插件再配合PHP的GD库就可以轻松的实现图片裁切功能。注,本插件包内不包括...
jquery.imgareaselect是一个图像上传于裁剪的java代码
关于ImgAreaSelect, 是一jQuery插件,它支持用户通过鼠标拖曳选择图片的一部分,如图片拖曳、图片编辑等。下面通过本文给大家介绍jQuery插件imgAreaSelect基础讲解,需要的的朋友参考下吧
jQuery插件imgAreaSelect 实例代码,自己实践后的代码,很简单的代码,完成了图片上传、剪切的功能,很不错,推荐。
jquery_imgareaselect图片裁切插件使用的中文文档
jquery的imgareaselect插件
jquery imgareaselect截图jquery imgareaselect截图jquery imgareaselect截图jquery imgareaselect截图jquery imgareaselect截图jquery imgareaselect截图
javascript截图 jQuery插件imgAreaSelect用法详解_.docx
利用jquery的imgAreaSelect插件实现图片裁剪示例
基于jquery(imgareaselect)的网页截图插件,完整项目。可在eclipse中直接运行
imgAreaSelect_Demo 从官方的教程做了个
使用JQuery ImgAreaSelect插件实现图片在线剪裁并保存到ASP.NET服务器端实例。
个人网上收集,一共三个: ImgCropper jquery.imgareaselect BitmapCutter 在此给大家分享了!
上一节随笔中,我们已经知道了关于jQuery插件ImgAreaSelect基本的知识;那么现在看一下实例: 首先,要知道我们应该实现什么功能? (1)图片能够实现上传预览功能 (2)拖拽裁剪图片,使其能够显示裁剪后的区域 (3...
主要介绍了avascript截图 jQuery插件imgAreaSelect使用详解,需要的朋友可以参考下
基于jquery.imgareaselect-0.9.10截图上传,包含PHP代码