Scaling help

Ok so for a while now I had this tiny chunk of code that would resize and image and scale it proportionatly. However I just realized there is an issue and I’m having some trouble fixing it - which should be a joke to fix but I can’t.


if (_root.base_back.portrait_placeholder._width>99.7) {
    _root.base_back.portrait_placeholder._width = 99.7;
    _root.base_back.portrait_placeholder._yscale = _root.base_back.portrait_placeholder._xscale;
} else {
    _root.base_back.portrait_placeholder._height = 133;
    _root.base_back.portrait_placeholder._yscale = _root.base_back.portrait_placeholder._xscale;
}
if (_root.base_back.portrait_placeholder._height>133) {
    _root.base_back.portrait_placeholder._height = 133;
    _root.base_back.portrait_placeholder._xscale = _root.base_back.portrait_placeholder._yscale;
} else {
    _root.base_back.portrait_placeholder._height = 133;
    _root.base_back.portrait_placeholder._xscale = _root.base_back.portrait_placeholder._yscale;
}

The problem is that the width can never be greater then 99.7 and the height can never be greater then 133 - even after it’s scaled.

This code obviously is poorly written and does not handle that.

Any ideas how to make this work?