jcrop php 头像裁剪,php jcrop 头像截剪

这是一个关于使用Jcrop jQuery插件进行图片裁剪的示例脚本。当提交表单时,脚本会创建一个200x200像素的缩略图,并可以进一步制作多个不同尺寸的副本。用户在前端选择裁剪区域后,服务器端脚本将处理裁剪操作。
摘要由CSDN通过智能技术生成

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:

?>

$(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;

};

Jcrop - Crop Behavior

jcrop.jpg

An example server-side crop script. Hidden form values

are set when a selection is made. If you press the Crop Image

button, the form will be submitted and a 150x150 thumbnail will be

dumped to the browser. Try it!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值