Python之批量改变图片大小

 

image_pylib模块:https://github.com/huangshiyu13/image_pylib

data_engine模块:https://github.com/huangshiyu13/RPNplus/blob/master/data_engine.py

_init_paths模块:https://github.com/huangshiyu13/RPNplus/blob/master/_init_paths.py

import _init_paths
from image_pylib import IMGLIB
import data_engine
import os



if __name__ == '__main__':
    dataDir = '../data/testData/horse'
    saveDir = '../data/testData/horse_r'
    data_engine.checkDir(dataDir)
    data_engine.checkDir(saveDir,creat=True)
    files = data_engine.getAllFiles(dataDir,'.jpg')

    imglib = IMGLIB()
    for file in files:
        imglib.read_img(file[0])
        imglib.pureResize(224,224)
        imglib.save_img( os.path.join(saveDir,file[1]+'.jpg') )

 

posted @ 2017-06-20 10:58  Shiyu_Huang  阅读(1054)  评论(0编辑  收藏  举报