I want to draw text in a image, using Imagick and PHP7 (support by Hostgator). I have problem when the text is very long, i don't want to wrapping (new lines), I want to scale width of the text (height is a constant).
Here is a Demo that I want.
![Image](https://i.stack.imgur.com/ovxbQ.jpg)
Please tell me the solution.
My PHP code:
Code: Select all
if(isset($_POST["value1"])){
$image = new Imagick('background.jpg');
$text = $_POST["value1"];
$draw = new ImagickDraw();
$draw->setFont('Arial.ttf');
$draw->setFontSize(25);
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);
$height = $image->getimageheight();
$width = $image->getimagewidth();
$centerX = $width/2;
$centerY = $height/2;
$draw->setFillColor('#fcf59c');
$image->annotateImage($draw, $centerX, $centerY, 0, "This is a long text");
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
}