<?php 
$sImage          = $_GET['bestand']; // Haal het bestand uit de header
$iImageMaxWidth  = "120"; // De maximum hoogte van de afbeelding 
$iImageMaxHeight = "90";  // De maximum breedte van de afbeelding
$aImageData      = getimagesize($bestand); // Zoek de huidige breedte en hoogte van de afbeelding op
$iImageWidth     = $aImageData[0]; // Haal de huidige breedte uit de array
$iImageHeight    = $aImageData[1]; // Haal de huidige hoogte uit de array

if ($iImageHeight > $iImageMaxWith || $iImageHeight > $iImageMaxHeight) // Kijk of de opgegeven afmetingen kleiner zijn dan de huidige
{ 
	if ($iImageWidth / $iImageHeight > $iImageMaxWidth / $iImageMaxHeight)  // Kijk of afbeelding te groot is
	{ 
		$iImageNewWidth  = $iImageMaxWidth; // Verhoudingen voor breedte bepalen                                   
		$iImageNewHeight = round ($iImageHeight / ($iImageWidth / $iImageMaxWidth)); // Verhoudingen voor hoogte bepalen
	} 
	else 
	{	 
		$iImageNewHeight = $iImageMaxHeight; // Verhoudingen voor hoogte bepalen 
		$iImageNewWidth  = round($iImageWidth / ($iImageHeight / $iImageMaxHeight)); // Verhoudingen bepalen voor breedte 
	}
} 
else // Als de afbeelding precies groot genoeg is
{ 
	$iImageNewHeight = $iImageMaxHeight;
	$iImageNewWidth  = $iImageMaxWidth; 
} 
$fImage = @imagecreatefromjpeg($bestand); // Vanuit vroegere bestand werken
$fImageTemp = imagecreatetruecolor($iImageNewWidth, $iImageNewHeight); 
imagecopyresized($fImageTemp, $fImage, 0, 0, 0, 0, $iImageNewWidth, $iImageNewHeight, $iImageWidth, $iImageHeight); // Verkleinen
imagedestroy($fImage); 
header("Content-type: image/jpeg"); // Header voor jpeg afbeeldingen doorsturen 
imagejpeg($fImageTemp, "", 75); // Uiteindelijke verkleinde afbeelding terugsturen
?> 