<?php
include("../common/common.php");
include("../common/file.php");
/**
* Jcrop image cropping plugin for jQuery
* Example cropping script
* @copyright 2008 Kelly Hallman
* More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$targ_w = $targ_h = 200;
$src = 'jcrop.jpg';
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
$targ_w,$targ_h,$_POST['w'],$_POST['h']);
$fileName = $_SC['webpath'].'/images/test/jcrop.jpg';
//header('Content-type: image/jpeg');
$webroot = $_SC['webpath'].'/images/test/t0.jpg';
imagejpeg($dst_r,$webroot,100);
$destArr = array($_SC['webpath'].'/images/test/t1.jpg',$_SC['webpath'].'/images/test/t2.jpg');
$wtArr = array(array(100,100),array(50,50));
if(file_exists($webroot)){
echo "正在截剪";
makeThumb($webroot,$destArr,$wtArr);
}else{
echo "没有文件".$webroot;
}
exit;
}
// If not a POST request, display page below:
?><html>
<head>
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.Jcrop.min.js"></script>
<link rel="stylesheet" href="jcrop.css" type="text/css" />
<link rel="stylesheet" href="jquery.Jcrop.css" type="text/css" />
<script language="Javascript">
$(function(){
$('#cropbox').Jcrop({
aspectRatio: 1,
onSelect: updateCoords,
setSelect: [100,100,300,300],
minSize:[200,200],
addClass: 'custom',
bgColor: 'yellow',
bgOpacity: .8,
sideHandles: false
});
});
function updateCoords(c)
{
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
function checkCoords()
{
if (parseInt($('#w').val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
</script>
</head>
<body>
<div id="outer">
<div class="jcExample">
<div class="article">
<h1>Jcrop - Crop Behavior</h1>
<!-- This is the image we're attaching Jcrop to -->
<img src="jcrop.jpg" id="cropbox" />
<!-- This is the form that our event handler fills -->
<form action="jcrop.php" method="post" onsubmit="return checkCoords();">
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="submit" value="Crop Image" />
</form>
<p>
<b>An example server-side crop script.</b> Hidden form values
are set when a selection is made. If you press the <i>Crop Image</i>
button, the form will be submitted and a 150x150 thumbnail will be
dumped to the browser. Try it!
</p>
<div id="dl_links">
<a href="http://deepliquid.com/content/Jcrop.html">Jcrop Home</a> |
<a href="http://deepliquid.com/content/Jcrop_Manual.html">Manual (Docs)</a>
</div>
</div>
</div>
</div>
</body>
</html>
分享到:
相关推荐
PHP+jQuery+jCrop裁剪头像 处理图片
Jcrop+uploadify+php实现上传头像预览裁剪
NULL 博文链接:https://duchengjiu.iteye.com/blog/1798061
一个头像上传的实现,结合了php+jcrop+ajaxfileupload
PHP实例开发源码—PHP+ajaxfileupload+jcrop插件完美实现头像上传剪裁.zip
jquery头像截取jcropjquery头像截取jcropjquery头像截取jcrop
这个Demo选择整合了jcrop的截取图片插件, 上传图片还是使用file表单提交,php后台处理截图保存。
PHP+Jcrop+artDialog头像上传
在做项目的时候,经常需要一些会员系统相关的内容,比如头像的上传与裁剪等等,下面将这块内容分享给大家
好用的头像裁剪拖动插件,PHP后台处理代码,通过js判断位置进行裁剪
这个demo可以看做是一个头像上传的例子,实现了头像上传的大体流程,当然直接拿去就用可能不太现实,这只是一个demo,代码中的上传功能是用PHP实现的,所以这个例子需要在PHP环境下运行,刚刚学习,轻喷
用PHP JQUERY并使用了jcrop,uploadfiy制作的头像上传插件。有图片裁剪,图片尺寸过大时自动改变大小等功能.
jquery.Jcrop实现图片选取裁剪上传,包含php服务端源码
在后台要进行放大处理:将切面放大N倍,N=原图/前台展示的头像。 即 X = X原图宽/前图宽, Y = Y原图高/前, 图高, W = W原图宽/前图宽, H = H原图高/前图高。 基本options参数设置: 名称 默认值 说明 allowSelect ...
shearphoto1.2-头像截取,切图插件.rar,秒杀富头像和JCROP
但是今天介绍的一款专用于图片裁切的插件jquery.Jcrop.min.js就将揭开图片剪切的神秘面纱。使用这个插件可以很方便的实现这一功能,使用时仅需鼠标在图片上圈选出选区,即可把图片裁切成所选部分,非常适合用于头像...
在后台要进行放大处理:将切面放大N倍,N=原图/前台展示的头像。 即 X = X原图宽/前图宽, Y = Y原图高/前, 图高, W = W原图宽/前图宽, H = H原图高/前图高。 基本options参数设置: 名称 默认值 说明 allowSelect ...