[Mapserver-users] GIF animation made simple

Charlton Purvis cpurvis at asg.sc.edu
Wed Apr 23 13:01:04 EDT 2003


My first-pass at animation included SWF output, but probably because of
my own ignorance, I never hit a homerun.  So I looked at the animated
GIF approach.

The idea of this example uses a .map file that has a base elevation
layer (raster) and 5 storm surge flooding polygon layers.  The .html
page allows the user to choose how many surge layers ($num_cats) to
display as part of the animation (the base layer (0) is always
included).

$anim_gif_cmd = "/usr/local/bin/gifsicle -l -d 100 -O2 ";

 for ($i = 0; $i <= $num_cats; $i++) {
   if ($i > 0) {
     $layer_obj[$i] = $map->getLayer($i);
     $layer_obj[$i] -> set("status",MS_ON);
   }
   $image[$i]     = $map->draw();
   $image_url[$i] = $image[$i]->saveWebImage(MS_GIF,1,1,0);
   $file_path[$i] = $map->web->imagepath 
                    . substr(strrchr($image_url[$i], "/"),1);
   $anim_files   = $anim_files . $file_path[$i] . " ";
 }

 // Create a unique filename and URL for the animated GIF output
 $anim_name = "anim".substr(strrchr($image_url[0], "/"),1);
 $anim_path = $map->web->imagepath . $anim_name;
 $anim_url = $map->web->imageurl . $anim_name;

 system($anim_gif_cmd . " -o " . $anim_path . " " .  $anim_files); 
 
Tool used is http://www.lcdf.org/~eddietwo/gifsicle/.  Originally I
tried used whirlgif (http://www.danbbs.dk/~dino/whirlgif/), but gifsicle
rendered a GIF one-third the size of a whirlgif animation.  So I'm
sticking w/ gifsicle until I find something better.

 


Charlton Purvis
(803) 777-8858 : voice
(803) 777-8833 : fax
cpurvis at sc.edu
 
Advanced Solutions Group
Department of Physics and Astronomy
University of South Carolina
Columbia, SC 29208




More information about the mapserver-users mailing list