[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20030106: how to display loop of images in a webpage



>From: Sridharareddy Duggireddy <address@hidden>
>Organization: USF
>Keywords: 200301061638.h06Gcdt04784 McIDAS web animated GIF

Sridhara,

>I have tried the mcidas commands you have given for displaying the loop
>of images. They are working. I have to loop these images in a webpage.

The typical approach that sites use for looping images in web pages
is to use a Java applet GIF looper.  This is what we do in:

http://mcdemo.unidata.ucar.edu

>For displaying the single image I was doing like this.
>
>First I was calling the following command from a shell script
>"  mcenv -g 32 -i 128 -f "$geom" $MYBIN/mk_mcsfcloop datasetname imagename "
>
>Then in mk_mcsfcloop i was calling the commands
>  sfcplot.k PLOT OLAY FRAME
>  sfccon.k PMSL OLAY FRAME
>
>and Then I was saving the image using
>
>  frmsave.k 1 imagename.

Right.  Here you have a single GIF image that is easily displayed using
the <img> tag approach that Jim Koermer's example uses.

>Then i was coming back to shell script and displaying the image using
><img> tag.

Right.

>Now in order to display the loop of images I should have 10 frames . How
>can i create 10 frames using mcenv?

'mcenv' allows you to create a frame or a number of frames.  Here is the
online help for 'mcenv' you can get in McIDAS:

HELP mcenv
mcenv -- execute in a McIDAS environment
  mcenv [-f <framespec>]... [-e <bytes>] [prog arg...]
Remarks:
  Command line arguments:
     -f <framespec>  specifies a set of frames to include in the
                     McIDAS environment

                     A <framespec> of the form address@hidden in which N, L,
                     and E represent integers, and x is the small
                     letter x, means to allocate N frames of L lines
                     by E elements.

                     A <framespec> of the form LxE means to allocate
                     1 frame of L lines by E elements.

                     A <framespec> of the form N means to allocate N
                     frames of 480 lines by 640 elements.

                     Multiple -f options can be given in order to
                     specify frames of different sizes.

                     If there are no -f options, the default
                     environment is as if ``-f address@hidden'' were
                     given.

     -e <bytes>      specifies how large to make the MAKFRM free
                     space pool in the McIDAS environment

                     The <bytes> number can be suffixed with a k or
                     an m, for kilobytes or megabytes.

                     If there is no -e option, the default
                     environment is as if ``-e 0'' were given.

     -g <number>     specifies number of graphics color levels
                     (McIDAS-X only)

     -i <number>     specifies number of image color levels
                     (McIDAS-X only)

     prog arg...     program to run in the McIDAS environment

                     If no program is specified, the default
                     program to run is $SHELL.

  The mcenv command creates an environment (shared memory block) and
  then forks and execs the given program.  When the program exits,
  mcenv removes the shared memory object and exits.

  mcenv processes can nest; commands run under an inner mcenv can
  not see or affect the environment created by the outer mcenv.
----------

'mcenv' defaults to the creation of a single frame of 480x640 with 48
image colors and 8 graphic color levels.  If you wanted to create a
mini-session using 'mcenv' that is 10 800x600 frames long with 64 image
levels and 16 grphic color levels, you would use a construct like:

mcenv address@hidden -g 16 -i 64 << EOF

imgdisp.k RTIMAGES/GE-IR ALL=1 10 STA=KTBW EU=IMAGE MAG=2 SF=YES REFRESH='EG 
(GRA);BAR GRA=(GRA);MAP H GRA=(GRA)'
lb.k 1 10
wait.k 5
loopit.k \"SFCPLOT T OLAY FRAME
loopit.k \"SFCCON PMSL OLAY FRAME
frmsave.k 1 frame1.gif
frmsave.k 2 frame2.gif
frmsave.k 3 frame3.gif
# etc.
exit

EOF

You can use the McIDAS REPEAT command to save GIFs of each frame in one
go as follows:

mcenv address@hidden -g 16 -i 64 << EOF

te.k SAVEFRM \"FRMSAVE !1 frame!1.gif
imgdisp.k RTIMAGES/GE-IR ALL=1 10 STA=KTBW EU=IMAGE MAG=2 SF=YES REFRESH='EG 
(GRA);BAR GRA=(GRA);MAP H GRA=(GRA)'
lb.k 1 10
wait.k 5
loopit.k \"SFCPLOT T OLAY FRAME
loopit.k \"SFCCON PMSL OLAY FRAME
repeat.k SAVEFRM 1 TO 10 BY 1

exit

EOF

You may have to escape the '!1':

te.k SAVEFRM \"FRMSAVE \!1 frame\!1.gif

>I think i have to store these images
>and display them.

Yes, you should create a GIF of each image and then use a GIF looper.

>in the previous mail
>you have given commands to display the loop of images.

Yes, in McIDAS, not in a web page.

>How should i use them in the shell script. That means where shall i
>use .k extension for example in "LOOPIT "SFCPLOT PLOT OLAY FRAME" , LB 1
>10, DR 9*3 20 " ?

loopit.k \"SFCPLOT PLOT OLAY FRAME
lb.k 1 10

>How should i display these 10 images in a webpage using <img> tag ?

If you don't want to use a GIF looper, you can do something like
save each frame into its own GIF file, and then use ImageMagick
(available in Linux) to create an animated GIF.  Once you have an
animated GIF, you can display it in the exact same way as you do a
single frame GIF.  The ImageMagick function to use is 'convert'.
Here is a simple example of using 'convert' to create a single
animated GIF file out of 10 GIF files:

#!/bin/csh -f
convert \
         -loop 9999 \
         -delay 50 \
         frame1.gif \
         frame2.gif \
         frame3.gif \
         frame4.gif \
         frame5.gif \
         frame6.gif \
         frame7.gif \
         frame8.gif \
         frame9.gif \
         -delay 200 \
         frame10.gif \
         GE-IRloop.gif

The resultant animated GIF loop will pause '50' time increments (this
is platform-dependent) on the first 9 frames and '200' time increments
on the last frame of the loop.

>Please explain the above questions

If you are interested in the Java GIF looper approach, I can bundle
up the Java applet we use (developed by Tom Whittaker of SSEC) and
make it available to you.  Personally, I think the animated GIF approach
is a good one to get started with.

> regards,
> Sridhara.

Tom


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.