//保證可以解決!!!?圖片路徑、字體路徑,等??自己?用你自己的?
?//不用去啥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;
}
2017-09-15
//加圖片水印?圖片和水印圖片?,自己試下,就分清了 $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);