/** * Applies the effect. */ public function apply() { /* Determine placement on image */ switch ($this->_params['valign']) { case 'bottom': $v = 'south'; break; case 'center': $v = 'center'; break; default: $v = 'north'; } switch ($this->_params['halign']) { case 'right': $h = 'east'; break; case 'center': $h = 'center'; break; default: $h = 'west'; } if ($v == 'center' && $h != 'center' || $v == 'center' && $h == 'center') { $gravity = $h; } elseif ($h == 'center' && $v != 'center') { $gravity = $v; } else { $gravity = $v . $h; } /* Determine font point size */ $point = Horde_Image::getFontSize($this->_params['fontsize']); //@TODO: throw new Horde_Image_Exception('Not Yet Implemented.'); }
/** * Applies the effect. */ public function apply() { /* Determine placement on image */ switch ($this->_params['valign']) { case 'bottom': $v = 'south'; break; case 'center': $v = 'center'; break; default: $v = 'north'; } switch ($this->_params['halign']) { case 'right': $h = 'east'; break; case 'center': $h = 'center'; break; default: $h = 'west'; } if ($v == 'center' && $h != 'center' || $v == 'center' && $h == 'center') { $gravity = $h; } elseif ($h == 'center' && $v != 'center') { $gravity = $v; } else { $gravity = $v . $h; } /* Determine font point size */ $point = Horde_Image::getFontSize($this->_params['fontsize']); $this->_image->raw(); $this->_image->addPostSrcOperation(' -font ' . $this->_params['font'] . ' -pointsize ' . $point . ' \\( +clone -resize 1x1 -fx 1-intensity -threshold 50% -scale 32x32 -write mpr:color +delete \\) -tile mpr:color -gravity ' . $gravity . ' -annotate +20+10 "' . $this->_params['text'] . '"'); $this->_image->raw(); }
/** * Draws a text string on the image in a specified location, with the * specified style information. * * @TODO: Need to differentiate between the stroke (border) and the fill * color, but this is a BC break, since we were just not providing a * border. * * @param string $text The text to draw. * @param integer $x The left x coordinate of the start of the * text string. * @param integer $y The top y coordinate of the start of the text * string. * @param string $font The font identifier you want to use for the * text. * @param string $color The color that you want the text displayed in. * @param integer $direction An integer that specifies the orientation of * the text. * @param string $fontsize Size of the font (small, medium, large, giant) */ public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small') { $string = addslashes('"' . $string . '"'); $fontsize = Horde_Image::getFontSize($fontsize); $this->_postSrcOperations[] = "-fill {$color} " . (!empty($font) ? "-font {$font}" : '') . " -pointsize {$fontsize} -gravity northwest -draw \"text {$x},{$y} {$string}\" -fill none"; }
/** * Draws a text string on the image in a specified location, with * the specified style information. * * @TODO: Need to differentiate between the stroke (border) and the fill color, * but this is a BC break, since we were just not providing a border. * * @param string $text The text to draw. * @param integer $x The left x coordinate of the start of the text string. * @param integer $y The top y coordinate of the start of the text string. * @param string $font The font identifier you want to use for the text. * @param string $color The color that you want the text displayed in. * @param integer $direction An integer that specifies the orientation of the text. * @param string $fontsize Size of the font (small, medium, large, giant) */ public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small') { $fontsize = Horde_Image::getFontSize($fontsize); $pixel = new ImagickPixel($color); $draw = new ImagickDraw(); $draw->setFillColor($pixel); if (!empty($font)) { $draw->setFont($font); } $draw->setFontSize($fontsize); $draw->setGravity(Imagick::GRAVITY_NORTHWEST); try { $res = $this->_imagick->annotateImage($draw, $x, $y, $direction, $string); } catch (ImagickException $e) { throw new Horde_Image_Exception($e); } $draw->destroy(); }