php jcrop 头像截剪

<?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>
 

你可能感兴趣的:(jquery,C++,c,PHP,css)