Index: trunk/stac/src/shiftSize.c
===================================================================
--- trunk/stac/src/shiftSize.c	(revision 5743)
+++ trunk/stac/src/shiftSize.c	(revision 6887)
@@ -17,11 +17,11 @@
 {
     fprintf (stderr, "shiftSize: Calculate size for output combined image\n"
-	     "Usage: %s [-h] [-v] IN1 IN2...\n"
-	     "where\n"
-	     "\t-h           Help (this info)\n"
-	     "\t-v           Increase verbosity level\n"
-	     "\tIN1, IN2...  Input images, which have associated .map files.\n",
-	     name
-	);
+             "Usage: %s [-h] [-v] IN1 IN2...\n"
+             "where\n"
+             "\t-h           Help (this info)\n"
+             "\t-v           Increase verbosity level\n"
+             "\tIN1, IN2...  Input images, which have associated .map files.\n",
+             name
+        );
 }
 
@@ -41,8 +41,8 @@
 
 
-    int verbose = 0;			// Verbosity level
+    int verbose = 0;                    // Verbosity level
 
     // Parse command line
-    const char *programName = argv[0];	// Program name
+    const char *programName = argv[0];  // Program name
     /* Variables for getopt */
     int opt;   /* Option, from getopt */
@@ -53,13 +53,13 @@
     while ((opt = getopt(argc, argv, "hv")) != -1) {
         switch (opt) {
-	  case 'h':
-	    help(programName);
-	    exit(EXIT_SUCCESS);
-	  case 'v':
+          case 'h':
+            help(programName);
+            exit(EXIT_SUCCESS);
+          case 'v':
             verbose++;
             break;
-	  default:
-	    help(programName);
-	}
+          default:
+            help(programName);
+        }
     }
 
@@ -73,11 +73,34 @@
 
     psArray *inputs = psArrayAlloc(argc); // Input filenames
+    inputs->n = argc;
     for (int i = 0; i < argc; i++) {
-	inputs->data[i] = psAlloc(strlen(argv[i]));
-	strncpy(inputs->data[i], argv[i], strlen(argv[i]));
+        inputs->data[i] = psAlloc(strlen(argv[i]));
+        strncpy(inputs->data[i], argv[i], strlen(argv[i]));
+        psTrace("stac.size", 8, "Input file: %s\n", inputs->data[i]);
     }
 
     // Read input files
-    psArray *images = stacReadImages(NULL, inputs);
+    psVector *xSize = psVectorAlloc(inputs->n, PS_TYPE_S32);
+    psVector *ySize = psVectorAlloc(inputs->n, PS_TYPE_S32);
+    xSize->n = inputs->n;
+    ySize->n = inputs->n;
+    for (int i = 0; i < inputs->n; i++) {
+        const char *filename = inputs->data[i]; // Name of FITS file
+        psFits *file = psFitsOpen(filename, "r"); // FITS file handle
+        psMetadata *header = psFitsReadHeader(NULL, file); // FITS header
+        psFitsClose(file);
+        bool mdok = true;               // Status of MD lookup
+        xSize->data.S32[i] = psMetadataLookupS32(&mdok, header, "NAXIS1");
+        if (!mdok) {
+            psError(PS_ERR_IO, true, "Unable to find NAXIS1 in %s\n", filename);
+            exit(EXIT_FAILURE);
+        }
+        ySize->data.S32[i] = psMetadataLookupS32(&mdok, header, "NAXIS2");
+        if (!mdok) {
+            psError(PS_ERR_IO, true, "Unable to find NAXIS2 in %s\n", filename);
+            exit(EXIT_FAILURE);
+        }
+        psFree(header);
+    }
 
     // Read maps
@@ -85,7 +108,9 @@
 
     // Get size
-    int outnx, outny;			// Size of combined image
-    float xMapDiff, yMapDiff;		// Difference to apply to maps
-    stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, images, maps);
+    int outnx, outny;                   // Size of combined image
+    float xMapDiff, yMapDiff;           // Difference to apply to maps
+    stacSize(&outnx, &outny, &xMapDiff, &yMapDiff, xSize, ySize, maps);
+    psFree(xSize);
+    psFree(ySize);
 
     printf("%d %d\n", outnx, outny);
@@ -95,5 +120,4 @@
 
     psFree(inputs);
-    psFree(images);
     psFree(maps);
 
