I'm using Imagine together with Zend Framework 2.
I'm looking for a way to add a text in image before save it.
I tried with this :
//create required instances...
$Imagine = new \Imagine\Gd\Imagine();
$Palette = new \Imagine\Image\Palette\RGB();
//Background color of the upcomming image basend on settings passed by user...
$BackgroundColor = $Palette->color('fff', 0);
//...some other code...
$TextColor = $Palette->color('#000', 100);
//create an ImageBox for upcomming image based on given width and height
$ImageBox = new \Imagine\Image\Box(300, 300);
//get center X|Y coordinates for ImageBox
$ImageCenterPosition = new \Imagine\Image\Point\Center($ImageBox);
//create Text Object with font-family, font-size and color from settgins
$TextFont = new \Imagine\Gd\Font( BASE_PATH . "/public/assets/plugins/font-awesome/fonts/fontawesome-webfont.ttf" , 13, $TextColor);
//create a Box (dimensions) based on font and given string...
$TextBox = $TextFont->box( "test texte" );
//get center X|Y coordinates for the box containing the text
$TextCenterPosition = new \Imagine\Image\Point\Center( $TextBox );
//calculate center X|Y coordanates from ImageBox center coordanates and FontBox center coordanates
$CenteredTextPosition = new \Imagine\Image\Point( $ImageCenterPosition->getX() - $TextCenterPosition->getX(), $ImageCenterPosition->getY() - $TextCenterPosition->getY());
//create an image with ImageBox dimensions and BackgroundColor
$_img_ = $Imagine->create($ImageBox, $BackgroundColor);
//now draw the text...
$_img_->draw()->text("test texte 222", $TextFont, $CenteredTextPosition);
$_img_->save($newName);
I hope one of you guys can help out with a solution.