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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.