x_rem = x - x_int
if x_int % 2 == 1:
    return round(x)
elif x_rem - 0.5 < 0.001:
    return math.floor(x)
else:
    return math.ceil(x)
App Engine: Calculating the dimensions of thumbnails to be generated by serving thumbnails from the blobstore