Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

imagegif()

Discussion in 'General Discussion' started by agabehzad, Apr 17, 2004.

  1. agabehzad

    agabehzad Member

    Joined:
    Mar 12, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    151
    hi,
    have installed the gd lib. and i can use them
    but i can't use imagegif() , here is the error
    Fatal error: Call to undefined function: imagegif()
    and here is the code
    <?
    $fn='index1.gif';
    if(isset($fn)){
    $ext = substr($fn, -3);

    if($ext == 'jpg'){
    $mime = "image/jpeg";
    }
    elseif($ext == 'gif'){
    $mime = "image/gif";
    }
    elseif($ext == 'png'){
    $mime = "image/png";
    }
    else{
    exit("<b>Unkown format!</b><br/>\n");
    }

    function resize($fn, $mime, $vraz){
    header("Content-Type: ".$mime."\n\n");

    list($width, $height, $value, $params) = GetImageSize($fn);

    $new_width = ceil($width/$vraz);
    $new_height = ceil($height/$vraz);

    $new_width2 = ceil($width/$vraz)."0";
    $new_height2 = ceil($height/$vraz)."0";

    if($mime == 'image/jpeg'){
    $newImage = ImageCreate($new_width, $new_height);
    $cpyImage = ImageCreateFromJPEG($fn);
    ImageCopyResized($newImage, $cpyImage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    ImageJPEG($newImage);
    }
    elseif($mime == 'image/gif'){
    $newImage = ImageCreate($new_width, $new_height);
    $cpyImage = ImageCreateFromGIF($fn);
    ImageCopyResized($newImage, $cpyImage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    ImageGIF($newImage);
    }
    elseif($mime == 'image/png'){
    $newImage = ImageCreate($new_width, $new_height);
    $cpyImage = ImageCreateFromPNG($fn);
    ImageCopyResized($newImage, $cpyImage, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    ImagePNG($newImage);
    }
    else{
    exit("<b>Unkown format!</b><br/>\n");
    }
    }

    resize($fn, $mime, 100);
    }
    else{
    exit("<b>Please select file!</b><br/>\n");
    }
    ?>


    can u please help me ?!
     
  2. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    316
    Location:
    Spain
    From http://www.php.net/manual/en/function.imagegif.php:
     
  3. agabehzad

    agabehzad Member

    Joined:
    Mar 12, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    151
    how can i install the imagegif() function in to my gd lib. ?
    i want to resize a picture with this code .
    can you send me please some codes to resize an image without imagegif() function ?
     
  4. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    166
    either downgrade to the version with gif support (and w/o png support)

    OR...

    use imagepng instead (code below)
     
    #4 elleryjh, Apr 18, 2004
    Last edited: Apr 18, 2004
  5. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    166
    PHP:
    <?
    $fn='index1.gif';
    if(isset(
    $fn)){
    $ext substr($fn, -3);

    if(
    $ext == 'jpg'){
    $mime "image/jpeg";
    }
    elseif(
    $ext == 'gif'){
    $mime "image/png";
    }
    elseif(
    $ext == 'png'){
    $mime "image/png";
    }
    else{
    exit(
    "<b>Unkown format!</b><br/>\n");
    }

    function 
    resize($fn$mime$vraz){
    header("Content-Type: ".$mime."\n\n");

    list(
    $width$height$value$params) = GetImageSize($fn);

    $new_width ceil($width/$vraz);
    $new_height ceil($height/$vraz);

    $new_width2 ceil($width/$vraz)."0";
    $new_height2 ceil($height/$vraz)."0";

    if(
    $mime == 'image/jpeg'){
    $newImage ImageCreate($new_width$new_height);
    $cpyImage ImageCreateFromJPEG($fn);
    ImageCopyResized($newImage$cpyImage0000$new_width$new_height$width$height);

    ImageJPEG($newImage);
    }
    elseif(
    $mime == 'image/gif'){
    $newImage ImageCreate($new_width$new_height);
    $cpyImage ImageCreateFromGIF($fn);
    ImageCopyResized($newImage$cpyImage0000$new_width$new_height$width$height);

    ImagePNG($newImage);
    }
    elseif(
    $mime == 'image/png'){
    $newImage ImageCreate($new_width$new_height);
    $cpyImage ImageCreateFromPNG($fn);
    ImageCopyResized($newImage$cpyImage0000$new_width$new_height$width$height);

    ImagePNG($newImage);
    }
    else{
    exit(
    "<b>Unkown format!</b><br/>\n");
    }
    }

    resize($fn$mime100);
    }
    else{
    exit(
    "<b>Please select file!</b><br/>\n");
    }
    ?>
     
  6. agabehzad

    agabehzad Member

    Joined:
    Mar 12, 2004
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    151
    the picture created by this code , has not a good quality. ( color is not real) can you please help me ?!?
     

Share This Page