Home > Backend Development > Python Tutorial > python实现图片批量剪切示例

python实现图片批量剪切示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:29:37
Original
1717 people have browsed it

代码如下:


import os
from PIL import Image

#批量剪切目录下图片
for j in range(10,121):
    p = 'C:/'+str(j)+'/'   #图片目录
  #  print p
    a = os.listdir(p)

    for i in a:
        path = p+i
        print path    #图片名称
        try:
            f = Image.open(path)
    #    print f
        except:

            continue

        else:
            xsize,ysize=f.size
            box=(0,0,xsize,ysize-37)
            f.crop(box).save(path)

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template