亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

圖片加水印,報錯的解決方法

//保證可以解決!!!?圖片路徑、字體路徑,等??自己?用你自己的?
?//不用去啥bom頭,和加?ob_clean();有的加了這句,也不一定管用
$dst_path?=?"des_big.jpg";
//創建圖片的實例
$dst?=?imagecreatefromstring(file_get_contents($dst_path));

//打上文字
$font?=?'../FONTS/MSYH.TTF';//字體路徑

$color?=?imagecolorallocate($dst,?0x00,?0x00,?0x00);//字體顏色
imagefttext($dst,?13,?0,?20,?20,?$color,?$font,?'快樂編程');
//輸出圖片
list($dst_w,?$dst_h,?$dst_type)?=?getimagesize($dst_path);
switch?($dst_type)?{
????case?1://GIF
????????header('Content-Type:?image/gif');
????????imagegif($dst);
????????break;
????case?2://JPG
????????header('Content-Type:?image/jpeg');
????????imagejpeg($dst);
????????break;
????case?3://PNG
????????header('Content-Type:?image/png');
????????imagepng($dst);
????????break;
????default:
????????break;
}


正在回答

1 回答

//加圖片水印?圖片和水印圖片?,自己試下,就分清了

$groundImg?=?"des_big.jpg";
$groundInfo?=?getimagesize($groundImg);
$ground_w?=?$groundInfo[0];
//print_r($groundInfo);
$ground_h?=?$groundInfo[1];
switch($groundInfo[2]){
case?1:
$ground_im?=?imagecreatefromgif($groundImg);
break;
case?2:
$ground_im?=?imagecreatefromjpeg($groundImg);
break;
case?3:
$ground_im?=?imagecreatefrompng($groundImg);
break;
}

$waterImg?=?"../images/logo.jpg";
$imgInfo?=getimagesize($waterImg);
$water_w?=?$imgInfo[0];
$water_h?=?$imgInfo[1];

switch($imgInfo[2]){
case?1:
$water_im?=?imagecreatefromgif($waterImg);
break;
case?2:
$water_im?=?imagecreatefromjpeg($waterImg);
break;
case?3:
$water_im?=?imagecreatefrompng($waterImg);
break;
}
//?imagecopy($ground_im,$water_im,100,100,0,0,500,500);
imagecopymerge($ground_im,?$water_im,?0,0,0,0,?$water_w,?$water_h,30);
header("Content-type:?image/jpeg");

imagejpeg($ground_im);

http://img1.sycdn.imooc.com//59bba20a0001d3af02680342.jpg

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
手把手教你實現電商網站后臺開發
  • 參與學習       117248    人
  • 解答問題       2101    個

手把手教你用PHP搭建電子商務平臺,由淺入深教你搭建電商系統

進入課程

圖片加水印,報錯的解決方法

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號