Commit 05fcec2d by BellCodeEditor

save project

parent 2b3ba018
Showing with 43 additions and 12 deletions
from PIL import Image
from PIL import Image,ImageSequence
from tkinter import filedialog
from tkinter import Tk
from os import system
w=Tk()
w.withdraw()
path = filedialog.askopenfilenames(title='选择图片文件',
filetypes=[("png", ".png")],
initialdir="./")
sc=input("请选择加工方式(1合成gif,2倒放gif):")
imgl=[]
for i in path:
img = Image.open(i)
imgl.append(img)
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()
imgl[0].save("MyGIF.gif",save_all=True,append_images=imgl[1:])
print(path)
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