PIL: agrandir une image

Je vais avoir de la difficulté à obtenir PIL agrandir une image. Les grandes images sont revus à la baisse, mais les petites images ne sera pas plus grande.

# 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)))
  • pourriez-vous aussi s'il vous plaît écrivez comment vous avez fait lire le fichier image?
InformationsquelleAutor Grant Eagon | 2011-03-09