ImageCreateFromJpeg problem
Posted: Wed Jan 05, 2005 5:01 pm
I have created a resize_image function which i know is coded fine. However the only problem is that when i view my newsboard the image is not there. however opening notepad i can see that it has found the create path for the image and all is displayed is a white image with a red cross. I then typed the actual line of code into the browser which was
this produced
I thought that imagecreatefromjpeg was an internal function of php? full code is below any help very helpful!
Code: Select all
http://localhost/resize_image.php?image=2.jpgCode: Select all
Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\program files\apache group\apache2\htdocs\resize_image.php on line 38Code: Select all
<?php
$image = $_GET['image'];
if (!$max_width)
$max_width = 80;
if (!$max_height)
$max_height = 60;
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
//find the ratio between the actual and max dimensions.
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if ( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg($image);
$dst = ImageCreate($tn_width,$tn_height);
ImageCopyResized($dst, $src, 0, 0 ,0 ,0, $tn_width, $tn_height, $width, $height);
header('Content-type: image/jpeg');
ImageJpeg($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
?>