Tools to read and write animated gif files

Version 2.8 (23.4 KB) by DGM
Tools from MIMT to read/write multiframe GIFs
1.1K Downloads
Updated 4 Jul 2024
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
Since R2018b, there are extant bugs in the support files for imread() which cripple MATLAB's ability to read most GIF files without destructive alteration or complete loss of image data. I alone am in no position to motivate a bugfix or troubleshoot versions after R2019b. Until I write a complete replacement for the GIF functionality of imread/imfinfo, be very careful that your data isn't being damaged by MATLAB.
These tools are merely a subset of the Matlab Image Manipulation Toolbox (FEX)

Cite As

DGM (2024). Tools to read and write animated gif files (https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.8), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on View and Analyze Simulation Results in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
2.8

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.8

2.7

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.7

2.6.0.0

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.6

2.5.0.0

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.5

2.4.1.0

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.4.1

2.4

See release notes for this release on GitHub: https://github.com/291ce4321ac/MIMT-gif-tools/releases/tag/v2.4

2.3.3

Synopsis edit and minor support file update.

2.3.2.4

Updated bug notice in gifread.m to reflect state of current regression.

2.3.2.3

ughfg

2.3.2.2

i swear. we've gone from one janky description editor to another

2.3.2.1

description update

2.3.2

reduced temporary memory footprint during output array allocation

2.3.1

a couple bugfixes and a note about pending issues with versions R2018b and up

2.3.0

dependency update

2.2.0

gifread now supports input frame ranges as per request
gifwrite supports vectorized frame delay

2.1.1.0

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

2.1.0.0

fixed description
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

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
fixed archive problem again
fixed archive mistake
added thumbnail image

1.0.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.