/    Sign up×
Community /Pin to ProfileBookmark

undefined function:

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

[/quote]

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 🙂
?>
[/code]

This is the link on my old server
[url=http://www.slweb.co.nz/party/index.php#upload]older example[/url]
And the new set-up
[url=http://www.asktom.co.nz/add.php]this example[/url]

You have to upload an image to see the error

Thanks for any comments

Sheldon

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@chazzyOct 03.2005 — My first idea is that this function did not get installed when PHP was installed on the system in question. Is this the same box? Are you sure PHP is running correctly?

is it a windows box maybe?

http://us3.php.net/manual/en/function.imagecreatefromjpeg.php
Copy linkTweet thisAlerts:
@bringerofnightOct 03.2005 — Reinstall PHP try installing 5.0.1 that should work.
Copy linkTweet thisAlerts:
@SheldonauthorOct 03.2005 — One box is running linux debian and the other is running mac os X server both running PHP Version 4.3.11?
Copy linkTweet thisAlerts:
@pyroOct 03.2005 — Run a phpinfo script and make sure GD is installed...
×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...