我想向图像添加带有文本阴影的覆盖文本。到目前为止,我已经能够实现这一目标// top text
imagettftext($im, $font_size+2, 0,
$text1_params['centered_start'],
$font_size+$margin,
$black, $font, $text1_params['text']
);
imagettftext($im, $font_size, 0,
$text1_params['centered_start'],
$font_size+$margin,
$white, $font, $text1_params['text']
);
// bottom text
imagettftext($im, $font_size, 0,
$text2_params['centered_start'] ,
$image_height-$text2_params['height']+$font_size+$margin,
$black, $font, $text2_params['text']
);
imagettftext($im, $font_size, 0,
$text2_params['centered_start']-2,
$image_height-$text2_params['height']+$font_size+$margin-2,
$white, $font, $text2_params['text']
);
这是结果的样子-
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS94OWtoRy5qcGcifQ==” alt =“在此处输入图像描述”>但我希望它看起来像这样(注意两个文本阴影之间的细微差别)-
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9SWDlacC5qcGcifQ==” alt =“在此处输入图像描述”>
一种怪异的方法是将黑色文本呈现8次。第一次偏移到左上角,然后是顶部中心,然后是右上角,然后是左侧,依此类推。它可能会在某些地方留下轮廓缺失的像素,但可能不会引起注意。