3 class WikiPlugin_text2png
6 var $name = 'text2png';
7 function getDefaultArguments() {
8 return array('text' => 'Hello WikiWorld!');
11 //FIXME: are quotes needed for the argument string text= or no?
12 //FIXME: the next two lines aren't the correct way to extract a text argument for a WikiPlugin
15 return $this->text2png($t);
17 // return sprintf("<tt>%s %s</tt>", $salutation, $name);
20 function text2png($text) {
21 //FIXME: once this accepts a text argument the next line should be removed
22 $text="Hello WikiWorld!";
24 $text or die ("?text string required");
25 $im = @ImageCreate(150, 75) or die ("Cannot Initialize new GD image stream. PHP must be compiled with support for GD 1.6 or later to create png files.");
27 $bg_color = ImageColorAllocate($im, 255, 255, 255);
28 $text_color = ImageColorAllocate($im, 50, 50, 200);
29 $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf";
31 ImageTTFText($im, 10, 0, 10, 30, $text_color, $ttfont, $text);
32 ImageString($im, 2, 10, 40, $text, $text_color);
34 // dump directly to browser:
35 // header("Content-type: image/png");
39 $filename = $text . ".png";
40 $success = ImagePng($im, "../" . $filename);
42 //FIXME: the link generated doesn't work. The image file is dumped in the same directory as index.php
44 $s = "<p>png image saved as <a href=\"/$filename\">$filename</a>.</p>";
46 $s = "<p>Error creating png file.</p>";
57 // c-hanging-comment-ender-p: nil
58 // indent-tabs-mode: nil