File Exchange

image thumbnail

Tools to read and write animated gif files

version 2.1.1.0 (7.3 KB) by DGM
Functions to read and write animated gifs to and from 4-D RGB image arrays

8 Downloads

Updated 18 Jun 2018

View License

These functions can be used to read and write animated gifs. They are intended for use with 4-D image arrays of various type. Supported types include RGB/RGBA arrays, as well as indexed images. Indexed mages with transparent content can be specified by a corresponding vector of indices, or by simply appending an alpha channel to the image array itself. When writing, colormaps, transparency, and disposal method can be specified per-frame or globally.
.
Optional functionality requires the use of imagemagick and is exclusively intended to work in a *nix environment, but default settings should work on other systems. I have no intention of modifying this to be more robust in that aspect.
.
====================
.
GIFREAD(FILEPATH, {KEYWORDS})
reads all frames of an animated gif into a 4-D image array
.
====================
.
GIFWRITE(INARRAY, {DISPOSALMETHOD}, FILEPATH, {DELAY}, {WRITEMETHOD})
GIFWRITE(INARRAY, MAP, {TRANSPARENTIDX}, {DISPOSALMETHOD}, FILEPATH, {DELAY}, {WRITEMETHOD})
Write image stack to an animated gif

Comments and Ratings (3)

DGM

Jack: That sounds reasonable. I've added that to the todo list.

Great gifwrite(). How about having a frame range for gifread() so one can efficiently test methods used on large GIFs, for example?

Updates

2.1.1.0

fixed a bug for logical & single-frame images (gifwrite)

2.1.0.0

fixed description

2.1.0.0

Fixed some handling of TCIDX, some documentation errors.
Better support for importing transparent images with specified disposal methods

2.0.1.0

forgot to include MIMT dependencies

2.0.0.0

removed mapping toolbox dependency
added class flexibility as well as some indexed image, & transparency support

1.2.0.0

added automatic expansion on dim 3 and a bit of input class flexibility to GIFWRITE()

1.1.0.0

added thumbnail image

1.1.0.0

fixed archive problem again

1.1.0.0

fixed archive mistake

1.1.0.0

changed both functions to utilize /dev/shm instead of hard disk for temporary file creation when using optional 'imagemagick' modes; also increased speed and quality of 'imagemagick' mode in gifwrite.m

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux