图片旋转 90、180、270

#scipy的版本为1.0.0
import scipy
from scipy import misc
import os
import time
import glob
from scipy import ndimage

def get_image_paths(folder):
    return glob.glob(os.path.join(folder, '*.jpg'))

def create_read_img(filename):
    im = misc.imread(filename)
    img_rote_90 = ndimage.rotate(im, 90)
    scipy.misc.imsave(filename[:-4]+'_90.jpg',img_rote_90)

    img_rote_180 = ndimage.rotate(im, 180)
    scipy.misc.imsave(filename[:-4]+'_180.jpg',img_rote_180)

    img_rote_270 = ndimage.rotate(im, 270)
    scipy.misc.imsave(filename[:-4]+'_270.jpg',img_rote_270)
    print(filename)
img_path = 'USA'  #这个路径是所有图片在的位置
imgs = get_image_paths(img_path)
print (imgs)

for i in imgs:
    create_read_img(i)

上一篇:使用github遇到的问题


下一篇:MISC