Commit c238efbd by BellCodeEditor

save project

parent 6f3517e6
Showing with 49 additions and 0 deletions
from PIL import Image,ImageSequence
from tkinter import filedialog
from tkinter import Tk
from os import system
sc=input("请选择加工方式(1合成gif,2倒放gif):")
def make_gif():
w=Tk()
w.withdraw()
path = filedialog.askopenfilenames(title='选择图片文件',
filetypes=[("png", ".png .jpg .bmp .jpeg")],
initialdir="./")
imgl=[]
for i in path:
img = Image.open(i)
imgl.append(img)
imgl[0].save("MyGIF.gif",save_all=True,append_images=imgl[1:])
def replay_gif():
w=Tk()
w.withdraw()
path = filedialog.askopenfilename(title='选择动图文件',
filetypes=[("动态图片", ".gif")],
initialdir="./")
img=Image.open(path)
nmp=0
for i in ImageSequence.Iterator(img):
i.save("./Img.TMP\\"+str(nmp)+".tmp.png")
nmp+=1
imgl=[]
for i in range(nmp):
img = Image.open("./Img.TMP\\"+str(i)+".tmp.png")
imgl.insert(0,img)
imgl[0].save("MyGIF.gif",save_all=True,append_images=imgl[1:])
system("del Img.TMP")
if sc=="1":
make_gif()
elif sc=="2":
replay_gif()
dive.gif

1.9 MB

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