def import_image(src_filename, dest_filename):
if os.path.isfile(dest_filename):
click.echo('Already exists, skipping: {}'.format(dest_filename))
else:
with Image.open(src_filename) as image:
image.thumbnail((IMAGE_MAX_SIZE, IMAGE_MAX_SIZE))
try:
image.filter(ImageFilter.SHARPEN)
except ValueError:
pass # skip filtering for images which do not support it
click.echo('Saving: {}'.format(dest_filename))
options = dict(IMAGE_SAVE_OPTIONS)
if is_animated(image):
options.setdefault('save_all', True)
image.save(dest_filename, image.format, **options)
评论列表
文章目录