PHP 网站照片截图 <input type="file" name="myphoto" /> 自动找你照片本地路径$mysqlphoto=addslashes(fread(fopen($myphoto,"r"),$myphotosize)); 把这个放到数据库的字段中对于截取其中一部分,我不清楚了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 截取函数也很简单.js部设置个层,获取截取部分的坐标.将坐标提交到后台.用gd库来处理.然后保存到mysql数据库. 同意楼上的,前台用javascript 获得坐标的四个点,在后台提交的时候根据四个点来用gd截取图片 比较有难度,我看DZ,是FLASH做的 2 楼的兄弟能否 给下具体的js 代码(最好后台PHP也给下) 谢谢拉 就是前台的JS 我不会写 我给你再加份 自己整合一下吧,呵呵,直接拿来是不能用的,你得修改一下.可以结帖了.CSDN的前台部分,用的是prototype<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head><title> 裁减头像 - CSDN个人空间</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="Content-Language" content="zh-CN" /> <script src="js/prototype.js" type="text/javascript"></script> <script src="js/scriptaculous.js?load=builder,effects,dragdrop" type="text/javascript"></script> <script src="js/ImageCropper/cropper.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> var x1; var y1; var width; var height; document.onkeydown = function(e) { if (e ? e.which : event.keyCode == 13) { crop(); } } function onEndCrop( coords, dimensions ) { x1 = coords.x1; y1 = coords.y1; width = dimensions.width; height = dimensions.height; } Event.observe( window, 'load', function() { new Cropper.ImgWithPreview( 'tempPicture', { minWidth: 100, minHeight: 100, ratioDim: { x: 100, y: 100 }, displayOnInit: true, onEndCrop: onEndCrop, previewWrap: 'previewArea' } ) } ); function closeWindow() { window.opener.openWindowUnload(); window.close(); } function crop() { if (!$('cropButton').disabled) { $('cropButton').disabled = true; $('cropButton').value = '正在裁减图片,请稍候...'; var opt={ method:'post', parameters:{x1: x1, y1: y1, width: width, height: height}, onSuccess: function(){ closeWindow(); }, onFailure: function() { alert('裁减图片错误'); $('cropButton').value = '裁减'; $('cropButton').disabled = false; } } new Ajax.Request('CropPicture.aspx', opt); } } function resize() { var w = $('tempPicture').offsetWidth + 170; var h = $('tempPicture').offsetHeight + 173; var x = (screen.width-w)/2; var y = (screen.height-h)/2; self.moveTo(x, y); self.resizeTo(w, h); } </script> <style type="text/css"> *{margin:0;padding:0;} .exprt_noticeboxstysmall{background:url(images/croppicture_bg.gif) repeat-x;font:normal 12px verdana,sans-serif;margin:5px;border:1px solid #f60;} .exprt_noticeboxstysmall h3{font-size:14px;color:#FFF;line-height:28px;text-indent:0.5em;} .exprt_noticeboxstysmall h4{font-size:12px;color:#000;padding:0.5em 0.5em 0;} .exprt_noticeboxstysmall p{color:#f00;padding:0.5em;} .exprt_noticeboxstysmall input{border:1px solid #000;margin:0 6px 0 0;font:normal 12px Tahoma,sans-serif;} #image { float: left; margin: 10px 0 10px 10px; display:inline; } #previewArea { margin: 20px 0 0 20px; float: left; } #buttons { clear: both; margin-left: 10px; margin-bottom: 10px; } </style></head><body onload="javascript:resize();"> <form name="form1" method="post" action="CropPicture.aspx?t=3084" id="form1"><div><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjAxNTc3MDgzOWRkKY8ohS2j+S5LF8cBa/1DEh76fjk=" /></div> <div class="exprt_noticeboxstysmall"> <h3>裁减头像</h3> <div id="image"> <img src="ShowTempPicture.aspx?t=1133" alt="" id="tempPicture" /> </div> <div id="previewArea"></div> <div id="buttons"> <input id="cropButton" type="button" value="裁减" onclick="javascript:crop();" /> <input type="button" value="取消" onclick="javascript:window.close();" /> </div> </div> </form></body></html>后台部分就是用gd库操作header("Content-type: image/jpeg");$imgName = $_GET['image'];$startingW = $_GET['startingW'];$width = $_GET['width'];$startingH = $_GET['startingH'];$height = $_GET['height'];$imgName = "test.jpg";$startingW = 300;$startingH = 300;$width= 400;$height = 400;$im = imagecreatefromjpeg($imgName);$im1 = imagecreatetruecolor($width, $height);//imagecopy($im1, $im, 0, 0, $startingW, $startingH, $width, $height);imagecopyresampled($im1, $im, 0, 0, $startingW, $startingH, $width, $height, $width, $height);imagejpeg($im1);imagedestroy($im);imagedestroy($im1); http://download.csdn.net/source/724007给你一个完整的吧,这是使用JavaScript和php完成的,是我根据cloudgamer 改写的php后台切割图片。是采用的php完成的。http://download.csdn.net/source/724007 php生成sitemap的案例 关于外联表的问题,求教。 关于:array_walk_recursive PHPMYadmin 打开是空白页 问一个广告投放的功能实现。语言不限,我只看思路 php函数 escape,unescape,unicodeToUtf8....请大家测试。 如何使用Php中的exec()函数 求大神帮实现购物车商品相同问题 使用Smarty出错,请求解决,捣鼓几天了! php新手, 最近用php写正则匹配 遇到了一个问题 高分请教php输出html! 看到一好文章 跟大家分享!
js部设置个层,获取截取部分的坐标.
将坐标提交到后台.
用gd库来处理.
然后保存到mysql数据库.
能否
给下具体的js 代码(最好后台PHP也给下)
谢谢拉
就是前台的JS 我不会写
我给你再加份
<head><title>
裁减头像 - CSDN个人空间
</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta http-equiv="Content-Language" content="zh-CN" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=builder,effects,dragdrop" type="text/javascript"></script>
<script src="js/ImageCropper/cropper.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
var x1;
var y1;
var width;
var height; document.onkeydown = function(e) {
if (e ? e.which : event.keyCode == 13) {
crop();
}
} function onEndCrop( coords, dimensions ) {
x1 = coords.x1;
y1 = coords.y1;
width = dimensions.width;
height = dimensions.height;
}
Event.observe(
window,
'load',
function() {
new Cropper.ImgWithPreview(
'tempPicture',
{
minWidth: 100,
minHeight: 100,
ratioDim: { x: 100, y: 100 },
displayOnInit: true,
onEndCrop: onEndCrop,
previewWrap: 'previewArea'
}
)
}
);
function closeWindow()
{
window.opener.openWindowUnload();
window.close();
}
function crop()
{
if (!$('cropButton').disabled)
{
$('cropButton').disabled = true;
$('cropButton').value = '正在裁减图片,请稍候...';
var opt={
method:'post',
parameters:{x1: x1, y1: y1, width: width, height: height},
onSuccess: function(){ closeWindow(); },
onFailure: function() {
alert('裁减图片错误');
$('cropButton').value = '裁减';
$('cropButton').disabled = false;
}
}
new Ajax.Request('CropPicture.aspx', opt);
}
}
function resize()
{
var w = $('tempPicture').offsetWidth + 170;
var h = $('tempPicture').offsetHeight + 173;
var x = (screen.width-w)/2;
var y = (screen.height-h)/2;
self.moveTo(x, y);
self.resizeTo(w, h);
}
</script>
<style type="text/css">
*{margin:0;padding:0;}
.exprt_noticeboxstysmall{background:url(images/croppicture_bg.gif) repeat-x;font:normal 12px verdana,sans-serif;margin:5px;border:1px solid #f60;}
.exprt_noticeboxstysmall h3{font-size:14px;color:#FFF;line-height:28px;text-indent:0.5em;}
.exprt_noticeboxstysmall h4{font-size:12px;color:#000;padding:0.5em 0.5em 0;}
.exprt_noticeboxstysmall p{color:#f00;padding:0.5em;}
.exprt_noticeboxstysmall input{border:1px solid #000;margin:0 6px 0 0;font:normal 12px Tahoma,sans-serif;}
#image {
float: left;
margin: 10px 0 10px 10px;
display:inline;
}
#previewArea {
margin: 20px 0 0 20px;
float: left;
}
#buttons {
clear: both;
margin-left: 10px;
margin-bottom: 10px;
}
</style>
</head>
<body onload="javascript:resize();">
<form name="form1" method="post" action="CropPicture.aspx?t=3084" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjAxNTc3MDgzOWRkKY8ohS2j+S5LF8cBa/1DEh76fjk=" />
</div> <div class="exprt_noticeboxstysmall">
<h3>裁减头像</h3>
<div id="image">
<img src="ShowTempPicture.aspx?t=1133" alt="" id="tempPicture" />
</div>
<div id="previewArea"></div>
<div id="buttons">
<input id="cropButton" type="button" value="裁减" onclick="javascript:crop();" />
<input type="button" value="取消" onclick="javascript:window.close();" />
</div>
</div>
</form>
</body>
</html>
后台部分就是用gd库操作header("Content-type: image/jpeg");
$imgName = $_GET['image'];
$startingW = $_GET['startingW'];
$width = $_GET['width'];
$startingH = $_GET['startingH'];
$height = $_GET['height'];
$imgName = "test.jpg";
$startingW = 300;
$startingH = 300;
$width= 400;
$height = 400;
$im = imagecreatefromjpeg($imgName);
$im1 = imagecreatetruecolor($width, $height);
//imagecopy($im1, $im, 0, 0, $startingW, $startingH, $width, $height);
imagecopyresampled($im1, $im, 0, 0, $startingW, $startingH, $width, $height, $width, $height);
imagejpeg($im1);
imagedestroy($im);
imagedestroy($im1);
给你一个完整的吧,这是使用JavaScript和php完成的,是我根据cloudgamer 改写的php后台切割图片。是采用的php完成的。http://download.csdn.net/source/724007