Php 如何计算在我的课堂上写水印文本的位置
我刚完成我的课程,在图像上制作水印文本 这是我的问题 1-用户选择字体文件 2-用户选择字体颜色 3-用户选择水印位置 4-用户选择字体大小 因此,我的问题是如何根据字体大小、字体系列计算正确的位置 这是我刚试过的代码 ` $width=400//图像宽度 $height=300//像高Php 如何计算在我的课堂上写水印文本的位置,php,watermark,Php,Watermark,我刚完成我的课程,在图像上制作水印文本 这是我的问题 1-用户选择字体文件 2-用户选择字体颜色 3-用户选择水印位置 4-用户选择字体大小 因此,我的问题是如何根据字体大小、字体系列计算正确的位置 这是我刚试过的代码 ` $width=400//图像宽度 $height=300//像高 if($this -> text_posi == 'topleft'){ $x1 = ($width - $width )
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,就可以了
请你离开显示器,拿一支铅笔和一张纸,画一些图片,好吗
watermark in the bottom-right corner
img_width
|----------- -----------------|<--|
| | |
| | |
| | |
| | |
| | | mark Y offset
img_height | | |
| | |
| | |
| | |
| mark_width | |
| |-------------|<--|
| | |
| mark_height | |
| | |
|-----------------------------|
^ ^
|_______________|
mark X offset
右下角的水印
img_宽度
|---------------------------|离开显示器,拿起一支铅笔和一张纸,画一些图片:
watermark in the bottom-right corner
img_width
|----------- -----------------|<--|
| | |
| | |
| | |
| | |
| | | mark Y offset
img_height | | |
| | |
| | |
| | |
| mark_width | |
| |-------------|<--|
| | |
| mark_height | |
| | |
|-----------------------------|
^ ^
|_______________|
mark X offset
右下角的水印
img_宽度
|------------------------------谢谢你回答@stereofrog,所以imagettfbbox给我我将在图片上写的单词的x&y,谢谢你谢谢你回答@stereofrog,所以imagettfbbox给我将在图片上写的单词的x&y,谢谢