开发者

Create thumbnail images for jpegs with python

开发者 https://www.devze.com 2022-12-26 14:35 出处:网络
As the title says i am looking for a way convert a huge number of images into thumbn开发者_JAVA百科ails of different sizes , How do i go about doing this in python See: http://www.pythonware.com/produ

As the title says i am looking for a way convert a huge number of images into thumbn开发者_JAVA百科ails of different sizes , How do i go about doing this in python


See: http://www.pythonware.com/products/pil/index.htm

import os, sys
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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号