Share Pastebin
Guest
Public paste!

vkrmsv

By: a guest | Sep 19th, 2008 | Syntax: PHP | Size: 1.14 KB | Hits: 42 | Expires: Never
Copy text to clipboard
  1. <?php
  2.  
  3. function convert_text_image($text_input)
  4. {
  5. $my_img = imagecreate( 290, 18 );
  6. $background = imagecolorallocate( $my_img, 255, 255, 255 );
  7. $text_colour = imagecolorallocate( $my_img, 0, 0, 0 );
  8. imagestring( $my_img, 4, 0, 0, $text_input,$text_colour );
  9. ob_start(); // This prevents the imagegif function from outputting to the browser.                                                            
  10. imagegif($my_img);
  11. $img_out = ob_get_contents(); // This gets the raw data of the image.                                                                        
  12. ob_end_clean(); // Clear all output till now                                                                                                  
  13.  $img_out = chunk_split(base64_encode($img_out)); // Encodes the data so that we can display this as a raw image on the browser.              
  14. $string = "\"data: image/gif;base64,".$img_out."\"";
  15. echo "<img src=$string />";
  16.  imagedestroy( $my_img ); //Free resources.                                                                                                  
  17. }
  18.  
  19.  
  20. $text = "example@example.com";
  21. convert_text_image($text);
  22.  
  23. ?>