def static_partial_tile_sizes(width, height, tilesize, scale_factors):
    """Generator for partial tile sizes for zoomed in views.

    Positional arguments:
    width -- width of full size image
    height -- height of full size image
    tilesize -- width and height of tiles
    scale_factors -- iterable of scale factors, typically [1,2,4..]

    Yields ([rx,ry,rw,rh],[sw,sh]), the region and size for each tile
    """
    for sf in scale_factors:
        if sf * tilesize >= width and sf * tilesize >= height:
            continue
        rts = tilesize * sf
        xt = (width - 1) // rts + 1
        yt = (height - 1) // rts + 1
        for nx in range(xt):
            rx = nx * rts
            rxe = rx + rts
            if rxe > width:
                rxe = width
            rw = rxe - rx
            sw = (rw + sf - 1) // sf
            for ny in range(yt):
                ry = ny * rts
                rye = ry + rts
                if rye > height:
                    rye = height
                rh = rye - ry
                sh = (rh + sf - 1) // sf
                yield [rx, ry, rw, rh], [sw, sh]
