import math


def squaredims(dims):
    """Takes a pair of dimensions and normalizes them so that they're almost square."""
    w, h = dims
    total = w*h
    outw = int(math.sqrt(total))
    outw -= outw % min(w,h)
    outh = total//outw
    if total % outw:
        outh += 1
    return (outw, outh)