python动画制作库,在Python中生成动画GIF

I'm trying to generate an animated GIF using images2gif.py (pastebin to the most recent verson : bit.ly/XMMn5h ).

I'm using this Python script:

__author__ = 'Robert'

from images2gif import writeGif

from PIL import Image

import os

file_names = sorted((fn for fn in os.listdir('.') if fn.endswith('.gif')))

#['animationframa.png', 'animationframb.png', ...] "

images = [Image.open(fn) for fn in file_names]

size = (150,150)

for im in images:

im.thumbnail(size, Image.ANTIALIAS)

print writeGif.__doc__

filename = "my_gif.GIF"

writeGif(filename, images, duration=0.2)

However, I am getting the following error:

File "C:\Python27\lib\images2gif.py" , line 418, in writeGifToFile

globalPalette = palettes[ occur.index(max(occur)) ] ValueError: max()

arg is an empty sequence

It seems to me that occur is empty. What is wrong, and is there a better way?

解决方案

OK I have tested your exact code on two different machines, and it works perfectly on both. One machine is Ubuntu 12.04 and the other is running Windows XP. They are both using Python 2.7, and the latest version of images2gif which I downloaded from here. I recommend the following:

check what version of python and the libraries you are using, try and get the latest ones.

test it on another machine

try and uninstall python and all the libraries and try and re-install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值