Python之批量改变图片大小
原创
©著作权归作者所有:来自51CTO博客作者wx62d12289ce45b的原创作品,请联系作者获取转载授权,否则将追究法律责任
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') )
黄世宇/Shiyu Huang's Personal Page:https://huangshiyu13.github.io/