def rangeFromList(list, index):
    minValue = list[0][index]
    maxValue = list[0][index]
    for i in list:
        minValue = min(minValue, i[index])
        maxValue = max(maxValue, i[index])
    return range(minValue, maxValue+1)
Beispiel #2
0
def rangeFromList(list, index):
    minValue = list[0][index]
    maxValue = list[0][index]
    for i in list:
        minValue = min(minValue, i[index])
        maxValue = max(maxValue, i[index])
    return range(minValue, maxValue + 1)
def range_from_list(list, index):
    min_value = list[0][index]
    max_value = list[0][index]
    for i in list:
        min_value = min(min_value, i[index])
        max_value = max(max_value, i[index])
    return range(min_value, max_value+1)
def reshape_to_fit(image, size_x, size_y, bg=(0, 0, 0)):
    """
    Make the PIL image fit the sizeX and sizeY dimensions by scaling as
    necessary and then padding with background.
    Used for watermark and intro & outro slides.
    """
    image_w, image_h = image.size
    if (image_w, image_h) == (size_x, size_y):
        return image
    # scale
    ratio = min(float(size_x) / image_w, float(size_y) / image_h)
    image = image.resize(map(lambda x: int(x*ratio), image.size),
                         Image.ANTIALIAS)
    # paste
    bg = Image.new("RGBA", (size_x, size_y), (0, 0, 0))     # black bg
    ovlpos = (size_x-image.size[0]) / 2, (size_y-image.size[1]) / 2
    bg.paste(image, ovlpos)
    return bg
Beispiel #5
0
def reshape_to_fit(image, sizeX, sizeY, bg=(0, 0, 0)):
    """
    Make the PIL image fit the sizeX and sizeY dimensions by scaling as necessary
    and then padding with background.
    Used for watermark and intro & outro slides.
    """
    image_w, image_h = image.size
    if (image_w, image_h) == (sizeX, sizeY):
        return image
    # scale
    print "scale...from ", image.size, " to ", sizeX, sizeY
    ratio = min(float(sizeX) / image_w, float(sizeY) / image_h)
    image = image.resize(map(lambda x: x * ratio, image.size), Image.ANTIALIAS)
    print ratio, image.size
    # paste
    bg = Image.new("RGBA", (sizeX, sizeY), (0, 0, 0))  # black bg
    ovlpos = (sizeX - image.size[0]) / 2, (sizeY - image.size[1]) / 2
    print "ovlpos", ovlpos
    bg.paste(image, ovlpos)
    return bg
Beispiel #6
0
def reshape_to_fit(image, sizeX, sizeY, bg=(0,0,0)):
    """
    Make the PIL image fit the sizeX and sizeY dimensions by scaling as necessary
    and then padding with background.
    Used for watermark and intro & outro slides.
    """
    image_w, image_h = image.size
    if (image_w, image_h) == (sizeX, sizeY):
        return image
    # scale
    print "scale...from ", image.size, " to ", sizeX, sizeY
    ratio = min(float(sizeX) / image_w, float(sizeY) / image_h)
    image = image.resize(map(lambda x: x*ratio, image.size), Image.ANTIALIAS)
    print ratio, image.size
    # paste
    bg = Image.new("RGBA", (sizeX, sizeY), (0,0,0))     # black bg
    ovlpos = (sizeX-image.size[0]) / 2, (sizeY-image.size[1]) / 2
    print "ovlpos", ovlpos
    bg.paste(image, ovlpos)
    return bg