Skip to content

Instantly share code, notes, and snippets.

@jesliwang
Created December 30, 2017 15:43
Show Gist options
  • Save jesliwang/6e4f070eeaf5bdf3871e3e689b945261 to your computer and use it in GitHub Desktop.
Save jesliwang/6e4f070eeaf5bdf3871e3e689b945261 to your computer and use it in GitHub Desktop.
批量修改图片尺寸
#!/Users/Jesli/anaconda2/bin/python
# -*- coding: utf-8 -*-
# pip install pillow
from PIL import Image
image_size = [36, 48, 72, 96, 144, 192]
def start():
for size in image_size:
create_image(size,)
def create_image(size):
pri_image = Image.open("origin.jpg")
resize_image = pri_image.resize((size, size), Image.ANTIALIAS)
resize_image.save("img/png_%d.png" % size)
if __name__ == "__main__":
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment