Commit d361f51c by BellCodeEditor

auto save

parent 896375fd
from tkinter import filedialog,Tk # 导入tkinter模块中的filedialog,Tk模块
from PIL import Image # 导入PTL模块中的Image模块
# 创建窗口对象
rt=Tk()
rt.withdraw()
# 参数1设置选择图片文件,参数2设置文件类型和后缀,参数3指定文件操作窗口的默认路径
path=filedialog.askopenfilenames(title='选择图片文件',
filetypes=[('png','.png')],
initialdir='./')
img_list = [] # 建立空列表img_list
for i in path: # for循环
img = Image.open(i) # Image.open()方法参数为i赋值给变量img
img_list.insert(0,img) # 列表名.append()方法参数为img
# 生成GIF动图
# 参数1文件命名,参数2save_all设为True,参数3append_images设为img_list[1:]取出第二到结尾所有图
img_list[0].save("dive.gif",save_all=True,
append_images=img_list[1:])
\ No newline at end of file
from PIL import Image,ImageSequence # 导入PIL模块中的Image,ImageSequence模块
img = Image.open("dive.gif") # Image.open()方法读取gif动图
num = 0 # 变量num设为0
# for循环对动图里每一帧静图进行遍历
for i in ImageSequence.Iterator(img):
i.save("img/"+str(num)+".png") # 这里把分解到的每一张静态图保存到当前目录下
num += 1 # 每次循环遍历num增加1
img/0.png

48.4 KB

img/1.png

47.9 KB

img/10.png

52.1 KB

img/11.png

52.6 KB

img/12.png

51.8 KB

img/13.png

51.4 KB

img/14.png

50.2 KB

img/15.png

50.9 KB

img/16.png

50.2 KB

img/17.png

50.2 KB

img/18.png

50.1 KB

img/19.png

50.1 KB

img/2.png

47.7 KB

img/20.png

49.8 KB

img/22.png

50.2 KB

img/23.png

50.1 KB

img/24.png

50.3 KB

img/25.png

50.9 KB

img/26.png

49.9 KB

img/27.png

48.9 KB

img/28.png

49.1 KB

img/29.png

49.6 KB

img/3.png

48.3 KB

img/30.png

49.4 KB

img/32.png

49.1 KB

img/33.png

49.3 KB

img/35.png

48.4 KB

img/36.png

48.2 KB

img/4.png

48.2 KB

img/5.png

49.1 KB

img/6.png

50.1 KB

img/8.png

51.7 KB

img/9.png

52.1 KB

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment