Page 1 of 1
Need Help with GD Library
Posted: Wed Mar 31, 2004 1:24 pm
by tmejias
I have GD installed on my server, but some functions not working: createimagefromjpeg and createimagefromgif, and I dont know why.
Please help I need this so I can open up my site to the public.
Tracy
Posted: Wed Mar 31, 2004 1:38 pm
by magicrobotmonkey
Little more information would be useful - like why it isn't working, what are you trying to do with it, what errors are you getting, maybe some bits of code which are generating the errors, if there are any.
GD Library
Posted: Wed Mar 31, 2004 1:53 pm
by tmejias
This is the error I am getting:
Fatal error: Call to undefined function: imagegif() in /home/showcase/public_html/bear_addod.php on line 90
I am trying to use this to resize large images into thumbnail images.
I can give you some code:
This is the coding of the acutal page that I get the error on:
bear_addod.php:
<?
session_start();
if (!session_is_registered("MEMBER")) {
header ("Location:index.php");
exit;
} else {
include_once ("settings/settings.php");
include_once ($CLASS_FOLDER."database.class.php");
include_once ($CLASS_FOLDER."users.class.php");
include_once ($CLASS_FOLDER."image.class.php");
include_once ($CLASS_FOLDER."bear.class.php");
$db=new DatabaseClass;
$db->Open();
$user=new UserClass;
$image=new ImageClass;
$bear=new BearsClass;
$sessid=session_id();
$username=$MEMBER;
if ($user->Check_Session($username,$sessid)) {
header ("Location:index.php");
exit;
} else {
if (!$bear->Check_Exists($id,$name)) {
header ("Location:member.php?bdy=2&msg=7");
exit;
} else {
$err=false;
$image1_name=$_FILES['file']['name'];
$image1_ext=$image->Get_extension ($image1_name);
if ($image1_ext!="jpg" & $image1_ext!="gif") {
$err=true;
header ("Location:member.php?bdy=2&msg=1");
exit;
}
if ($f2caption) {
$image2_name=$_FILES['file2']['name'];
$image2_ext=$image->Get_extension ($image2_name);
if ($image2_ext!="jpg" & $image2_ext!="gif") {
$err=true;
header ("Location:member.php?bdy=2&msg=2");
exit;
}
}
$image1_size=$_FILES['file']['size'];
if ($image1_size>102400) {
$err=true;
header ("Location:member.php?bdy=2&msg=3");
exit;
}
if ($f2caption) {
$image2_size=$_FILES['file2']['size'];
if ($image2_size>102400) {
$err=true;
header ("Location:member.php?bdy=2&msg=4");
exit;
}
}
if (!$err) {
$nameadd=time();
$image1_fullname=$nameadd.$image1_name;
$image1_thumtarget="bears/thumb/".$nameadd.$image1_name;
$iamges1_target="bears/".$image1_fullname;
if (! @copy($_FILES['file']['tmp_name'],$iamges1_target)) {
header ("Location:member.php?bdy=2&msg=5");
exit;
} else {
//thumbal 1 create
$img_arr=getimagesize($_FILES['file']['tmp_name']);
$image1_width=$img_arr[0];
$image1_height=$img_arr[1];
if ($image1_width>$image1_height & $image1_width>$THUMBAL_W) {
$ratio=$image1_width/$THUMBAL_W;
} else {
$ratio=$image1_height/$THUMBAL_H;
}
$image1_new_width=intval($image1_width/$ratio);
$image1_new_height=intval($image1_height/$ratio);
switch ($image1_ext) {
case 'gif':
$img1_src = imagecreatefromgif ($iamges1_target);
break;
case 'jpg':
$img1_src = imagecreatefromjpeg ($iamges1_target);
break;
}
$img1_dest = ImageCreateTrueColor ($image1_new_width,$image1_new_height);
ImageCopyResized( $img1_dest, $img1_src, 0, 0, 0, 0, $image1_new_width, $image1_new_height, $image1_width, $image1_height );
switch ($image1_ext) {
case 'gif':
imagegif($img1_dest,$image1_thumtarget);
break;
case 'jpg':
imagejpeg($img1_dest,$image1_thumtarget);
break;
}
// end create thumbal 1
if ($f2caption) {
$image2_fullname=$nameadd.$image2_name;
$image2_thumtarget="bears/thumb/".$nameadd.$image2_name;
$iamges2_target="bears/".$image2_fullname;
if (! @copy($_FILES['file2']['tmp_name'],$iamges2_target)) {
header ("Location:member.php?bdy=2&msg=6");
exit;
} else {
//thumbal 1 create
$img_arr=getimagesize($_FILES['file2']['tmp_name']);
$image2_width=$img_arr[0];
$image2_height=$img_arr[1];
if ($image2_width>$image2_height & $image2_width>$THUMBAL_W) {
$ratio=$image2_width/$THUMBAL_W;
} else {
$ratio=$image2_height/$THUMBAL_H;
}
$image2_new_width=intval($image2_width/$ratio);
$image2_new_height=intval($image2_height/$ratio);
switch ($image2_ext) {
case 'gif':
$img2_src = imagecreatefromgif ($iamges2_target);
break;
case 'jpg':
$img2_src = imagecreatefromjpeg ($iamges2_target);
break;
}
$img2_dest = ImageCreateTrueColor ($image2_new_width,$image2_new_height);
ImageCopyResized( $img2_dest, $img2_src, 0, 0, 0, 0, $image2_new_width, $image2_new_height, $image2_width, $image2_height );
switch ($image2_ext) {
case 'gif':
imagegif($img2_dest,$image2_thumtarget);
break;
case 'jpg':
imagejpeg($img2_dest,$image2_thumtarget);
break;
} // end create thumbal 1
}
}
// add in database
$bear->Add ($id,$name,$artist,$size,$sized,$category,$fee,$feein,$shipping,$place,$image1_fullname,$f1caption,$image2_fullname,$f2caption,$description);
header ("Location: member.php?bdy=3");
exit;
}
}
}
}
}
?>
This is on my site BearShowcase.com
When a member adds a bear for sale, the upload an image, in turn this image needs to be thumbnailed so when a buyer clicks on the bear, they are shown the bears information as well as the larger image.
If you need something else, please let me know.
Thanks,
Tracy
Posted: Thu Apr 01, 2004 1:28 am
by twigletmac
Basically, if you are using GD version 1.6 or above you do not have access to the gif manipulation functions (they had to be removed for licensing reasons). Note this comment from the [php_man]imagegif[/php_man] manual page:
PHP Manual - imagegif() wrote:Note: Since all GIF support was removed from the GD library in version 1.6, this function is not available if you are using that version of the GD library. Support is expected to return in a version subsequent to the rerelease of GIF support in the GD library in mid 2004. For more information, see the GD Project site.
Mac
Posted: Thu Apr 01, 2004 4:27 am
by Zay
make a new page with this code:
then goto it... search for 'GD' and check what version you have there... if you can't find it you don't have it and you can't use any of those funcs.