# include "data.h"

int save (int argc, char **argv) {
  
  int N, celestial;
  int Ximage, Nimage;
  
  Nimage = -1;
  if ((N = get_argument (argc, argv, "-n"))) {
    remove_argument (N, &argc, argv);
    Nimage = atof (argv[N]);
    remove_argument (N, &argc, argv);
  }
  if (!GetImage (&Ximage, &Nimage)) return (FALSE);

  celestial = FALSE;
  if ((N = get_argument (argc, argv, "-c"))) {
    remove_argument (N, &argc, argv);
    celestial = TRUE;
  }

  if (argc != 3) {
    gprint (GP_ERR, "USAGE: save (overlay) <filename> [-c]\n");
    gprint (GP_ERR, "  -c: write contour in celestial coords\n");
    return (FALSE);
  }

  KiiSaveOverlay (Ximage, celestial, argv[1], argv[2]);
  return (TRUE);
}
