Jump to content

[SOLVED] GD - configuration


ali_2kool2002

Recommended Posts

1 ) Have you now downloaded the php_gd2.dll file from php.net?

 

2 ) Have you looked in you php.ini file for the line

 

          extension_dir = xxxx

 

3 ) Have you put the .dll file in the folder xxxx as defined in the ini file.

 

4 ) Have you then looked in the php.ini file for the line

 

          ;extension=php_gd2.dll

 

    and removed the ; from the beginning.

 

When you have, let  us know.

 

I know this may sound familiar as I answered this here

http://www.phpfreaks.com/forums/index.php/topic,133944.msg563734.html#msg563734

every time i look for a library on php.net it says its moved to another link and when i click the link

it goes to http://www.libgd.org/Main_Page.. this is where i dowloaded the file gd-2.0.35RC1.tar.bz2

which has no dll file.. any further ideas ?thanks

 

another good site is http://www.maani.us/charts/index.php but the chart doesnt change when i follow its tutorial, is this because it requires GD aswel?

hi iv made some kind of progress as the error of not recognising the image create has gone...

 

however, i have a error on your script for bar.php its

 

 

Notice: Undefined index: val in h:\Project\htdocs\fiinalyear\charts\bar.php on line 23

 

Notice: Undefined index: max in h:\Project\htdocs\fiinalyear\charts\bar.php on line 24

‰PNG IHDRf íÞ Í PLTEàààÿ‡½ß°IDATxœcÅp‘(…; úÙ[Fã\IEND®B`‚

 

This version should stop those notices when no values are passed to the script.

<?php
// set dimensions
     $w = 102;
     $h = 12;
// create image
     $im = imagecreate($w, $h);
// set colours to be used
     $bg = imagecolorallocate($im, 0xE0, 0xE0, 0xE0);
     $black = imagecolorallocate($im, 0x00, 0x00, 0x00);
     $barcolor  = imagecolorallocate($im, 0xFF, 0x00, 0x00);
// draw border
     imagerectangle($im, 0,0,$w-1,$h-1,$black);
// get value and max value from query string
     $val = isset($_GET['val']) ? $_GET['val'] : 0;
     $max = isset($_GET['max']) ? $_GET['max'] : 100; 
// calculate dimensions of inner bar
     $barw = $max ? floor(($w-2) * $val / $max) : 0;
     $barh = $h - 2;
// draw inner bar
 if ($barw)
     	imagefilledrectangle($im, 1, 1, $barw, $barh, $barcolor);
// send image header
     header("content-type: image/png");
// send png image
     imagepng($im);
     imagedestroy($im);
?>

the notices have gone but all i get if i go onto bar.php is :

 

‰PNG IHDRf íÞ Í PLTEàààÿ‡½ß°IDATxœcÅp‘(…; úÙ[Fã\IEND®B`‚

 

and the other normal html that uses bar.php displays the table but doesnt seem to be able to retrieve the bar.php in the last coumn...

 

does it work on your system?

png support is built in to the gd extension

 

If you run

 

<?php

phpinfo();

?>

 

You will get a list of supported formats.

 

 

When I run the sample html I get the attachd image. If I run bar.php on its own with no query string I get a grey rectangle

 

[attachment deleted by admin]

yes same folder

 

the code that i have used from urs is in the exact format as below:

 

UNTITLED2.PHP

 

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META http-equiv="content-language" content="en">
<META name="author" content="Barand">
<META name="generator" content="PHPEd 4.5">
<title>Bar sample</title>
</head>
<body>
<table width="884" border='1'>
   <tr>
      <td width="122">
         Item A      </td>
      <td width="58">
         20      </td>
      <td width="303">
         <img src='bar.php?val=20&max=50' border="0">      </td>
   </tr>
   <tr>
      <td height="42">
         Item B      </td>
      <td>
         40
      </td>
      <td>
         <img src='bar.php?val=40&max=50'>
      </td>
   </tr>
   <tr>
      <td>
         Item C
      </td>
      <td>
         30
      </td>
      <td>
         <img src='bar.php?val=30&max=50'>
      </td>
   </tr>
   <tr>
      <td>
         Item D
      </td>
      <td>
         50
      </td>
      <td>
         <img src='bar.php?val=50&max=50'>
      </td>
   </tr>
</table>

</body>
</html>

 

 

bar.php

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<?php
// set dimensions
     $w = 102;
     $h = 12;
// create image
     $im = imagecreate($w, $h);
// set colours to be used
     $bg = imagecolorallocate($im, 0xE0, 0xE0, 0xE0);
     $black = imagecolorallocate($im, 0x00, 0x00, 0x00);
     $barcolor  = imagecolorallocate($im, 0xFF, 0x00, 0x00);
// draw border
     imagerectangle($im, 0,0,$w-1,$h-1,$black);
// get value and max value from query string
     $val = isset($_GET['val']) ? $_GET['val'] : 0;
     $max = isset($_GET['max']) ? $_GET['max'] : 100; 
// calculate dimensions of inner bar
     $barw = $max ? floor(($w-2) * $val / $max) : 0;
     $barh = $h - 2;
// draw inner bar
 if ($barw)
     	imagefilledrectangle($im, 1, 1, $barw, $barh, $barcolor);
// send image header
     header("content-type: image/png");
// send png image
     imagepng($im);
     imagedestroy($im);
?>

</body>
</html>

 

What does this give

<?php
echo '<pre>', print_r(gd_info(), true), '</pre>';
?>

 

I get

Array

(

    [GD Version] => bundled (2.0.28 compatible)

    [FreeType Support] => 1

    [FreeType Linkage] => with freetype

    [T1Lib Support] => 1

    [GIF Read Support] => 1

    [GIF Create Support] => 1

    [JPG Support] => 1

    [PNG Support] => 1

    [WBMP Support] => 1

    [XPM Support] =>

    [XBM Support] => 1

    [JIS-mapped Japanese Font Support] =>

)

Array
(
    [GD Version] => bundled (2.0.28 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [T1Lib Support] => 1
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

ITS THE SAME I THINK

bar.php should be

<?php
// set dimensions
     $w = 102;
     $h = 12;
// create image
     $im = imagecreate($w, $h);
// set colours to be used
     $bg = imagecolorallocate($im, 0xE0, 0xE0, 0xE0);
     $black = imagecolorallocate($im, 0x00, 0x00, 0x00);
     $barcolor  = imagecolorallocate($im, 0xFF, 0x00, 0x00);
// draw border
     imagerectangle($im, 0,0,$w-1,$h-1,$black);
// get value and max value from query string
     $val = isset($_GET['val']) ? $_GET['val'] : 0;
     $max = isset($_GET['max']) ? $_GET['max'] : 100; 
// calculate dimensions of inner bar
     $barw = $max ? floor(($w-2) * $val / $max) : 0;
     $barh = $h - 2;
// draw inner bar
 if ($barw)
     	imagefilledrectangle($im, 1, 1, $barw, $barh, $barcolor);
// send image header
     header("content-type: image/png");
// send png image
     imagepng($im);
     imagedestroy($im);
?>

 

remove all the surrounding html code

P.S. REMOVING THE SURROUND CODE DID THE JOB....wonder why it didnt work with it...

 

Placing a gd produced image with

< img src='an_image.php' >

is the same as placing a static image file (such as jpeg). The only diff is the image is generated on demand from the php code.

 

If you edited a jpeg file and put the html code at the begining and end then that wouldn't work either.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.