Matlab movie to GIF Converter.
Syntax: movie2gif(mov, gifFile, prop, value, ...)
The list of properties is the same like for the command 'imwrite' for the
file format gif:
'BackgroundColor' - A scalar integer. This value specifies which index in
the colormap should be treated as the transparent
color for the image and is used for certain disposal
methods in animated GIFs. If X is uint8 or logical,
then indexing starts at 0. If X is double, then
indexing starts at 1.
'Comment' - A string or cell array of strings containing a comment to be
added to the image. For a cell array of strings, a carriage
return is added after each row.
'DelayTime' - A scalar value between 0 and 655 inclusive, that specifies
the delay in seconds before displaying the next image.
'DisposalMethod' - One of the following strings, which sets the disposal
method of an animated GIF: 'leaveInPlace',
'restoreBG', 'restorePrevious', or 'doNotSpecify'.
'LoopCount' - A finite integer between 0 and 65535 or the value Inf (the
default) which specifies the number of times to repeat the
animation. By default, the animation loops continuously.
For a value of 0, the animation will be played once. For a
value of 1, the animation will be played twice, etc.
'TransparentColor' - A scalar integer. This value specifies which index
in the colormap should be treated as the transparent
color for the image. If X is uint8 or logical, then
indexing starts at 0. If X is double, then indexing
starts at 1
Nicolae Cindea (2019). Movie to GIF Converter (https://www.mathworks.com/matlabcentral/fileexchange/17463-movie-to-gif-converter), MATLAB Central File Exchange. Retrieved .
Reply to Ki, I found out that if you want to have axis and title, you have to use getframe(fig), instead of only getframe
Awesome function! Helped me a lot with the presentation. Thank you so much!!!
Works like a charm.
Is there a way to include the axes, ticks and labels as well?
great script. I had to modify the last line.
great script. Just have one question, seems that the gil will not record anything in the frame title or xlabel or ylabel.
This is the best best best best one.
Gets the job done!
I don't understand why this code hasn't got 5 stars yet. It does what it has to do and is very simple. Very good work!
Very useful - with Keith's and Scott's recommendations.
nevermind, misread documentation
Doesn't work for me get the following error:
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> aRGB2IND at 12
RGBij = double(reshape(RGB(i,j,:), 1, 3)./255);
Error in ==> movie2gif at 75
[IND, map] = aRGB2IND(RGB);
Useful code. I too had to make Keith's mod to initialize the waitbar. Btw, since .gif is 8-bit color you can use [IND, map] = rgb2ind(RGB,256);.
whoops, i just realized that I was playing the gifs in quicktime. They play fine with firefox or some other web-browser.
nice code, but I am having trouble with the color in the gifs that are being created. The movie images I am using have a lot of different colors in them, but the gifs that are created only have shades of white, light blue, dark blue, and black. I am using a bunch of fill3 commands with lighting effects to create the images, so maybe its a problem with the colormap?
Thank you - This is a useful piece of code. To make it work, I had to make the change suggested by Keith Brodie (thanks Keith!). Also, when switching to the internal function rgb2ind, I had to supply an additional input, namely 128. In other words, this line shows up twice in my final code:
[IND, map] = rgb2ind(RGB,128);
Thanks - worked for me. I had to add one line to the movie2gif.m to initialize the waitbar handle in the case of nargin==2.
if (nargin == 2)
h = waitbar(0, 'Generate GIF file...');
Some small bug fixes and ameliorations.
This new version fixed some small bugs.