class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
See all posts See thread Reply
$foo = new Upload($_FILES['imgfile']) $toArea = (640*480); $fromSize = getimagesize($_FILES['imgfile']['tmp_name']); $fromArea = $fromSize[0] * $fromSize[1]; $areaDiff = sqrt($toArea / $fromArea); $foo->image_x = round($fromSize[0] * $areaDiff); $foo->image_y = round($fromSize[1] * $areaDiff); $foo->image_resize = true; $foo->Process('./');
sqrt does the trick!
Thanks for the contribution.