I'm trying to create thumbnails for my images and everything seems to
work correctly except for trying to save them. I've tried outputting
directly with imagejpeg($im) and that works, but when trying
imagejpeg($im, "new.jpeg") it does not create a new image in the current
directory. I even tried changing the ownership of the script to root to
see if my permissions were screwed up but that didn't work. Here's my
function:

$fileName is the full path name to the image
$newName is just the file name
$thumb_path is the full path to my thumbnail directory

function createThumb($fileName, $newName, $thumb_path, $MAX_H, $MAX_W){

        $new_h = 0;
        $new_w = 0;
        $divisor = 1;
        list($width, $height, $type, $attr) = getimagesize($fileName);
        if ($width > $MAX_W || $height > $MAX_H){
                if ($width > $height)
                        $divisor = $width/$MAX_W;
                else
                        $divisor = $height/$MAX_H;
        }

        switch($type){
                case 1: $src_img = imagecreatefromgif($fileName);
                                break;
                case 2: $src_img = imagecreatefromjpeg($fileName);
                                break;
                default: DisplayErrMsg("Unknown image format, please
alert webmaster!");
                                break;
        }

        if (isset($src_img)){
                $new_h = $height/$divisor;
                $new_w = $width/$divisor;
                $dest_img = imagecreatetruecolor($new_w,$new_h);
        
imagecopyresampled($dest_img,$src_img,0,0,0,0,$new_w,$new_h,$width,$heig
ht);
                switch($type){
                        case 1: imagegif($dest_img,
$thumb_path.$newName);
                                        break;
                        case 2: imagejpeg($dest_img,
$thumb_path.$newName);
                                        break;
                        default: DisplayErrMsg("Unknown image format,
please alert webmaster!");
                                        break;
                }
                imagedestroy($dest_img);
                imagedestroy($src_img);
        }
}

Thanks for any help!

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

Reply via email to