片格式转换:HEIC ->JPG
1、Python 3.6 安装 pillow:
pip3 intall pillow
2、当前目录下,heic格式转换完成,加了一个10s等待
time.sleep(10)
3、说明
os(用于文件和目录操作)
Pillow中的Image(用于图像处理)
heic-to-jpg.py脚本
from PIL import Image
import os
import time
# 获取当前目录下所有文件及文件夹
files = os.listdir()
for file in files:
if file.endswith(".heic"):
# 打开HEIC图片
image = Image.open(file)
# 保存为JPG格式
new_name = os.path.splitext(file)[0] + ".jpg"
image.save(new_name)
print("Now change ", file, " to ", new_name)
time.sleep(10)
print("Done")
脚本运行结果显示
参考
[1] https://blog.csdn.net/x1131230123/article/details/129195913