This script will allow you to use a string and convert to image and rotate to any angle.
How to call
$text = ''Hello World';
$height = (strlen($text)*6.3)+2;
'<img id="testImg" alt="str2Img" src="/imagePng.php?text='.$text.'&height='.$height.'" />';
Place the script below into a page called imagePng.php
<?php
header("Content-type: image/png");
$height = $_GET['height'] == '' ? 400 : $_GET['height'];
//imagecreate(width, height);
$im = imagecreate(20, $height);
$green = imagecolorallocate($im, 0, 255, 0);
$red = imagecolorallocate($im, 255, 0, 0);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// imagefill($im, 0, 0, $white) background to the image
imagefill($im, 0, 0, $white);
// path to font
$font = $_SERVER['DOCUMENT_ROOT'].'/inc/fonts/arial.ttf'; // point to where it can find the True Type Font
$fontSize = 9 ;
$angle = 90;
// imagettftext($im, font size, angle, first point x, first point y, font colour, font family, string);
$text = $_GET['text']; // <img id="testImg" alt="btn" src="imagePng.php?text='.$text.'&height='.$height.'" />
//imagettftext($im, $fontSize, $angle, 15, ($height-5), $green, $font, $text);// if you want a shadow
imagettftext($im, $fontSize, $angle, 16, ($height-4), $black, $font, $text);
imagepng($im);
imagedestroy($im);
?>
Example - Click here