def create_thumb(img_name):
image = Image.open('{}.tiff'.format(img_name))
(imageW, imageH) = image.size
if imageW > imageH:
ratio = thumb_size / imageW
newWidth = 400
newHeight = int(imageH * ratio)
else:
ratio = thumb_size / imageH
newHeight = 400
newWidth = int(imageW * ratio)
image = image.resize((newWidth, newHeight), Image.LANCZOS)
outfh = open('{}_thumb.tiff'.format(img_name), 'wb')
image.save(outfh, format='TIFF')
outfh.close()
评论列表
文章目录