[thelist] Return Image with Text via PHP?

Eduardo Kienetz eduardok at gmail.com
Mon Nov 19 16:09:36 CST 2007


On Nov 19, 2007 8:52 AM, Stefan Schwarzer <st.schwarzer at geois.de> wrote:
> I thought that this should be a not-to-difficult task, but am somehow
> blocked to get the clue....
>
> Can someone help me out?
>
> I guess I need to have a
>
>         header("Content-type: image/png");
>
> and then include some text, and at the end submit that, no?

Use GD directly:
<?php
  header("Content-type: image/png");
  $im = imagecreate(500, 30);
  $white = imagecolorallocate($im, 255, 255, 255);
  $black = imagecolorallocate($im, 0, 0, 0);

//replace the font path with some you have
  imagettftext($im, 20, 0, 10, 20, $black,
"/usr/share/fonts/TTF/DejaVuSansMono.ttf",
  "Too bad, no data :( ");
  imagepng($im);
  imagedestroy($im);
?>

-- 
Eduardo Bacchi Kienetz
LPI Certified - Level 2
http://www.noticiaslinux.com.br/eduardo/



More information about the thelist mailing list