3

strlogo

strlogo
SYNOPSIS

strlogo($name)

DESCRIPTION

The character font used to write the text is in the file font.ttf at the root of the site.

CODE
  1. function strlogo($name) {
  2.     $waspfile=ROOT_DIR . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'wasp.png';
  3.     $fontfile=ROOT_DIR . DIRECTORY_SEPARATOR . 'font.ttf';
  4.     $fontsize=24.0;
  5.  
  6.     $bbox = imageftbbox($fontsize, 0, $fontfile, $name);
  7.  
  8.     $w=$bbox[2]+48+5;
  9.     $h=40;
  10.  
  11.     $wasp = @imagecreatefrompng($waspfile) or die();
  12.     $img = @imagecreatetruecolor($w, $h) or die();
  13.  
  14.     $bg=imagecolorallocate($img, 255, 255, 255);
  15.     $fg=imagecolorallocate($img, 0x33, 0x33, 0x33);
  16.  
  17.     imagecolortransparent($img, $bg);
  18.     imagefill($img, 0, 0, $bg);
  19.  
  20.     imagettftext($img, $fontsize, 0, 0, 30, $fg, $fontfile, $name);
  21.  
  22.     imagecopy($img, $wasp, $w-48, 0, 0, 0, 48, 48);
  23.  
  24.     return $img;
  25. }

Comments

To add a comment, click here.