close

說明

bool imagecopymerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct )

參數說明:
參數 說明
dst_im 目標圖像
src_im 被拷貝的源圖像
dst_x 目標圖像開始 x 坐標
dst_y 目標圖像開始 y 坐標,x,y同為 0 則從左上角開始
src_x 拷貝圖像開始 x 坐標
src_y 拷貝圖像開始 y 坐標,x,y同為 0 則從左上角開始拷貝
src_w (從 src_x 開始)拷貝的寬度
src_h (從 src_y 開始)拷貝的高度
pct 圖像合並程度,取值 0-100 ,當 pct=0 時,實際上什麽也沒做,反之完全合並。
當為 pct = 100 時對於調色板圖像本函數和 imagecopy() 完全一樣,參考閱讀:

該函數的一個典型應用就是將圖像打上水印標識


<?
header("Content-type: image/jpeg");

//原始圖像
$dst = "images/flower_1.jpg";

//得到原始圖片信息
$dst_im = imagecreatefromjpeg($dst);
$dst_info = getimagesize($dst);

//水印圖像
$src = "images/logo.gif";
$src_im = imagecreatefromgif($src);
$src_info = getimagesize($src);

//水印透明度
$alpha = 30;

//合並水印圖片
imagecopymerge($dst_im,$src_im,$dst_info[0]-$src_info[0],$dst_info[1]-$src_info[1],0,0,$src_info[0],
$src_info[1],$alpha);

//輸出合並後水印圖片
imagejpeg($dst_im);
imagedestroy($dst_im);
imagedestroy($src_im);
?>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 stockwfj3 的頭像
    stockwfj3

    程式設計@筆記

    stockwfj3 發表在 痞客邦 留言(0) 人氣()