text2image


 / Published in: PHP
 

Put contents in a file called for example "button.php". instead of using filename.png in the img tag, use button.php?text=buttontext

  1. header("Content-type: image/png");
  2. $string = $_GET['text'];
  3. $im = imagecreatefrompng("images/button.png");
  4. $color = imagecolorallocate($im, 255, 255, 255);
  5. $px = (imagesx($im) - 7.5 * strlen($string)) / 2;
  6. $py = 9;
  7. $fontSize = 1;
  8.  
  9. imagestring($im, fontSize, $px, $py, $string, $color);
  10. imagepng($im);
  11. imagedestroy($im);

Report this snippet  

You need to login to post a comment.