October 14, 2008 5:31 pm GMT
Vertical text with Imagick
by Gary IllyesCreating vertical text over an image is extremely simple with Imagick. The text created with Imagick can be used for example as a watermark over an image or any other thing you can think of.
It’s very important to understand that the created object is just an image and that you can not have any text before the below code block and which will be sent to browser output. This includes white-space, page brake or any type of text.
The vertical text is obtained with annotateImage() since it’s 4th parameter of the function is to set the degree of the text. 0 degrees is horizontal text, 90 degrees is vertical text, that simple.
Let’s see the code:
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'white' );
$image->newImage(25, 150, $pixel);
$draw->setFontSize( 20 );
$image->annotateImage($draw, 0, 0, 90, 'Devoracles.com');
$image->setImageFormat('png');
header('Content-type: image/png');
echo $image;
The above’s result is what you see below.
As you see it’s extremely simple to create vertical text with Imagick, either if you’re a novice or a pro.
If you have any related question, feel free to ask.
















playerone on Tue, 9th Dec 2008 12:24 am
what if I want to add a border to that text ?
methode on Tue, 9th Dec 2008 6:49 am
Hi,
You mean, the characters or the image?
If the latter:
There’s a function named borderimage() you can use to add a border to the image.
The usage is the following:
$imagick->borderImage( $color, $width, $height );
It’s an imagick native function, so you have to use on the Imagick class.
If the characters, I have to think about it a bit. Will come up with something later today.