File Exchange

image thumbnail

gif

version 1.0.0.0 (501 KB) by Chad Greene
An easy gif generator

117 Downloads

Updated 03 Jun 2017

View License

Check out the Examples tab ^^^.

This function is intended to streamline the process of making gifs. Simply call

gif('myfile.gif')

to first the first frame, and then call

gif

to write each subsequent frame. That's it.

Cite As

Chad Greene (2019). gif (https://www.mathworks.com/matlabcentral/fileexchange/63239-gif), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (33)

Javed Iqbal

Can we use the same function on multiple images to save them as a gif? and How??

Rubens

Hi!
Thanks for the function.
To save sequence of images, I have to use imshow(myImage) and gcf. Is it possible to save without visualizing, directly?

Taiwo Fasae

Thanks!

Xinmin Liu

Thanks!

Thanks Chad

Chad Greene

@tanq: Just specify 'frame',gcf to capture the entire figure rather than the default frame (gca), which only captures the current axes. By capturing the entire figure it should include the title.

wave_buoys

Hello Chad, thanks for great work, but how could add the title in loop? thank a lot

Chad Greene

Aidan: To include a colorbar specify 'frame',gcf when calling gif the first time. That will ensure everything within the figure gets giffed. (The default frame is gca, which does not include colorbars outside the current axis.)

Xel Ch

Thanks Ethan. For some reason, I am still getting error messages with the line gif('myfile.gif') . When I comment this part out, the loop works but only runs through one time then stops.

For reference, I have all the code in one file instead of "creating a new gif file" like the example suggests, because I couldn't figure out how to do that. Not sure if that matters as it seems to still work for one loop. Thanks again!

Is there a minimum 'DelayTime'? I seem to be able to increase it beyond the default, but when I go any lower (0.005 for instance), the gif is still only doing 1/15 frames per second.

Alexandar, make sure the gif.m function is in your current directory when calling it

Xel Ch

When I try to use the run the line gif('myfile.gif') , I am given the error message "Cannot find an exact (case-sensitive) match for 'gif'". Any idea how to get around this? Thanks!

A well-documented and easy-to-use function that saved me a lot of time! Thanks, Chad.

Aidan Starr

Great function, however is there a way to include a colorbar in the gif? Cheers,
Aidan

Fei Lu

Dan Sazer

Please disregard my previous question; earlier in the script I had written "hold on" which led to the undesired overlay.

Dan Sazer

Great function! I was wondering if there's a way to remove the alpha channel from each frame? When using this function to make a sequence of plots, all the lines just superimpose over each other.

In response to Fabian . I got the same but then I read the documentation . The command is
web('myfile.gif') put in whatever your gif is called
Thanks
Anselm

Meatloaf

While using the function it only records the first frame. When i use gif to add the subsequent frames nothing happens. I only get a gif with one static frame. Any ideas ?

Meatloaf

Chad Greene

Hi Andrea, thanks for the note. The error you mention is strange--there is no "cq" function in the gif function, and I don't think it's in anything the gif function calls either. Is cq a typo in your script, by chance? If you can post the whole error message that might help us track down the cause.

Andrea

In Matlab 9.2.0.556344 (R2017a) I get the following error when running the example:

Undefined function 'cq' for input arguments of type 'uint8'

Any suggestions?

Updates

1.0.0.0

typo fix.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

gif/html/