国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python實現旋轉和水平翻轉的方法

2020-02-15 23:22:52
字體:
來源:轉載
供稿:網友

如下所示:

# coding=utf-8import globimport osfrom PIL import Imagedef rotate_270(imgae):"""將圖片旋轉270度"""# 讀取圖像im = Image.open(imgae)# im.show()# 指定逆時針旋轉的角度im_rotate = im.rotate(270)# im_rotate.show()return im_rotatedef flip_horizontal(image):"""將圖片水平翻轉"""im = Image.open(image)# im.show()im_fh = im.transpose(Image.FLIP_LEFT_RIGHT)# im_fh.show()return im_fhdef createFile(path):isExists = os.path.exists(path)# 判斷結果if not isExists:# 如果不存在則創建目錄# 創建目錄操作函數os.makedirs(path)return Trueelse:# 如果目錄存在則不創建,并提示目錄已存在print('%s 目錄已存在' % path)return Falsedef main():path = 'D:/VideoPhotos/hongshi/'createFile('D:/VideoPhotos/hongshi_rotate')createFile('D:/VideoPhotos/hongshi_flip_horizontal')dirs = os.listdir(path)for dir in dirs:# print(dir)createFile('D:/VideoPhotos/hongshi_rotate/' + dir)createFile('D:/VideoPhotos/hongshi_flip_horizontal/' + dir)images = glob.glob(path + dir + r"/*.jpg")for image in images:image_name = image[image.find("http://"):]print(image_name)rotate_270(image).save('D:/VideoPhotos/hongshi_rotate/' + dir +image_name)flip_horizontal(image).save('D:/VideoPhotos/hongshi_flip_horizontal/' + dir + image_name)if __name__ == '__main__':main()

以上這篇python實現旋轉和水平翻轉的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江达县| 洛隆县| 都昌县| 广德县| 大姚县| 东台市| 时尚| 荃湾区| 赤壁市| 高雄县| 外汇| 屏南县| 泽库县| 南溪县| 枝江市| 德庆县| 夏津县| 河北省| 萨迦县| 泸溪县| 浦东新区| 新安县| 晋中市| 巧家县| 左云县| 遂平县| 昂仁县| 米脂县| 红原县| 哈巴河县| 江门市| 临安市| 葵青区| 红安县| 双鸭山市| 荃湾区| 廊坊市| 信阳市| 太保市| 历史| 海晏县|