;+ ; NAME gif2jpg.pro ; ; PURPOSE Convert GIF images to JPEG format. ; ; SYNTAX gif2jpg, gif_list ; ; HISTORY Andrew L. Stanger HAO/NCAR 27 September 2001 ;- pro gif2jpg, gif_list, disp=disp CLOSE, 11 gif_name = '' xdim_prev = 0 ydim_prev = 0 red = bindgen (256) green = red blue = red ;--- File list loop. OPENR, 11, gif_list WHILE (NOT EOF (11)) DO $ BEGIN ;{ ;--- Read FITS image header & pixel data. READF, 11, gif_name ; Get file name. PRINT, 'gif image : ', gif_name READ_GIF, gif_name, gif_img, red, green, blue imgsz = SIZE (gif_img) xdim = imgsz [1] ydim = imgsz [2] ;--- Convert to byte pixels. ;--- Display image. IF (KEYWORD_SET (disp)) THEN $ BEGIN ;{ TVLCT, red, green, blue IF (xdim NE xdim_prev OR ydim NE ydim_prev) THEN $ WINDOW, xsize=xdim, ysize=ydim TV, gif_img ; Display image. END ;} jpg_img = BYTARR (xdim, ydim, 3) jpg_img [*, *, 0] = red [gif_img [*, *]] jpg_img [*, *, 1] = green [gif_img [*, *]] jpg_img [*, *, 2] = blue [gif_img [*, *]] ;--- Write new image to disk. sloc = RSTRPOS (gif_name, '.gif') new_name = STRMID (gif_name, 0, sloc) + '.jpg' PRINT, 'jpg image : ', new_name WRITE_JPEG, new_name, jpg_img, true=3, quality=75 ; Write new image. xdim_prev = xdim ydim_prev = ydim END ;} CLOSE, 11 END