Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // PHP - Draw an image in memory
- // reference: http://www.php.net/manual/en/ref.image.php
- $im = imagecreate($width, $height);
- // make some colours
- $white = imagecolorallocate($im, 255, 255, 255);
- $black = imagecolorallocate($im, 0, 0, 0);
- // set a background
- imagefill($im, 0, 0, $white);
- $text = 'Something';
- $font_number = 2; // try 2 to start with
- imagestring($im, $font_number, $x, $y, $text, $black);
- // we need somewhere to put the image
- $path = '/public_html/temp/'; // a server path to a temporary directory
- // make a unique number to ensure the image is not cached
- $unique = time();
- $url = $path.$unique.'gif';
- // save the image to the server
- $result = imagegif($im, $url);
- // get the http address for the image
- $url = get_site_url().'/temp/'.$unique.'.gif';
- echo '<img src="'.$url.'" />';
- // release the memory
- imagedestroy($im);
- // NB the temp directory will fill up over time
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement