text to image formating help

Hello phpusers :slight_smile:

I have the following code that is working great and it creates a image with a random quotes taken from the file quotes.txt file.

I would like to enhance it by formatting the quotes so at the start and end it has a colored quotation mark
a bit like the following that is bigger than the normal text.

[size=14pt]“[/size]Hold fast to your dreams, for without them life is a broken winged bird that cannot fly.[size=14pt]“[/size]

Could any one help me with enhancing my current script

[php]<?php
function ImageStringWrap($image, $font, $x, $y, $text, $color, $maxwidth)
{
$fontwidth = ImageFontWidth($font);
$fontheight = ImageFontHeight($font);

if ($maxwidth != NULL) {
$maxcharsperline = floor($maxwidth / $fontwidth);
$text = wordwrap($text, $maxcharsperline, “\n”, 1);
}

$lines = explode("\n", $text);
while (list($numl, $line) = each($lines)) {
ImageString($image, $font, $x, $y, $line, $color);
$y += $fontheight;
}
}
//
header(“Content-type: image/png”);
$h_array = file(“quotes.txt”);
srand((double) microtime() * 10000000);
$h = array_rand($h_array);

// Calculate vertical position
$im = imagecreatefrompng(“finch.png”);
//change your text color here ( must be the hex value) ex. 255,255,255 would be white
$color = imagecolorallocate($im, 255, 255, 255);

//change your X & y coordinates here to place the text on your image where you want it

$px=90;
$py=30;

ImageStringWrap($im, 5, $px, $py, rtrim($h_array[$h]), $color, 200 );

imagepng($im);
imagedestroy($im);

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service