Try this:

function Resize_Image($FilePath, $new_w){
        $File = fopen($FilePath, "r");
        $FileContents = fread($File, filesize($FilePath));

        $src            = imagecreatefromstring($FileContents);
        $width  = imagesx($src);

        // Shrink the image to the maximum width
        // Maintaining aspect ratio
        if($width > $new_w){
        $height = imagesy($src);
        $aspect_ratio = $height/$width;
        $new_h = abs($new_w * $aspect_ratio);
        $img = imagecreatetruecolor($new_w,$new_h); 

        imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);

        ob_start();
        imagejpeg($img);
        $FileContents = ob_get_contents();
        ob_end_clean();
        imagedestroy($img);
        }

        return $FileContents;
}

you can then either save the filecontents as an image, or place it in a
database.

-----Original Message-----
From: Rafael Alex Cremer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 20, 2004 5:29 PM
To: [EMAIL PROTECTED]
Subject: [PHP] thumbnail??? 

OK, but how? I already use GD, I need to now how to create a thumbnail, 
somebody now how to use the GD functions to create a thumbnail???

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to