;+
pro make_cmap_gifs, cam, wl, rad, SAVE=save, CONTROL=control, INPUT=input

; Front end to cmap2gif.pro
;
; INPUTS:
;  cam	'c2' or 'c3' or 'eit'
;  wl	'wl' or 'el' or '195' or '304' or '284' or '171'
;  rad	search string representing radius; for c2 or c3 only
;
; KEYWORDS:
;  SAVE='/output/directory/'
;  /CONTROL	Set if you want to control min and max for each image
;  INPUT=string_array	Contains list of FITS files to turn into GIFs
;
; N. Rich, NRL, 28Mar02
;
; Modified:
;  08.04.28, nbr - Use concat_dir for save dir
;  03.05.15, nbr - Modify default save directory
;  02.06.06, nbr - Add keyword definitions
;
; %H% %W% : NRL LASCO IDL Library
;
; -

IF not(keyword_set(INPUT)) THEN BEGIN
   cam = strlowcase(cam)
   wl  = strlowcase(wl)
   IF cam EQ 'eit' THEN rad='mer'
   list=findfile('$cmap/'+cam+'/'+cam+wl+'*'+rad+'.fts')
ENDIF ELSE list = input
n=n_elements(list)
sdir = '.' 
IF keyword_set(SAVE) THEN sdir = save
controlflag=1	; always do first image
FOR i=0,n-1 DO BEGIN
   gifim = cmap2gif(list(i), ROOT=root,CONTROL=controlflag)
   IF ~keyword_set(CONTROL) THEN controlflag=0
   outfil=concat_dir(sdir,root+'.gif')
   print,'Saving ',outfil
   write_gif,outfil,gifim
ENDFOR

end
