Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

python imaging library - Error in images2gif.py with GlobalPalette

Getting an error when trying to convert sequence of jpgs to gifs. Can't seem to figure out how to add a palette, or if that's the actual problem. Was able to get gifs to load using the numpy arrays in the images2gif.py main.

import PIL
from PIL import Image
import StringIO
import images2gif

images = []
for frame in animation1.frames:
    img_data = s3manager.get_file_as_string(frame.s3_filename)
    image = Image.open(StringIO.StringIO(img_data))
    images.append(image)

images2gif.writeGif('lala3.gif', images, duration=0.5, dither=0)  

With this I get the following error:

"images2gif.py", line 436, in writeGifToFile
  fp.write(globalPalette)
TypeError: must be string or buffer, not None

Not sure how to specify a palette for these jpgs. documentation unclear to me, and not even sure if that's the issue. help?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In images2gif.py change line 200:

for im in images:
    palettes.append( getheader(im)[1] )

to

for im in images:
    palettes.append(im.palette.getdata()[1])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...