;+ ; NAME gifjpg.pro ; ; PURPOSE Convert a GIF image to JPEG format. ; ; SYNTAX gifjpg, gif_name ; ; HISTORY Andrew L. Stanger HAO/NCAR 30 January 2003 ;- pro gifjpg, gif_name, disp=disp CLOSE, 11 red = bindgen (256) green = bindgen (256) blue = bindgen (256) ;--- 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 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. CLOSE, 11 END