码迷,mamicode.com
首页 > 编程语言 > 详细

python实现图片批量剪裁的程序

时间:2017-11-05 14:28:59      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:mkdir   color   img   port   image   python   es2017   span   box   

 1 from PIL import Image
 2 import os
 3 fin = ‘D:/test‘
 4 fout = ‘D:/test2‘
 5 for file in os.listdir(fin):
 6     file_fullname = fin + ‘/‘ +file
 7     img = Image.open(file_fullname)
 8     a = [80, 100, 260, 300]
 9     box = (a)
10     roi = img.crop(box)
11     if fout not in os.listdir(‘D:/‘):
12         os.mkdir(fout)
13     out_path = fout + ‘/‘ + file
14     roi.save(out_path)

基础不好,花样踩坑,在此记录一下。

技术分享

 

python实现图片批量剪裁的程序

标签:mkdir   color   img   port   image   python   es2017   span   box   

原文地址:http://www.cnblogs.com/ansang/p/7787315.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!