Hi,
In one of my prog's I have this function, which will resize, rename and move an image (And may do some other stuff ass well, but the idea should be clear):
function CreateThumb($fit_size, $picture, $input_path, $cdnr)
{
$quality = 100;
$fullPath = $input_path.$picture;
if ( !file_exists ( $fullPath ))
{
die("File doesnt exist!");
}
$outputpath = "c:";
$outfile = $outputpath.'\\cd'.$cdnr.'_'.$picture;
$inputpath = "";
echo $outfile;
$size = getimagesize($fullPath);
$height = $size[1];
$width = $size[0];
// echo $height;
// echo '<br>';
// echo $width;
//save thumbnail
if($height > $width)
{
$newY = $fit_size;
$newX = $width / $height * $newY;
$newX = round( $newX );
}
else
{
$newX = $fit_size;
$newY = $height / $width * $newX;
$newY = round( $newY );
}
// echo $newX;
// echo '<br>';
// echo $newY;
// echo '<br>';
//create the destination image resource.
// $destImg = ImageCreate($newX, $newY );
$destImg = ImageCreateTrueColor($newX, $newY );
//read the source image (original), use correct function depending on format
$sourceImg = ImageCreateFromJPEG ($fullPath);
ImageCopyResized($destImg, $sourceImg, 0,0,0,0, $newX, $newY, $size[0], $size[1]);
$new_picture = "c:\\" . "2" . $picture_filename;
// echo $new_picture;
imagejpeg($destImg, $new_picture, $quality);
$deletedfile = @unlink($fullPath);
rename($new_picture, $outfile);
}