There are a number of different modules and systems that constrain image
sizes, such as thumbnailing. Every one of these independantly implement the
same logic. That is, given a width and/or height constraint, they check to
see if the image is bigger than the constraint, and if so scale the image
down proportionally so that it fits withint the constraints.
Of course, they all do it slightly differnetly, and some do it better than
others.
'Image::Math::Constrain' has been created specifically to implement this
logic once, and implement it properly. Any module or script that does image
size constraining or thumbnailing should probably be using this for its
math.