I found an imagemagick convert command here to fit text into a smaller box, namely
convert sea.jpg \( -size 173x50 -background none label:"A" -trim -gravity center -extent 173x50 \) -gravity northwest -geometry +312+66 -composite result.png
I'm trying to replicate this in PHP using the IMagick library However, I can't seem to find a way to add a label? The IMagick LabelImage function doesn't actually add a label on the image but only the metadata.
my current attempt got me so far:
$label = new Imagick();
$label->newImage(173,50,new ImagickPixel('transparent'),"png");
$label->labelImage("Testing 123");
$label->trimImage(0);
$label->setGravity(imagick::GRAVITY_CENTER);
However the labelImage, as said, doesn't actually add anything to the image, so I think I've hit a dead end. What would be a good way to add a label to an image, or in general are there better ways to add text to an image in a shrink-to-fit way in a box using the IMagick library?
Thanks in advance :)