View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Web-browser viewable GUI animations of .PNGs, .GIFs, etc.

4.3 | 3 ratings Rate this file 4 Downloads (last 30 days) File Size: 2.53 MB File ID: #36052 Version: 1.5
image thumbnail

Web-browser viewable GUI animations of .PNGs, .GIFs, etc.


Kevin Bartlett (view profile)


06 Apr 2012 (Updated )

Creates javascript/html GUI-driven animation of still images (GIFs, JPEGs, etc.).

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

Let's say you have 24 .png graphics files you have generated in Matlab. You would like to view them as an animation, so you convert them to a movie format like .avi or .mpeg, with each graphics file being a separate frame of the movie.

There are three problems with the resulting movie:

  (1) You find you can't view it on certain platforms or without installing a particular piece of software; bewildering messages about "missing codecs" appear on your screen when you try to view the movie on a Linux machine.

  (2) The movie file is HUGE, despite consisting of only 24 frames.

  (3) The image quality is much worse than in the original graphics files.

The solution to these problems is to view the animation with a javascript/html page that cycles through each individual graphics file in turn. Such a page is portable, being viewable in any javascript-enabled Web browser; its size is not much larger than the sum of its frames; and the image quality is the same as that of the original graphics files. The result is much like an animated GIF, except that the animation can be paused, sped up, etc., using the javascript GUI controls.

jsanim.m allows you to generate a browser-viewable javascript/html GUI page for viewing animations of any browser-compatible graphics file type (.gif, .png, .jpg, etc.).

jsanim.m has numerous options, but at its simplest, it can be called with the syntax:

where fileList is a cell array of filenames of image files. The resulting html file can be opened in a Web browser.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
03 Mar 2014 David

David (view profile)

Great routine! Hate to be greedy but I would love more controls, esp the ability to step forward and backwards one frame at a time.

11 Jul 2012 TideMan

This is an excellent routine that produces high quality .html files. The facility for having a background with transparent overplots is especially good. I found I needed to use export_fig to produce the transparent .png images.

19 May 2012 Matthew

Nice work. Detailed help provided.

30 Apr 2012 1.1

Added some troubleshooting tips to the documentation.

19 Sep 2013 1.5

Bugfixes pointed out by TideMan. Now possible to change frameDelays and loopPauses from their default values.

Contact us