Results 1 to 9 of 9

Thread: Nice!!!

  1. #1
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Nice!!!

    What could be sweeter than dynamic image generation? Maybe dynamic flash generation but who's really checking?

  2. #2
    Join Date
    Nov 2002
    Posts
    5,713
    Rep Power
    0

    Default Re:Nice!!!

    Nice indeed, but it can be even nicer if you share the source code. ;D

  3. #3
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default Re:Nice!!!

    itunes for windows ;D. who needs dynamic flash generation anyway?

  4. #4
    Join Date
    Aug 2002
    Posts
    1,257
    Rep Power
    0

  5. #5
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Re:Nice!!!

    Actually tech, it's not a rondom image, it's a dynamically generated image.

    PHP has the ability to output streams other than text hence the ability to output binary data such as images and flash animation. This trick is accomplished by creating a PHP script that outputs an image and then using that script file as the image itself within HTML tags (or YaBB tags as the case may be) in the format <IMG SRC="image.php">.

    The code used to generate the image I'm now using is below:

    Code:
    <?
    $RF = "oneliners.txt";
    if (file_exists($RF))
    {
       $fp = fopen($RF, "r");
       $index = 0;
       while (!feof ($fp)) 
       {
          $lines[$index++] = fgets($fp, 4096);
       }
       fclose($fp);
    }
    
    header ("Content-type: image/png");
    $im = @ImageCreate (500, 30) or die ("No GD image support");
    $background_color = ImageColorAllocate ($im, 255, 255, 255);
    $text_color = ImageColorAllocate ($im, 233, 14, 91);
    
    srand ((double) microtime() * 10000000);
    
    $rand_line = array_rand ($lines, 1);
    
    $String = $lines[$rand_line];
    ImageString ($im, 2, 5, 5,  $String, $text_color);
    ImagePng ($im);
    ?>
    All you need do after this is have a file called "onliners.txt" in the same directory, place it on a server with PHP and GD support and place the file name in your image tag as shown above.



    -Life needs...Openess

  6. #6
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default Re:Nice!!!

    As you can imagine, this ability allows you to do some VERY interesting things:



  7. #7
    Join Date
    Aug 2002
    Posts
    1,257
    Rep Power
    0

    Default Re:Nice!!!

    [me=Tech_Guru]Says "CKnight I'm Gonna Kick you in da Nuts"[/me]

  8. #8
    Join Date
    Nov 2002
    Posts
    5,713
    Rep Power
    0

    Default Re:Nice!!!

    [quote author=CKnight link=board=22;threadid=2146;start=0#msg21149 date=1066933950]
    As you can imagine, this ability allows you to do some VERY interesting things:



    [/quote]

    It seems as if CK is harvesting IP's... What interesting things are you referring to?

  9. #9
    Join Date
    Apr 2003
    Posts
    13,270
    Rep Power
    35

    Default Re:Nice!!!

    You can also do this in ASP.NET. You can draw on an image using asp code. Won't post any code since this is a php forum.

Posting Permissions

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