Reply to Re: Resize to megapixels

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

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important