All pastes #343864 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-07 10:51 UTC
rendered paste body
def scale_bounds(bounds, factor):
    return int(bounds[0] * factor), int(bounds[1] * factor)

def square_bounds(bounds, dim):
    factor = min([dim/x for x in bounds])
    if factor < 1:
        return scale_bounds(bounds, factor)
    else:
        return bounds

def thumb_bounds(bounds):
    #dims = square_bounds(bounds, options.scaled_size * 0.2)
    dims = square_bounds(bounds, options.scaled_size)

    x, y = dims
    if x < y:
        y2 = (y * THUMB_SIZE) / x
        x2 = THUMB_SIZE
        center = (y2 - THUMB_SIZE) / 2
    else:
        y2 = THUMB_SIZE
        x2 = (THUMB_SIZE * x) / y
        center = (x2 - THUMB_SIZE) / 2
    dims = (int(x2), int(y2), int(center))
    return dims