Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Thumbnail Gif

  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbnail Gif

    I want to create a image thumbnails. I basically use the same code for jpeg and the image is perfect. But for gif, the image color is distorted. I'm not sure if distorted is the word, but the color is totally out. How do I rectify this problem?

    PHP Code:
            if (@$userfile_type=="image/gif")
            {
            
    $im=ImageCreateFromGIF($add);
            
    //$width=ImageSx($im);              // Original picture width is stored
            //$height=ImageSy($im);                  // Original picture height is stored
            
    $newimage=imagecreatetruecolor($n_width,$n_height);
            
    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
            if (
    function_exists("imagegif")) {

            
    ImageGIF($newimage,$tsrc);
            }
            elseif (
    function_exists("imagejpeg")) {

            
    ImageJPEG($newimage,$tsrc,100);
            }
            
    chmod("$tsrc",0777);
            } 

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I just answered this for someone else ....

    Use resample instead of resize.

    See this example page:

    http://www.catpin.com/scott.php

    In the example, I didn't deal with the transparent color.
    There is a function for handling transparent .gif colors.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •