Answer the question
In order to leave comments, you need to log in
How to quickly embed translucent text into an image in php?
Hello! Such a question - how to quickly embed translucent text at an angle into the picture?
There is such a code:
function textonimage($path) {
$string = "Текстовочка";
$image = imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'].$path);
$color = imagecolorallocatealpha($image, 255, 255, 255, 80);
$box = imagettfbbox(40, 45, '/var/www/includes/modules/arial.ttf', $string);
$left = 490-round(($box[2]-$box[0])/2);
imagettftext($image, 40, -45, $left, 180, $color, '/var/www/includes/modules/arial.ttf', $string);
ob_start();
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$stringdata = ob_get_clean();
return 'data:image/jpeg;base64,' . base64_encode($stringdata);
}
Answer the question
In order to leave comments, you need to log in
So you cache watermarked images and create them when you add images, not when you output. A content editor can tolerate two seconds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question