Undefined function

windows

Guest
PHP is outputtin that the imagecreatefromgif() and png is undefined. I have PHP 4.3.0 for Windows... here's the line in error: <br />
<br />
$ThePic = imagecreatefrompng($PicFile);<br />
<br />
But, I don't understand why it should be undefined... I have the latest version of PHP and the gd.dll (Or something close to that... at school so I can't check.)<br />
<br />
:o This is really pissing me off... Thanks In Advance for any and all help.<!--content-->it's missing the gd library i'm afraid - you'll need to check php.ini to make sure it's enabled. and for php help i'd suggest heading over to the php builder board (<!-- m --><a class="postlink" href="http://www.phpbuilder.com/board">http://www.phpbuilder.com/board</a><!-- m -->)<!--content-->Thanks for your reply. I have corrected the php.ini file, and no longer get errors. However, execution stops after calling imagecreatefromgif();<br />
<br />
$PlayerPic = imagecreatefromgif($PicFile);<br />
echo "TEST";<br />
<br />
$PicFile = A picture that is in the same dir as the script. Such as mypic.gif. (This has been checked, the var has the right value.)<br />
<br />
However, TEST is never echoed<!--content-->no no no no no that's not how it works. You cant just call a function like that and it will display an image - think about it in terms of the PHP creating html - you need an <img src=http://www.webdeveloper.com/forum/archive/index.php/...> tag to get an image, and that's not what that function creates.<br />
<br />
What you need to do is create a makeimage.php file (i've posted the one i use for jpegs just for you to look at) and then call it from your main php file like so:<br />
<br />
echo "<img src=http://www.webdeveloper.com/forum/archive/index.php/\"makeimage.php?directory=1&file=this.jpg\"><br />
<br />
here's my makeimage.php file:<br />
<br />
<br />
<?<br />
<br />
// if (!$max_width)<br />
$max_width = 100;<br />
// if (!$max_height)<br />
$max_height = 100;<br />
<br />
$file = $directory."/".$file;<br />
<br />
$size = GetImageSize($file);<br />
$width = $size[0];<br />
$height = $size[1];<br />
<br />
$x_ratio = $max_width / $width;<br />
$y_ratio = $max_height / $height;<br />
<br />
if ( ($width <= $max_width) && ($height <= $max_height) ) {<br />
$tn_width = $width;<br />
$tn_height = $height;<br />
}<br />
else if (($x_ratio * $height) < $max_height) {<br />
$tn_height = ceil($x_ratio * $height);<br />
$tn_width = $max_width;<br />
}<br />
else {<br />
$tn_width = ceil($y_ratio * $width);<br />
$tn_height = $max_height;<br />
}<br />
<br />
$src = <!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/archive/index.php/ImageCreateFromJpeg($file">http://www.webdeveloper.com/forum/archi ... Jpeg($file</a><!-- m -->);<br />
$dst = ImageCreate($tn_width,$tn_height);<br />
ImageCopyResized($dst, $src, 0, 0, 0, 0,<br />
$tn_width,$tn_height,$width,$height);<br />
header("Content-type: image/jpeg");<br />
ImageJpeg ($dst, '', 90);<br />
ImageDestroy($src);<br />
ImageDestroy($dst);<br />
<br />
?><br />
<br />
given as your code is generating an image, putting things like echo into it dont do anything or will confuse it - they'll have to go in your main script.<!--content-->Thanks so much. I now understand this a whole lot better. I put the image function in it's own file. Now it creates a 32x32 picture, and works almost perfectly. One problem:<br />
<br />
echo "<img src=http://www.webdeveloper.com/forum/archive/index.php/\"findPlayerpic.php?PicNum=".$ThePicNum."\">";<br />
The actual file:<br />
<HTML><br />
<?php<br />
echo $PicNum;<br />
// Just testing that var for now...<br />
?><br />
$PicNum is null. Why? How can I retrieve it from the URL?<!--content-->you dont (correctly) have globals on - use $_GET['variable name'] to get to the URL variables:<br />
<br />
echo "<img src=http://www.webdeveloper.com/forum/archive/index.php/\"findPlayerpic.php?PicNum=$ThePicNum\">";<br />
<br />
then:<br />
<br />
echo $_GET['PicNum']<!--content-->
 
Back
Top