PIL: увеличить изображение

Мне не удается заставить PIL увеличить изображение. Большие изображения легко уменьшаются в масштабе, но маленькие изображения не увеличиваются.

# get the ratio of the change in height of this image using the
# by dividing the height of the first image
s = h / float(image.size[1])
# calculate the change in dimension of the new image
new_size = tuple([int(x*s) for x in image.size])
# if this image height is larger than the image we are sizing to
if image.size[1] > h: 
    # make a thumbnail of the image using the new image size
    image.thumbnail(new_size)
    by = "thumbnailed"
    # add the image to the images list
    new_images.append(image)
else:
    # otherwise try to blow up the image - doesn't work
    new_image = image.resize(new_size)
    new_images.append(new_image)
    by = "resized"
logging.debug("image %s from: %s to %s" % (by, str(image.size), str(new_size)))
7
задан Grant Eagon 9 March 2011 в 19:19
поделиться