Index: trunk/ppImage/src/ppImageArguments.c
===================================================================
--- trunk/ppImage/src/ppImageArguments.c	(revision 16821)
+++ trunk/ppImage/src/ppImageArguments.c	(revision 16844)
@@ -10,4 +10,5 @@
     fprintf(stderr, "\t-stats STATS.mdc: Output statistics into STATS.mdc\n");
     fprintf(stderr, "\t-isfringe: The input image contains fringe data.\n");
+    fprintf(stderr, "\t-isdark: The input image contains dark data.\n");
     fprintf(stderr, "\t-usemask MASKVAL: Use this mask value (override recipe).\n");
     fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n");
@@ -71,4 +72,9 @@
                           "Input is fringe image", true);
     }
+    if ((argnum = psArgumentGet(argc, argv, "-isdark"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "INPUT_IS_DARK", PS_META_REPLACE,
+                          "Input is dark image", true);
+    }
 
     // the following options override the PPIMAGE recipe options
Index: trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendReadout.c	(revision 16821)
+++ trunk/ppImage/src/ppImageDetrendReadout.c	(revision 16844)
@@ -32,6 +32,6 @@
 # endif
 
-    // set up the readouts for dark and bias
-    pmReadout  *dark = NULL;
+    // set up the dark and bias
+    pmCell *dark = NULL;
     pmReadout  *bias = NULL;
     if (options->doBias) {
@@ -39,11 +39,11 @@
     }
     if (options->doDark) {
-        dark = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.DARK");
+        dark = pmFPAfileThisCell(config->files, detview, "PPIMAGE.DARK");
     }
 
     // Bias, dark and overscan subtraction are all merged.
-    if (options->doBias || options->doDark || options->doOverscan) {
-        if (!pmBiasSubtract(input, options->overscan, bias, dark, view)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.\n");
+    if (options->doBias || options->doOverscan) {
+        if (!pmBiasSubtract(input, options->overscan, bias, NULL, view)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
             return false;
         }
@@ -54,4 +54,11 @@
         // create the target mask and weight images
         pmReadoutGenerateWeight(input, true);
+    }
+
+    if (options->doDark) {
+        if (!pmDarkApply(input, dark, options->maskValue)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
+            return false;
+        }
     }
 
Index: trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- trunk/ppImage/src/ppImageParseCamera.c	(revision 16821)
+++ trunk/ppImage/src/ppImageParseCamera.c	(revision 16844)
@@ -59,5 +59,5 @@
     }
     if (options->doDark) {
-        if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_DARK)) {
+        if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_DARK, PM_DETREND_TYPE_DARK)) {
             psError (PS_ERR_IO, false, "Can't find a dark image source");
             psFree (options);
@@ -393,4 +393,9 @@
         outImage->type = PM_FPA_FILE_FRINGE;
     }
+    if (psMetadataLookupBool(NULL, config->arguments, "INPUT_IS_DARK")) {
+        // It's a dark file, so change the file type
+        input->type = PM_FPA_FILE_DARK;
+        outImage->type = PM_FPA_FILE_DARK;
+    }
 
     // Turn off mask and weight output if we're not doing anything interesting
