I'm using this function to add text with shadow on a picture:
function addWatermark($image, $text){
// Schriftdatei (TrueType Font)
$fontPath = __DIR__ . "/NotoSansSymbols-Regular.ttf";
// Text und Schriftgröße
$fontSize = 18; // in Punkten
// Farben definieren
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
// Bildgröße
$imageWidth = imagesx($image);
$imageHeight = imagesy($image);
if($imageWidth < 550){
$fontSize = 16;
}
// Textgröße berechnen
$bbox = imagettfbbox($fontSize, 0, $fontPath, $text);
$textWidth = abs($bbox[2] - $bbox[0]);
$textHeight = abs($bbox[7] - $bbox[1]);
// Padding (20% des Bildes)
$paddingY = 10;
$paddingX = 10;
// Obere rechte Position berechnen
$x = $imageWidth - $textWidth - $paddingX;
$y = $paddingY + $textHeight; // Y-Koordinate ist baseline
// Schwarzen Rand dünner zeichnen (nur oben, unten, links, rechts)
imagettftext($image, $fontSize, 0, $x - 1, $y, $black, $fontPath, $text); // links
imagettftext($image, $fontSize, 0, $x + 1, $y, $black, $fontPath, $text); // rechts
imagettftext($image, $fontSize, 0, $x, $y - 1, $black, $fontPath, $text); // oben
imagettftext($image, $fontSize, 0, $x, $y + 1, $black, $fontPath, $text); // unten
// Weißen Text darüber
imagettftext($image, $fontSize, 0, $x, $y, $white, $fontPath, $text);
return $image;
}
I want to add opacity of 70% to the final text, how can I do that?