PRO mk_tiffp, file, img, r, g, b, xs=xs, ys=ys, noflip=noflip, $
        xresol=xresol, yresol=yresol, interp=interp
;   ----------------------------------------------------------------


        IF N_PARAMS() eq 0 then BEGIN
          print, 'mk_tiffp, file, img, r, g, b, xs=xs, ys=ys,',$
        ' noflip=noflip, xresol=xresol, yresol=yresol, interp=interp'
        ENDIF ELSE BEGIN

          IF Keyword_set(noflip) THEN BEGIN
;       Do nothing in this case.        
          ENDIF ELSE BEGIN              ;default case- must flip
            img2 = reverse(img,2)   ;flip image vertically
          ENDELSE

          If (not Keyword_set(xs)) or (not keyword_set(ys)) THEN BEGIN
            Print, 'Returned Image will be 508x508'
            xs = 508 & ys = 508         ;default size
          ENDIF
          sinfo = size(img)
          If (sinfo(1) ne xs) or (sinfo(2) ne ys) THEN BEGIN
            Print, 'Image Resized to ',xs,'x',ys
            IF keyword_set(interp) then begin
              img2 = congrid(img2, xs, ys, /interp)
            ENDIF ELSE begin
              img2 = congrid(img2, xs, ys)  ;no interpolation
        ENDELSE
      ENDIF

          IF not Keyword_set(xresol) THEN BEGIN
            xresol = 100
          ENDIF
          IF not Keyword_set(yresol) THEN BEGIN
            yresol = 100
          ENDIF

          IF (n_elements(file) eq 0) THEN BEGIN
            file = ''
            READ, 'Enter Tiff Output FileName: ', file
          ENDIF ELSE BEGIN
            IF (file eq '') THEN BEGIN        ;null
              READ, 'Enter Tiff Output FileName: ', file
            ENDIF
          ENDELSE
          IF Keyword_set(noflip) THEN BEGIN
            tiff_write, file, img2, RED=r, GREEN=g, BLUE=b, $
              xresol=xresol, yresol=yresol
          ENDIF ELSE BEGIN                    ;flipped image output
            tiff_write, file, img2, 1, RED=r, GREEN=g, BLUE=b, $
              xresol=xresol, yresol=yresol
          ENDELSE
          Print, 'Palette Color Tiff file, ', file, ', has been created.'
    ENDELSE

    END