Resize to megapixels

See all posts See thread Reply

Re: Resize to megapixels new!
by Carl Johan, 16 years, 11 months ago
I just did it and it's really not alot of code. Something like this:

$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!Reply
Re: Resize to megapixels new!
by colin, 16 years, 11 months ago
Thanks, I will look into that. Running a bit out of time at the moment, but I hope to be able to release something during next week.

Thanks for the contribution.Reply