Results 1 to 3 of 3

Thread: creating several dynamic images with php

  1. #1
    Join Date
    Dec 2008
    Posts
    48
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default creating several dynamic images with php

    hello,

    i am looking for a tutorial/resource/script that would help me create several dynamic images with mysql information on them in php.

    The purpose is to allow members of an online browser game to show their "stats" to other people on forums, etc by the use of signatures.

    Ive found many tutorials regarding GD but they are all used for just one image or temporary image. I wanted to create an image for each member and update it with is stats every X hours.

    If anyone know anything about this, please let me know, cheers!

  2. #2
    Join Date
    Dec 2008
    Posts
    48
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default

    still looking, cheers!

  3. #3
    Join Date
    Apr 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow

    I did this in the way 'The script is the image'

    declare the script-output as image ( png is my favorite)
    (MakePNGCacheFileName is a routine wich you must provide )

    Code:
    $guid="a fantasy string" ;
    
    
    	header("Content-type: image/png");
    				
    	$PNGfile=MakePNGCacheFileName($guid.$theme."X".$sizeid."X") ;
    	
    	header('Content-Disposition: inline; filename="'.basename($PNGfile).'"') ;
    	header("Last-Modified: ".gmdate("D, d M Y 00:00:00")." GMT"); 
    		header("Expires: ".gmdate("D, d M Y 00:01:00", time()+86400)." GMT") ;
    this is followed by a caching instruction to control serverload

    Code:
    if(true) //Cache ON/OFF Control
    		{
        if (is_file($PNGfile)) 
        {
            readfile($PNGfile);
            return(0);
        }
        }
    process the image through the GD-Lib
    and send the image out / save a copy for the cache

    Code:
                    imagepng($image);
    		imagepng($image,$PNGfile);
    		imagedestroy($image);
    If you use time-functions in your MakePNGCacheFileName you can control
    how often the image is calculated.

    The values of $theme and $sizeid wich are passed to my MakePNGCacheFileName function are results of url-parameters wich in your case could be the playername.

    Note that the directory for the image output must be write enabled for the webserver process.

    In my case the cleaning of old images is done by a cron-job

    The script is then embedded in the (HTML) <img> tag: <img src="myscript.php" ...

    Good luck
    Last edited by sxRossi; 04-21-2009 at 07:18 AM. Reason: added HTML-Hint

Bookmarks

Posting Permissions

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