Jump to content

Image editing, the text wont go on to 2 lins D=


Jragon

Recommended Posts

Hey guys,

 

I have a problem with my quote thing, i have a few long quotes that i want to word wrap

 

My code:

<?php

/**
* @author Jragon
* @copyright 2010
*/

    Header ("Content-type: image/gif");
    $textfile = "quotes.txt";
    $quotes = array();
    if(file_exists($textfile)){
        $quotes = explode("\n",file_get_contents($textfile));
        srand ((float) microtime() * 10000000);
        $string = $quotes[array_rand($quotes)];
        $string= wordwrap($string, 50, "\n", true);
    } else {
        $string = "Sig file non-existant...";
    }
    $font = 3;
    $width = ImageFontWidth($font)* strlen($string);
    $height = ImageFontHeight($font);
    $im = ImageCreate($width,$height);
    $x=imagesx($im)-$width ;
    $y=imagesy($im)-$height;
    $background_color = imagecolorallocate ($im, 242, 242, 242); //white background
    $text_color = imagecolorallocate ($im, 0, 0,0);//black text
    $trans_color = $background_color;//transparent colour
    imagecolortransparent($im, $trans_color);
    imagestring ($im, $font, $x, $y, $string, $text_color);
    imagegif($im);
    ImageDestroy($im);
?>

 

The where the line breake should be there is a strange symbol, also there is a symbol at the end of eatch line.

quote

 

Thanks

 

Jragon

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.