I need to enclose any given rectangle with another rectangle.

The enclosing rectangle must be of a specific ratio - eg width is twice its height for example. In actual fact the ratio I need for the enclosing rectagle is that the width is 1.62344 times the height.

So given any rectange r with heigh h and width w I need to find rectangle r2 with height h2 and width w2 such that r sits inside r2 and r2 is just big enough to enclose r but no bigger than it needs to be.

Many thanks