pro summary_plot,list,outdir=outdir
;
;+
; NAME:
;	SUMMARY_PLOT
;
; PURPOSE:
;	This procedure writes gif files of up to 25 browse images per file
;       from the list of images
;
; CATEGORY:
;	UTIL
;
; CALLING SEQUENCE:
;	SUMMARY_PLOT,List
;
; INPUTS:
;	List:	A string array of the filenames to be used
;
; KEYWORD PARAMETERS
;	OUTDIR:	If set, specifies the output directory to write the images to.
;		If not set, writes to the users' home directory
;	
; OUTPUTS:
;	A series of files are written.
;
; SIDE EFFECTS:
;
; RESTRICTIONS:
;	At this time, the page size, the number of images/page, and
;	the image annotation is coded into the routine.  
;
;	It is easy to add a branch point for different number of images
;	per page, i.e., 25, 36, etc.  It is not clear how to change
;	the annotation.
;
;
; PROCEDURE:
;	Make gifs that are 650 by 900.  Portrait mode
;
; EXAMPLE:
;
; MODIFICATION HISTORY:
; 	Written by:	M.D. Andrews, 18 Aug 1997
;	Modifications:
;	19 Oct 1998	RAH	use lasco_readfits, test for bad image
;
;	%W% %H% LASCO IDL LIBRARY
;-
window,retain=2,xsize=650,ysize=940,/free
loadct,0
tvlct,r,g,b,/get
;
IF (KEYWORD_SET(outdir)) THEN outputdir=outdir ELSE outputdir=getenv('HOME')
IF (outputdir NE '') THEN outputdir=outputdir+'/'
;
nn=n_elements(list)
;
;  Enter number of frames/page and number or rows and collumns.
;
nf=25
nr=5
nc=5
;
np=(nn/nf)
;
;  Next for loops to make the plots.
;
	for i=0,np do begin
erase
;
		for j=0,nr-1 do begin
;
			for k=0,nc-1 do begin
;
index=i*nf + j*nc + k     ; Image Index
if index eq nn then goto, done
print,'Processing Image',index
;
;  Calculate coordinates for image and labels.
;
ix=k*130
iy=5 + (4-j)*170 + 40
y1=iy+103
y2=iy-20
y3=iy-40
;
;  Read image, resize, extract info from headers, plot and label.
;
img=lasco_readfits(list(index),h,/fits)
IF (img(0) NE -1)  THEN BEGIN
   q=where(img gt 0,nw)
   IF (nw GT 0)  THEN img=img-min(img(q))
   sd=stdev(img(q),mn)
   print,max(img),sd,mn
   sf=max([sd,mn])
   img=CONGRID(img,100,100)
ENDIF ELSE img=bytarr(100,100)
name=sxpar(h,'filename')
filter=sxpar(h,'filter')
polar=sxpar(h,'polar')
wave=sxpar(h,'waveleng')
;
label1=strtrim(filter,2)+' '+strtrim(polar,2)
label2=string(wave)
np=strpos(label2,'.')-4
label2=strmid(label2,np,6)+'nm'
;
tv,bytscl(img,0,sf),ix,iy,/device
;
xyouts,ix,y1,name,/device,col=255,size=1.5
xyouts,ix,y2,label1,/device,col=255,size=1.5
xyouts,ix,y3,label2,/device,col=255,size=1.5
;
		    endfor
;
	    endfor
;
done:
;
out=outputdir+'frame'+strtrim( string(i),2)+'.gif'
t=tvrd()
print,out
write_gif,out,t,r,g,b
;
      endfor
;
return
;
end
