$maxwidth) { $teiler = $currwidth / $maxwidth; $nwidth = $currwidth / $teiler; $nheight = $currheight / $teiler; if ($nheight > $maxheight) { $teiler = $nheight / $maxheight; $nheight = $nheight / $teiler; $nwidth = $nwidth / $teiler; } } elseif ($currheight > $maxheight) { $teiler = $currheight / $maxheight; $nwidth = $currwidth / $teiler; $nheight = $currheight / $teiler; if ($nwidth > $maxwidth) { $teiler = $nwidth / $maxwidth; $nheight = $nheight / $teiler; $nwidth = $nwidth / $teiler; } } $nwidth = intval($nwidth); $nheight = intval($nheight); $newim = imagecreatetruecolor ($nwidth, $nheight); imagecopyresampled($newim,$im,0,0,0,0,$nwidth,$nheight,$currwidth,$currheight); imagejpeg($newim,$newfile); ImageDestroy($im); ImageDestroy($newim); return ("ok"); } else { return ("fehler"); } } ?>