pro smaller_pixmap, infil, newsize, display=display, rowlen=rowlen
;
;
;HISTORY:
;	Written 1996 by M.Morrison
;	 3-Nov-97 (MDM) - Added ROWLEN
;	10-may-99 (CED) - changed REBIN to CONGRID
;
if (n_elements(rowlen) eq 0) then rowlen = 1024
;
for ifil=0,n_elements(infil)-1 do begin
    outfil = str_replace(infil(ifil), 'pixmap_', 'pixmap'+strtrim(newsize,2)+'_')
    if (outfil eq infil(ifil)) then stop
    ;
    out = rfits(infil(ifil), h=h0)
    ny = n_elements(out(0,*))		;should be 2 or 3
    ;
    img = lonarr(rowlen,rowlen) -1
    img(out(*,1)) = out(*,0)
    img2 = congrid(img, newsize, newsize) 
    ss = where(img2 ne -1, nss)
    out2 = lonarr(nss, ny)
    out2(*,0) = img2(ss)
    out2(*,1) = ss
    if (ny eq 3) then begin
	img(out(*,1)) = out(*,2)
	img2 = congrid(img, newsize, newsize)
	out2(*,2) = img2(ss)
    end
    ;
    if (keyword_set(display)) then begin
	img = bytarr(newsize, newsize)
	img( out2(*,1) ) = out2(*,0)
	tvscl,img
    end
    ;
    h = [mk_fits_head(out2), 'END                                                                             ']
    sxaddpar, h, 'INFILE', infil(ifil)
    sxaddpar, h, 'PROGVER2', 'SMALLER_PIXMAP Run ' + !stime
    sxaddpar, h, 'DISP_SIZ', newsize
    wrt_fits, outfil, h, out2
end

end
;------------------------------------
pro go_smaller_pixmap, ff
;
if (n_elements(ff) eq 0) then ff = findfile('/mdisw/dbase/ops/lists/pixmap_*')
smaller_pixmap, ff, 512, /display
smaller_pixmap, ff, 256, /display
smaller_pixmap, ff, 128, /display
smaller_pixmap, ff,  64, /display
end
