gnome.utilities.images2gif

MODULE images2gif

Provides a function (writeGif) to write animated gif from a series of PIL images or numpy arrays.

Added as a handy utility to the py_gnoe code.

Adapted form code from:

Almar Klein (June 2009)

  • based on gifmaker (in the scripts folder of the source distribution of PIL)

  • based on gif file structure as provided by wikipedia

This code is provided as is, and is free to use for all.

Module Contents

Functions

intToBin(i)

Integer to two bytes

getheaderAnim(im)

Animation header. To replace the getheader()[0]

getAppExt([loops])

Application extention. Part that secifies amount of loops.

getGraphicsControlExt([duration])

Graphics Control Extension. A sort of header at the start of

_writeGifToFile(fp, images, durations, loops)

Given a set of images writes the bytes to the specified stream.

writeGif(filename, images[, duration, loops, dither])

writeGif(filename, images, duration=0.1, loops=0, dither=1)

Attributes

PIL

np

im

gnome.utilities.images2gif.PIL
gnome.utilities.images2gif.np
gnome.utilities.images2gif.intToBin(i)

Integer to two bytes

gnome.utilities.images2gif.getheaderAnim(im)

Animation header. To replace the getheader()[0]

gnome.utilities.images2gif.getAppExt(loops=0)

Application extention. Part that secifies amount of loops. if loops is 0, if goes on infinitely.

gnome.utilities.images2gif.getGraphicsControlExt(duration=0.1)

Graphics Control Extension. A sort of header at the start of each image. Specifies transparancy and duration.

gnome.utilities.images2gif._writeGifToFile(fp, images, durations, loops)

Given a set of images writes the bytes to the specified stream.

gnome.utilities.images2gif.writeGif(filename, images, duration=0.1, loops=0, dither=1)

writeGif(filename, images, duration=0.1, loops=0, dither=1) Write an animated gif from the specified images. images should be a list of numpy arrays of PIL images. Numpy images of type float should have pixels between 0 and 1. Numpy images of other types are expected to have values between 0 and 255.

gnome.utilities.images2gif.im