Results 1 to 12 of 12

Thread: Can someone put me in the right direction?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Can someone put me in the right direction?

    I want to know how these image generators work.

    I can input some text and it will generate an image which will include my text ON the image...


    here is an example:
    http://txt2pic.com/signs/books/dummi...tag=&time=2320

    how is this done in PHP? how can I do it?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    anyone?
    Last edited by erbio; Jul 28th, 2007 at 04:04 AM.
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Can someone put me in the right direction?

    Have a look at the Image Functions and please don't bump your threads.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    Ok I've gotten pretty far but I am now very stuck, I've tried my hardest to figure it out.

    It says cannot modify header information or already set. What I'm trying to do is pull random quotes from my database, I can display random quotes by TEXT with echo but cant seem to get them to work with my image code below:

    PHP Code:
    <?php
    // Set the content-type
    header("Content-type: image/gif");

    $fontsize 15;
    if(@
    $_GET['fontsize']) {
        
    $fontsize $_GET['fontsize'];
    }
    $font 'times.ttf';
    $domain GetHostByName($REMOTE_ADDR);
    $text = @$_GET['text'];// . "" . $domain;

    // Create the image
    $size imagettfbbox($fontsize0$font$text);
    $width $size[2] + $size[0] + 8;
    $height abs($size[1]) + abs($size[7]);

    $im imagecreate($width$height);

    $colourBlack imagecolorallocate($im255255255);
    imagecolortransparent($im$colourBlack);

    // Create some colors
    $white imagecolorallocate($im255255255);
    $black imagecolorallocate($im000);

    // Add the text
    imagefttext($im$fontsize00abs($size[5]), $black$font$text);

    // Using imagepng() results in clearer text compared with
    imagegif($im);
    imagedestroy($im);
    ?>

    Both codes work how I want them to when they are separate. What's going on here?!


    The code freaks out when I add this:
    PHP Code:
    <?php
    header
    ("Content-type: image/gif");
    mysql_connect("SERVER""USERNAME""PASSWORD") or die(mysql_error());
    mysql_select_db("Servic4_msr") or die(mysql_error());
    ?>

    <?php
    $query 
    "SELECT * FROM quotes ORDER BY RAND()LIMIT 1"
    $result mysql_query($query) or die(mysql_error());
    while(
    $row mysql_fetch_array($result)){
    $line $row['lines'];
    }

    ?>
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    and while I'm at it, how do I make a new line with this? It all goes on one line no matter what I try.

    (im trying my hardest, I swear!) thanks
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    Okay, nevermind about the newline, slash n didn't work the first time, I got it now.

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Can someone put me in the right direction?

    What's the exact error message?

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    As I said in my third reply, It says cannot modify header information or already set. - When I try to put both codes within one php file.

    PHP Code:
    WarningCannot modify header information headers already sent by (output started at D:\hshome\servicep\site.com\msr\image.php:2in D:\hshome\servicep\site.com\msr\image.php on line 18 
    Line 18 contains: header("Content-type: image/gif");


    and thanks for un-closing my thread.
    Last edited by erbio; Jul 30th, 2007 at 12:30 PM.

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Can someone put me in the right direction?

    You need to ensure there i no output or white space before you call the header function.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    EDIT - wait, it works now!


    I can't believe WHITE SPACE (or empty lines) effect the header. LOL?)

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: Can someone put me in the right direction?

    Lets say one of my quotes is more than 50 chars long
    how can I insert a new line break (/n)
    after every 50 chars
    i dont want it to stretch forum pages.

    http://www.erbio.com/msr/image.php (my sig)
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Can someone put me in the right direction?

    You could use the wordwrap() function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width