Subscribe to Developer OraclesNews FeedSubscribe to Developer OraclesComments — Translate page:        

Vertical text with Imagick

October 14, 2008
Filed under IMagick

Creating 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.

Share or Bookmark this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Ask
  • Bloglines
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Slashdot
  • SphereIt
  • Technorati

Possible related posts (automatic):

Related posts brought to you by Yet Another Related Posts Plugin.

Comments

2 Comments on " Vertical text with Imagick "

  1. playerone on Tue, 9th Dec 2008 12:24 am  

    what if I want to add a border to that text ?

  2. 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.

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

If you want to use your OpenID, fill out the field labeled "Website" with the OpenID URL. The other fields may remain empty.

Subscribe without commenting