title: Create transparent png with text from scratch in php
body: <p>All the examples I've found on the web seem to create pngs with text from an existing png. Is it possible to create a transparent png from scratch and then add text?</p>
  
  <p>The code ive got so far follows (but it doesnt work. just outputs a blank image source)</p>
  
  <pre><code>&lt;?php
      $width = 150;
      $height = 30;
      $text = "My Text";
      $fontsize = 5;
  
      $im = imagecreate($width, $height);
      $transcolor = imagecolortransparent($im);
  
      imagestring($im, $fontsize, 0, 0, $text, $transcolor);
  
      header('Content-type: image/png');
      imagepng($im);
      imagedestroy($im);
  ?&gt;
  </code></pre>