1
類
寫水印文字我剛剛完成我的課,使圖像如何計算在哪裏我
水位標記的文字在這裏是我的問題
1 - 用戶選擇的字體文件
2 - 用戶選擇字體顏色
3 - 用戶選擇水印位置
4 - 用戶選擇字體大小
所以 - 我的問題是如何計算的正確位置取決於字體大小,家庭
這裏是我的代碼我只是想
`
$寬度= 400; //圖片寬度
$ height = 300; //圖像高度
if($this -> text_posi == 'topleft'){
$x1 = ($width - $width) + 20;
$y1 = ($height - $height) + 40;
}elseif($this -> text_posi == 'topright'){
$x1 = $width - 200;
$y1 = ($height - $height) + 40;
}
elseif($this -> text_posi == 'bottomleft'){
$x1 = ($width - $width) + 20;
$y1 = $height - 30;
}
elseif($this -> text_posi == 'bottomright'){
$x1 = $width - 200;
$y1 = $height - 30;
}
elseif($this -> text_posi == 'topcenter'){
$x1 = $width * .5 - 100;
$y1 = ($height - $height) + 30;
}
elseif($this -> text_posi == 'bottomcenter'){
$x1 = $width * .5 - 100;
$y1 = $height - 30;
}
elseif($this -> text_posi == 'rightcenter'){
$x1 = $width - 180;
$y1 = $height * .5;
}
elseif($this -> text_posi == 'leftcenter'){
$x1 = $width - $width + 20;
$y1 = $height * .5 ;
}else{
$x1 = ($width/2) - 30;
$y1 = ($height/2) - 20 ;
}
`
我認爲這很好,如果圖像大於寬度> = 500和高度> = 500
你能遠離顯示器的幫助,請
謝謝您回答@stereofrog,因此imagettfbbox會爲我提供該字詞的x&y字樣,我將在圖片上寫下,謝謝 – SamarLover