Index: trunk/magic/remove/src/streakscompare.c
===================================================================
--- trunk/magic/remove/src/streakscompare.c	(revision 20816)
+++ trunk/magic/remove/src/streakscompare.c	(revision 20843)
@@ -20,37 +20,62 @@
     sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true);
 
-    readImage(file1, 0, stage);
-    readImage(file2, 0, stage);
-
-    psImage *image1 = file1->image;
-    psImage *image2 = file2->image;
-
-    if ((image1->numRows != image2->numRows) || (image1->numCols != image2->numCols)) {
-        streaksExit("image sizes do not match\n", PS_EXIT_DATA_ERROR);
+    int ncomponents;
+    if (stage == IPP_STAGE_RAW) {
+        if (file1->nHDU != file2->nHDU) {
+            streaksExit("mages do not have same number of components\n", PS_EXIT_DATA_ERROR);
+        }
+        if (!(psFitsMoveExtNum(file1->fits, 1, true) && psFitsMoveExtNum(file2->fits, 1, true))) {
+            streaksExit("failed to skip primary header of raw file\n", PS_EXIT_DATA_ERROR);
+        }
+        ncomponents = file1->nHDU - 1;
+    } else {
+        ncomponents = 1;
     }
 
-    int width = image1->numCols;
-    int height = image1->numRows;
     int numErrors = 0;
-    for (int y = 0; y < height; y++) {
-        for (int x = 0; x < width; x++) {
-            bool error = false;
+    for (int component = 0; component < ncomponents; component++) {
+        if (component && !(psFitsMoveExtNum(file1->fits, 1, true) 
+                           && psFitsMoveExtNum(file2->fits, 1, true))) {
+            streaksExit("failed to advance to next extesion\n", PS_EXIT_DATA_ERROR);
+        }
+        readImage(file1, 0, stage);
+        readImage(file2, 0, stage);
 
-            double value1 = psImageGet(image1, x, y);
-            double value2 = psImageGet(image1, x, y);
+        psImage *image1 = file1->image;
+        psImage *image2 = file2->image;
 
-            if (!isnan(value1) && !isnan(value2)) {
-                if (value1 != value2) {
-                    error = true;
+        // TODO: do more sanity checking. For example check that extname's  (if any) match 
+        // check for matching image cubes
+        if (image1 && image2) {
+            if ((image1->numRows != image2->numRows) || (image1->numCols != image2->numCols)) {
+                streaksExit("image sizes do not match\n", PS_EXIT_DATA_ERROR);
+            }
+            int width = image1->numCols;
+            int height = image1->numRows;
+            for (int y = 0; y < height; y++) {
+                for (int x = 0; x < width; x++) {
+                    bool error = false;
+
+                    double value1 = psImageGet(image1, x, y);
+                    double value2 = psImageGet(image1, x, y);
+
+                    if (!isnan(value1) && !isnan(value2)) {
+                        if (value1 != value2) {
+                            error = true;
+                        }
+                    } else {
+                        // if one's a nan they had both better be
+                        error = ! isnan(value1) && isnan(value2);
+                    }
+                    
+                    if (error) {
+                        numErrors++;
+                        fprintf(stderr, "pixel at %5d %5d do not match %f %f\n", x, y, value1, value2);
+                    }
                 }
-            } else {
-                // if one's a nan they had both better be
-                error = ! isnan(value1) && isnan(value2);
             }
-            
-            if (error) {
-                numErrors++;
-                fprintf(stderr, "pixel at %5d %5d do not match %f %f\n", x, y, value1, value2);
-            }
+        } else if (! ((image1 == NULL) && (image2 == NULL))) {
+            // if one image is null (video extension) both should be
+            streaksExit("image1 null but not image2!", PS_EXIT_DATA_ERROR);
         }
     }
