Index: trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO.c	(revision 19870)
+++ trunk/psModules/src/objects/pmSourceIO.c	(revision 19875)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-02 19:06:17 $
+ *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-10-03 02:11:48 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -424,25 +424,24 @@
                 pmConfigConformHeader(hdu->header, file->format);
 
-		// psFitsWriteBlank strips out the NAXISn keywords, forcing CFITSIO to take care of them
-		// save NAXIS1,NAXIS2 as IMNAXIS1,IMNAXIS2
-		int Nx = psMetadataLookupS32 (&status, hdu->header, "IMNAXIS1");
-		if (!status) {
-		    Nx = psMetadataLookupS32 (&status, hdu->header, "NAXIS1");
-		    if (status) {
-			psMetadataAddS32 (hdu->header, PS_LIST_TAIL, "IMNAXIS1", PS_META_REPLACE, "original image size (x-dir)", Nx);
-		    } else {
-			fprintf (stderr, "header is missing NAXIS1!");
-		    }
-		}
-
-		int Ny = psMetadataLookupS32 (&status, hdu->header, "IMNAXIS2");
-		if (!status) {
-		    Ny = psMetadataLookupS32 (&status, hdu->header, "NAXIS2");
-		    if (status) {
-			psMetadataAddS32 (hdu->header, PS_LIST_TAIL, "IMNAXIS2", PS_META_REPLACE, "original image size (y-dir)", Ny);
-		    } else {
-			fprintf (stderr, "header is missing NAXIS2!");
-		    }
-		}
+                // psFitsWriteBlank strips out the NAXISn keywords, forcing CFITSIO to take care of them
+                // save NAXIS1,NAXIS2 as IMNAXIS1,IMNAXIS2
+                int numCols = 0, numRows = 0; // Size of image
+                if (readout->image) {
+                    numCols = readout->image->numCols;
+                    numRows = readout->image->numRows;
+                } else {
+                    numCols = psMetadataLookupS32(&status, hdu->header, "IMNAXIS1");
+                    if (!status) {
+                        numCols = psMetadataLookupS32(&status, hdu->header, "NAXIS1");
+                    }
+                    numRows = psMetadataLookupS32(&status, hdu->header, "IMNAXIS2");
+                    if (!status) {
+                        numRows = psMetadataLookupS32(&status, hdu->header, "NAXIS2");
+                    }
+                }
+
+                if (numCols == 0 || numRows == 0) {
+                    psWarning("Output source file has invalid IMNAXIS1, IMNAXIS2.");
+                }
 
                 psFitsWriteBlank (file->fits, hdu->header, headname);
@@ -906,15 +905,15 @@
 
         // XXX these are case-sensitive since the EXTYPE is case-sensitive
-	if (file->type == PM_FPA_FILE_CMF) {
-	    if (!strcmp (exttype, "SMPDATA")) {
-		sources = pmSourcesRead_SMPDATA (file->fits, hdu->header);
-	    }
-	    if (!strcmp (exttype, "PS1_DEV_0")) {
-		sources = pmSourcesRead_PS1_DEV_0 (file->fits, hdu->header);
-	    }
-	    if (!strcmp (exttype, "PS1_DEV_1")) {
-		sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header);
-	    }
-	}
+        if (file->type == PM_FPA_FILE_CMF) {
+            if (!strcmp (exttype, "SMPDATA")) {
+                sources = pmSourcesRead_SMPDATA (file->fits, hdu->header);
+            }
+            if (!strcmp (exttype, "PS1_DEV_0")) {
+                sources = pmSourcesRead_PS1_DEV_0 (file->fits, hdu->header);
+            }
+            if (!strcmp (exttype, "PS1_DEV_1")) {
+                sources = pmSourcesRead_PS1_DEV_1 (file->fits, hdu->header);
+            }
+        }
 
         psTrace("psModules.objects", 6, "read CMF table from %s : %s : %s", file->filename, headname, dataname);
