Re: FW: Resizing Pictures

From: Date: Tue, 20 Apr 2004 05:39:45 +0000
Subject: Re: FW: Resizing Pictures
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-183918@lists.php.net to get a copy of this message
Ryan Schefke wrote:
How do you resize pictures once they're in a certain directory? I have the script to upload a picture, that's working fine. I just need some help with resizing it. Can someone help? Thanks! im creating a new image in this function, but you get the idea..
function generateThumb($ID) {
    $source_image   = GALLERY_ROOT . "images/". $ID . ".jpg";
    $dest_image     = GALLERY_ROOT  . "thumbnails/" . $ID . ".jpg";
    $source_id      = imageCreateFromJPEG($source_image);
    $picsize        = getimagesize($source_image);
    $source_x       = $picsize[0];
    $source_y       = $picsize[1];
    $dest_x         = THUMB_X;
    $dest_y         = THUMB_Y;
    $target_id      = imagecreatetruecolor($dest_x,$dest_y);
    $target_pic     = imagecopyresampled($target_id,$source_id, 0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
    return imagejpeg($target_id,$dest_image);
} Dan

« previous php.general (#183918) next »