使用wxpython向面板插入动图,但是尺寸不太符合要求,尝试使用以下代码改变gif尺寸但是无效。
def aaa(self,event):
if not self.teams:
wx.MessageBox('抽奖次数已用完,请重新启动!')
return
self.bb=wx.Frame(self,-1,style=wx.SIMPLE_BORDER | wx.TRANSPARENT_WINDOW )#,size=(1500,1024)
self.animation = AnimationCtrl(self.bb,size=(1000,800))
# self.animation.LoadFile(r'C:\Users\gztsrayz\Desktop\img\new.gif')
self.animation.Load(self.pngSize(r'C:\Users\gztsrayz\Desktop\img\new.gif',1000,1000))
self.animation.Play()
self.bb.Fit()
self.bb.Center()
self.bb.Show()
b = threading.Thread(target=self.cc, daemon=True)
b.start()
def cc(self):
time.sleep(2.65)
# time.sleep(.5)
self.bb.Destroy()
from PIL import Image, ImageSequence
def fk():
gifPath = r'C:\Users\gztsrayz\Desktop\img\d7c.gif'
oriGif = Image.open(gifPath)
lifeTime = oriGif.info['duration']
imgList = []
for i in ImageSequence.Iterator(oriGif):
print(i.copy())
imgList.append(i.copy())
for index, f in enumerate(imgList):
f.save(r'C:\Users\gztsrayz\Desktop\img\ff\%d.png' % index)
def pj():
gifPath = r'C:\Users\gztsrayz\Desktop\img\d7c.gif'
oriGif = Image.open(gifPath)
lifeTime = oriGif.info['duration']
imgList = []
imgNew = []
for i in ImageSequence.Iterator(oriGif):
print(i.copy())
imgList.append(i.copy())
for index, f in enumerate(imgList):
f.save(r'C:\Users\gztsrayz\Desktop\img\ff\%d.png' % index)
img = Image.open(r'C:\Users\gztsrayz\Desktop\img\ff\%d.png' % index)
# img.thumbnail((1800, 1200), Image.LANCZOS)
img.resize((1200,1200))
imgNew.append(img)
imgNew[0].save(r"C:\Users\gztsrayz\Desktop\img\new.gif", 'gif', save_all=True, append_images=imgNew[1:], loop=0,
duration=lifeTime)
oriGif.close()