當前位置:首頁 » 編程語言 » php頭像裁剪

php頭像裁剪

發布時間: 2023-02-03 12:41:22

㈠ 能不能給我發一個php上傳頭像裁剪啊 謝謝 兄弟

ResultCode BSTree<T>::Search1(T &x) const
{
BTNode<T> *p = root;
while(p) {
if(x < p -> element) p = p -> lChild;
else if(x > p -> element) p = p -> rChild;
else {
x = p -> element;
return Success;
}
}
return NotPresent;
}

㈡ 怎麼實現php上傳圖片並可以裁剪的功能,類似一些網站的頭像截取,裁剪可以用jcrop插件。高分懸賞

php本身有裁剪圖片的函數,js的截取一般是獲得幾個坐標,供這個函數作為參數,php在圖片上傳到伺服器臨時空間的時候,對圖片進行裁剪,再按編程人的需求保存到指定目錄。

網路下現成的,或者翻翻手冊。

㈢ 急求一個可用的 Thinkphp 頭像剪裁上傳的功能,官網的demo下載鏈接打不開,急急急!!!

美圖秀秀有個這個的插件,挺簡單的你可以試試


自己看

㈣ 為什麼用PHP對上傳圖片進行裁剪的時候,沒成功,而且連上傳的原圖都沒了

加個base64_decode方法試試:
$src = imagecreatefromstring(base64_decode(file_get_contents($src_path)));

㈤ thinkphp3.1頭像剪切上傳怎麼把jquery剪切好的圖片上傳保存到資料庫

canvas
轉成
base64位,然後得到圖片的編碼,然後上傳到資料庫

㈥ php求助圖片縮放裁切問題

這段代碼可以通過自已選擇來決定圖片的大小!

效果圖如下所示:希望對你有幫助!

其中

minSize:[48,48],

setSelect:[0,0,190,190],

是調整選取范圍的大小,若你調整為120和160就改為了

setSelect:[0,0,120,160],

就可以了!

<?php
error_reporting(7);
date_default_timezone_set("Asia/Shanghai");
header("Content-type:text/html;Charset=utf-8");
require_once("./image.class.php");

$images=newImages("file");

if($_GET['act']=='cut'){
$image="0000.jpg";
$res=$images->thumb($image,false,1);
if($res==false){
echo"裁剪失敗";
}elseif(is_array($res)){
echo'<imgsrc="'.$res['big'].'"style="margin:10px;">';
echo'<imgsrc="'.$res['small'].'"style="margin:10px;">';
}elseif(is_string($res)){
echo'<imgsrc="'.$res.'">';
}
}elseif(isset($_GET['act'])&&$_GET['act']=="upload"){

$path=$images->move_uploaded();
$images->thumb($path,false,0); //文件比規定的尺寸大則生成縮略圖,小則保持原樣
if($path==false){
$images->get_errMsg();
}else{
echo"上傳成功!<ahref='".$path."'target='_blank'>查看</a>";
}
}else{
?>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
<metaname="Author"content="SeekEver">
<metaname="Keywords"content="">
<metaname="Description"content="">
<metacontent="text/html;charset=UTF-8"http-equiv="Content-Type">
<scriptsrc="./js/jquery.min.js"type="text/javascript"></script>
<scriptsrc="./js/jquery.Jcrop.js"type="text/javascript"></script>
<linkrel="stylesheet"href="./css/jquery.Jcrop.css"type="text/css"/>
<scripttype="text/javascript">

jQuery(function($){

//Createvariables(inthisscope)toholdtheAPIandimagesize
varjcrop_api,boundx,boundy;

$('#target').Jcrop({
minSize:[48,48],
setSelect:[0,0,190,190],
onChange:updatePreview,
onSelect:updatePreview,
onSelect:updateCoords,
aspectRatio:1
},
function(){
//
varbounds=this.getBounds();
boundx=bounds[0];
boundy=bounds[1];
//StoretheAPIinthejcrop_apivariable
jcrop_api=this;
});
functionupdateCoords(c)
{
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
functioncheckCoords()
{
if(parseInt($('#w').val()))returntrue;
alert('.');
returnfalse;
};
functionupdatePreview(c){
if(parseInt(c.w)>0)
{
varrx=48/c.w; //小頭像預覽Div的大小
varry=48/c.h;

$('#preview').css({
width:Math.round(rx*boundx)+'px',
height:Math.round(ry*boundy)+'px',
marginLeft:'-'+Math.round(rx*c.x)+'px',
marginTop:'-'+Math.round(ry*c.y)+'px'
});
}
{
varrx=199/c.w; //大頭像預覽Div的大小
varry=199/c.h;
$('#preview2').css({
width:Math.round(rx*boundx)+'px',
height:Math.round(ry*boundy)+'px',
marginLeft:'-'+Math.round(rx*c.x)+'px',
marginTop:'-'+Math.round(ry*c.y)+'px'
});
}
};
});

</script>
</head>
<body>
<formmethod="post"action="?act=upload"enctype="multipart/form-data">
<inputtype="file"name="file">
<inputtype="submit"value="上傳">
</form>
<divstyle="float:left;"><imgid="target"src="0000.jpg" ></div>
<divstyle="width:48px;height:48px;margin:10px;overflow:hidden;float:left;"><img style="float:left;"id="preview"src="0000.jpg"></div>
<divstyle="width:190px;height:195px;margin:10px;overflow:hidden;float:left;"><img style="float:left;"id="preview2"src="0000.jpg"></div>
<formaction="index.php?act=cut"method="post"onsubmit="returncheckCoords();">
<inputtype="hidden"id="x"name="x"/>
<inputtype="hidden"id="y"name="y"/>
<inputtype="hidden"id="w"name="w"/>
<inputtype="hidden"id="h"name="h"/>
<inputtype="submit"value="裁剪"/>
</form>
</body>
</html>
<?php
}
?>

㈦ php 上傳頭像預覽裁剪功能怎麼實現 最好有個例子

說下你的信箱,我發給你。

熱點內容
thinkphp緩存關閉 發布:2024-04-26 18:19:32 瀏覽:96
linux信號捕捉 發布:2024-04-26 18:19:27 瀏覽:934
編譯有哪兩種模式 發布:2024-04-26 17:53:30 瀏覽:871
伺服器電腦上能用嗎 發布:2024-04-26 17:44:42 瀏覽:560
組件式編程 發布:2024-04-26 17:19:57 瀏覽:943
電子兒童存錢罐如何改密碼 發布:2024-04-26 17:19:13 瀏覽:601
什麼安卓手機直播投屏好 發布:2024-04-26 17:18:31 瀏覽:627
linuxhba查看 發布:2024-04-26 16:57:28 瀏覽:903
啟動mongodb服務linux 發布:2024-04-26 16:38:37 瀏覽:553
525標軸選裝哪些配置 發布:2024-04-26 16:34:24 瀏覽:849