Last active
March 15, 2016 05:24
-
-
Save chris-zh/1813a36bc39cb052e713 to your computer and use it in GitHub Desktop.
支持Python3的图片处理库
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[Pillow说明文档][1] | |
#[1]:https://pillow.readthedocs.org/en/3.1.x/ | |
#压缩图片尺寸 | |
from __future__ import print_function | |
import os, sys | |
from PIL import Image | |
size = (128, 128) | |
for infile in sys.argv[1:]: | |
outfile = os.path.splitext(infile)[0] + ".thumbnail" | |
if infile != outfile: | |
try: | |
im = Image.open(infile) | |
im.thumbnail(size) | |
im.save(outfile, "JPEG") | |
except IOError: | |
print("cannot create thumbnail for", infile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment