5 use \Intervention\Image\Image;
20 $draw = new \ImagickDraw();
21 $draw->setStrokeAntialias(
true);
22 $draw->setTextAntialias(
true);
26 $draw->setFont($this->
file);
28 throw new \Intervention\Image\Exception\RuntimeException(
29 "Font file must be provided to apply text to image."
36 $draw->setFontSize($this->
size);
37 $draw->setFillColor(
$color->getPixel());
40 switch (strtolower($this->
align)) {
42 $align = \Imagick::ALIGN_CENTER;
46 $align = \Imagick::ALIGN_RIGHT;
50 $align = \Imagick::ALIGN_LEFT;
54 $draw->setTextAlignment(
$align);
57 if (strtolower($this->
valign) !=
'bottom') {
60 $dimensions = $image->
getCore()->queryFontMetrics($draw, $this->
text);
63 switch (strtolower($this->
valign)) {
66 $posy = $posy + $dimensions[
'textHeight'] * 0.65 / 2;
70 $posy = $posy + $dimensions[
'textHeight'] * 0.65;
76 $image->
getCore()->annotateImage($draw, $posx, $posy, $this->
angle * (-1), $this->
text);