Index: /trunk/Ohana/src/addstar/src/ReadImageHeader.c
===================================================================
--- /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12486)
+++ /trunk/Ohana/src/addstar/src/ReadImageHeader.c	(revision 12487)
@@ -5,5 +5,5 @@
 int ReadImageHeader (Header *header, Image *image, int photcode) {
 
-  int Nastro, ccdnum, hour, min;
+  int Nastro, ccdnum, hour, min, Nx, Ny;
   double tmp, sec;
   char *c, photname[64], line[80];
@@ -11,9 +11,16 @@
   /* get astrometry information */
   if (!GetCoords (&image[0].coords, header)) {
-    fprintf (stderr, "ERROR: no astrometric solution in header\n");
-    exit (1);
+    fprintf (stderr, "no astrometric solution in header\n");
+    return (FALSE);
   }
-  gfits_scan (header, "NAXIS1",   "%hd", 1, &image[0].NX);
-  gfits_scan (header, "NAXIS2",   "%hd", 1, &image[0].NY);
+  // XXX currently, image uses an unsigned short for NX,XY. this is rather restrictive
+  // and needs to be at least checked.
+  gfits_scan (header, "NAXIS1",   "%d", 1, &Nx);
+  gfits_scan (header, "NAXIS2",   "%d", 1, &Ny);
+  if ((Nx < 0) || (Nx > 0xffff)) {
+    fprintf (stderr, "WARNING: NX, NY out of range : image boundary will be wrong\n");
+  }
+  image[0].NX = Nx;
+  image[0].NY = Ny;
 
   if (!gfits_scan (header, "TZERO",   "%d",  1, &image[0].tzero)) {
@@ -31,11 +38,11 @@
   gfits_scan (header, "NASTRO", "%d", 1, &Nastro);
   if ((Nastro == 0) && !ACCEPT_ASTROM) {
-    fprintf (stderr, "ERROR: bad astrometric solution in header\n");
-    exit (1);
+    fprintf (stderr, "bad astrometric solution in header\n");
+    return (FALSE);
   }
   if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
     if (MOSAIC == NULL) {
-      fprintf (stderr, "ERROR: no mosaic for WRP image (use -mosaic)\n");
-      exit (1);
+      fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n");
+      return (FALSE);
     }
     RegisterMosaic (MOSAIC);
@@ -53,16 +60,16 @@
   if (photcode == 0) {
     if (!gfits_scan (header, "PHOTCODE", "%s", 1, photname)) {
-      fprintf (stderr, "ERROR: photcode not supplied in header\n");
-      exit (1);
+      fprintf (stderr, "photcode not supplied in header\n");
+      return (FALSE);
     }
     photcode = GetPhotcodeCodebyName (photname);
     if (photcode == 0) {
-      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", photname);
-      exit (1);
+      fprintf (stderr, "photcode %s not found in photcode table\n", photname);
+      return (FALSE);
     }
   }
   if (photcode == 0) { 
-    fprintf (stderr, "ERROR: no valid photcode is supplied\n");
-    exit (1);
+    fprintf (stderr, "no valid photcode is supplied\n");
+    return (FALSE);
   }
   image[0].photcode = photcode;
@@ -137,6 +144,6 @@
   /* find expected number of stars */
   if (!gfits_scan (header, "NSTARS", "%d", 1, &image[0].nstar)) {
-    fprintf (stderr, "ERROR: can't get NSTARS from header\n");
-    exit (1);
+    fprintf (stderr, "can't get NSTARS from header\n");
+    return (FALSE);
   }
 
