Hi all, I have been using this same script(s) on another server for ages, working with no errors. Then/Now setting up another site, using the same code i get this error,
[quote]
Fatal error: Call to undefined function: imagecreatefromjpeg() in /Volumes/Data/Web/AskTom/nuglass/image_resize.php on line 16
and the code/line is
dont worry about the comments, i sometimes like to write bull**** to myself for next time i modify it ?
[code=php]
<?php
//include this in addphoto.php with this line to set the immage size.
//this line is in add photo becasue you will forget it later on sheldon
//$image = resizeImage($thefile,$UploadDir,400); //the last variable is the width to rezise the image to.
function resizeImage($filename,$path,$limitWidth) {
//resize image using vars from addphoto.php
list($initWidth, $initHeight) = getimagesize($path.$filename);
//next section alters the image, changes the width and height
if($initWidth > $limitWidth) {
$per = sprintf(‘%01.4f’,$limitWidth / $initWidth);
$newwidth = sprintf(‘%01.0f’,$per * $initWidth);
$newheight = sprintf(‘%01.0f’,$per * $initHeight);
//set max time and memory limits
set_time_limit(3000);
ini_set(“memory_limit”,”30M”);
//allowed file types are png,jpg and gif
$image_type = strstr($filename, ‘.’);
switch(strtolower($image_type)) {//makes filename in lower case. Great for bad uppercase file names
case ‘.jpg’:
$source = imagecreatefromjpeg($path.$filename);
break;
case ‘.png’:
$source = imagecreatefrompng($path.$filename);
break;
case ‘.gif’:
$source = imagecreatefromgif($path.$filename);
break;
default:
echo(“Error Invalid Image Type”);
die;
break;
}
//sets the path to move the newly resizes image to.
$fullpath = $path . $filename;
list($width, $height) = getimagesize($path.$filename);
//creates thuimbnail
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $fullpath, 100);//width of thumbnail
$filepath = $fullpath;
}
//sends info back to addphoto
return $filepath;
}
//notes: add support for other filetypes and learn how to edit the file and maybe add a watermark, yes that would piss people off :). Good for modification for profile images 🙂
?>
This is the link on my old server
[url=http://www.slweb.co.nz/party/index.php#upload]older example
And the new set-up
[url=http://www.asktom.co.nz/add.php]this example
You have to upload an image to see the error
Thanks for any comments
Sheldon