As Weedpacket stated there are special functions used to do that. I did this recently. This is what to do:
you put the code below in a new php file that you save in your images directory; you might name this file resize_image.php. This is the code:
<?php
//set the width of the thumbnail
(double)$max_width = 150;
//set the height of the thumbnail
(double)$max_height = 100;
//take the size of the original image
$size = GetImageSize("$image");
(double)$width = $size[0];
(double)$height = $size[1];
//make calculations for the redimensioning of the original image into a thumbnail,
// keeping proportions intact
$x_ratio = $max_width/$width;
$y_ratio = $max_height/$height;
if (($width <=$max_width)&&($height<=$max_height))
{
$tn_width = $width;
$tn_height = $height;
}
else if (($x_ratio$height)<$max_height) {
$tn_height = ceil($x_ratio$height);
$tn_width = $max_width;
}
else {
(double)$tn_width = ceil($y_ratio*$width);
$tn_height = $max_height;
//echo $tn_width;
//echo $tn_height;
//exit;
}
//create the thumbnail for a JPEG image, use ImageCreateFromGIF() for GIFs
$src = ImageCreateFromJPEG("$image");
$dst = ImageCreate($tn_width, $tn_height);
ImageCopyResized($dst, $src, 0,0,0,0, $tn_width, $tn_height, $width, $height);
error_reporting(0);
header("Content-type: image/jpeg");
ImageJPEG($dst, null, -1);
ImageDestroy($src);
ImageDestroy($dst);
?>
In your actual page you use this line for the <src> tag:
<?php
echo "<img src=\"images\/resize_image.php?image=".$file.".jpg\">";
?>
You let me know whether this worked for you.