def _initial_size(ix, iy, sx, sy):
    """we need a best fit centered selection. Shamelessly copied from
    plone.app.imaging.browser.editor
    """
    ix, iy, sx, sy = map(float, (ix, iy, sx, sy))
    if iy > 0:
        ir = ix / iy
    else:
        ir = 1
    if sy > 0:
        sr = sx / sy
    else:
        sr = 1
    if ir > sr:
        rx1, ry1 = ix * sr / ir, iy
    else:
        rx1, ry1 = ix, iy * ir / sr
    rx0, ry0 = 0, 0
    if rx1 < ix:
        deltax = ix - rx1
        rx0 = deltax / 2
        rx1 = rx1 + deltax / 2
    if ry1 < iy:
        deltay = iy - ry1
        ry0 = deltay / 2
        ry1 = ry1 + deltay / 2
    rx0, ry0 = int(round(rx0)), int(round(ry0))
    rx1, ry1 = int(round(rx1)), int(round(ry1))
    return rx0, ry0, rx1, ry1
