I have found function resize somewhere (probably at this forum). I've made some changes to it, so it makes the picture smaller after uploading and saves it to disk. You have to make changes so it sends the picture to the browser instead.
function resize($start_path,$end_path,$end_size,$type)
{
$picture_location = "$start_path";
$picture_save = "$end_path";
$size = $end_size; // size in pixel you want the picture to come out height or width - whichever is bigger
$im_size = GetImageSize ( $picture_location);
$imageWidth = $im_size[0];
$imageHeight = $im_size[1];
// do all your color allocations here
//$font_color_black = ImageColorAllocate( $im, 0,0,0);
if ($type == "jpg")
{
$im2 = ImageCreateFromJPEG($picture_location);
}
if ($type == "png")
{
$im2 = ImageCreateFromPNG($picture_location);
}
if ($imageWidth>=$imageHeight)
{
$width=$size;
$height = ($width/$imageWidth)*$imageHeight;
}
else
{
$height=$size;
$width = ($height/$imageHeight)*$imageWidth;
}
$im = ImageCreateTrueColor( $width, $height );
ImageCopyResized ($im,$im2, 0, 0, 0, 0, $width, $height, $imageWidth, $imageHeight);
if ($type == "jpg")
{
// Header("Content-type: image/jpeg");
ImageJPEG($im,$picture_save,80);
}
if ($type == "png")
{
// Header("Content-type: image/png");
ImagePNG($im,$picture_save,80);
}
ImageDestroy($im);
ImageDestroy ($im2);
}//end of resize
It requires GD library and jpeg-6b library. You can check if the function gd_info() returns something on the line of JPEG Support=>true.