Forum: Geek Forum
Topic: PHP4 Graphics
started by: psychopharmacologist

Posted by psychopharmacologist on Jul. 19 2001,19:51
Does PHP4 generate Graphics on the fly?

I got the following code from a tutorial at freeskills.com

$image = ImageCreate(200,150);
$gray =ImageColorAllocate($image,204,204,204);
ImageLine($image, 10,10, 150,30, $blue);

However when i try to run the script, php sez that none of the functions exist. And I'm pretty sure that php is installed and working fine, I've gotten it to do basic text stuff.
btw, i'm running this on a win98 machine, w/apache. so i'm using localhost to test everything.
So does anyone know if those functions actualy exist, or am I doing something wrong?


Posted by incubus on Jul. 19 2001,20:15
are you sure you dont need modules or something?

a bit like mrtg uses the gd module to make graphs and stuff?


Posted by cr0bar on Jul. 19 2001,21:28
It's exactly that. You need to get gd and compile PHP --with-gd
Posted by RenegadeSnark on Jul. 19 2001,21:30
Or you could shell to the program "convert" from ImageMagick and do it like a real l33t hax0r does it.



Posted by psychopharmacologist on Jul. 20 2001,01:30
ahh, that makes sense... thanx.

Not to seem helpless or anything, but where might i get this magical module?


Posted by porn_dealer on Jul. 20 2001,01:51
When using ImageMagick w/ PHP, a sample app to draw text over an image might look like this:

<?php
// text str to write
$str = "Hello";

// x/y coords of where to draw the text
$x = 312;
$y = 0;

// -draw switch to pass to convert
$draw = "-draw \"text $x,$y '$str'\"";

// original image to write text over:
$original_image = "/usr/sites/mysite/htdocs/images/blank_dong.jpg"; // dont ask.

// font
$font_to_use = "$DOCUMENT_ROOT/verdana.ttf";

// write the header
header("Content-type: image/jpeg");

// align (Center, West, East, South, etc.)
$align = "Center";

// text color
$font_color = "#FFFFFF";

// run /usr/local/bin/convert
passthru("/usr/local/bin/convert -font @$font_to_use -pointsize 14 -gravity $align -quality 100 -antialias -pen \$font_color $draw $original_image jpeg:-");

// done!

?>

------------------
I swear to god the combined IQ of these forums (not including the ladies) must be less than the cost of a used 85 honda civic with severe rear damage...
-- Kamilion


Posted by porn_dealer on Jul. 20 2001,01:53
If you want VD--err GD, goto < www.boutell.org/gd/ > (i believe)
Powered by Ikonboard 3.1.4 © 2006 Ikonboard