Link to home
Start Free TrialLog in
Avatar of x_terminat_or_3
x_terminat_or_3

asked on

Resize img with min/max + ratio

Hi all

IANAM (I am not a mathematician) and this is causing me some problems.


I need a function that scales down its input variables based on the min/max range


function imageResize(&$width,&$height,$maxwidth,$maxheight)
{

}

I want that both width and height are in range AND

originalsize/originalwidth ~= newwidth/newheight

I tried first calculating width, and then decreasing that until width*ratio<=maxheight but that gives result way too low!


Good luck


Ramses aka x_terminat_or_3
ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of x_terminat_or_3
x_terminat_or_3

ASKER

Thanks my man.  Ugly simple that.  Shame I didn't see it myself.

Anyway, thanks for the link as well, but I cannot rely on GD being available so I 'cheat' by just setting the width/height attributes on the image tag.


With kind regards


Ramses