Tools to read and write animated gif files (2024)

You are now following this Submission

  • You will see updates in your followed content feed
  • You may receive emails, depending on your communication preferences

Version 2.7 (16.1 KB) by DGM

Tools from MIMT to read/write multiframe GIFs

Follow

  • Share
  • Open in MATLAB Online

  • Download

  • Overview
  • Functions
  • Version History
  • Reviews (4)
  • Discussions (4)

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.

https://www.mathworks.com/matlabcentral/answers/654298-nonsensical-imread-behavior-with-multiframe-gifs-in-r2019b

https://www.mathworks.com/matlabcentral/answers/893347-is-there-a-bug-in-imread-or-imfinfo-with-multiframe-gifs-in-r2021a-b

https://www.mathworks.com/matlabcentral/answers/1902680-could-someone-help-me-to-import-individual-jpeg-images-embedded-in-a-gif-image-into-each-slide-in-a#answer_1162021

These tools are merely a subset of the Matlab Image Manipulation Toolbox (FEX)

https://www.mathworks.com/matlabcentral/fileexchange/53786-image-manipulation-toolbox

Cite As

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

Requires

Some options require imagemagick and are platform-dependent

MATLAB Release Compatibility

Created with R2009b

Compatible with any release

Platform Compatibility

Windows macOS Linux

Categories
  • Simulink > Simulation > View and Analyze Simulation Results >

Find more on View and Analyze Simulation Results in Help Center and MATLAB Answers

Tags Add Tags

animation graphics export graphics import image processing

Community Treasure Hunt

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

Start Hunting!

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor

giftools

  • gifread
  • gifwrite
  • hasipt
  • imcast
  • imclassrange
  • imrange
  • imrescale
  • isimageclass
  • quietwarning
  • strismember
Version Published Release Notes
2.7

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

Download

2.6.0.0

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

Download

2.5.0.0

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

Download

2.4.1.0

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

Download

2.4

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

Download

2.3.3

Synopsis edit and minor support file update.

Download

2.3.2.4

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

Download

2.3.2.3

ughfg

Download

2.3.2.2

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

Download

2.3.2.1

description update

Download

2.3.2

reduced temporary memory footprint during output array allocation

Download

2.3.1

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

Download

2.3.0

dependency update

Download

2.2.0

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

Download

2.1.1.0

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

Download

2.1.0.0

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

Download

2.0.1.0

forgot to include MIMT dependencies

Download

2.0.0.0

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

Download

1.2.0.0

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

Download

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

Download

1.0.0.0

Download

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

.

Tools to read and write animated gif files (3)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

Contact your local office

Tools to read and write animated gif files (2024)
Top Articles
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated:

Views: 5931

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.