Index: trunk/psphot/src/psphotArguments.c
===================================================================
--- trunk/psphot/src/psphotArguments.c	(revision 5049)
+++ trunk/psphot/src/psphotArguments.c	(revision 5084)
@@ -38,4 +38,12 @@
   }
 
+  // optional output residual image - add to config
+  char *photcode = NULL;
+  if ((N = psArgumentGet (*argc, argv, "-photcode"))) {
+    psArgumentRemove (N, argc, argv);
+    photcode = psStringCopy (argv[N]);
+    psArgumentRemove (N, argc, argv);
+  }
+
   if (*argc != 4) usage ();
 
@@ -60,4 +68,7 @@
     psMetadataAdd (config, PS_LIST_HEAD, "RESID_IMAGE", mode, "", resid);
   }
+  if (photcode != NULL) {
+    psMetadataAdd (config, PS_LIST_HEAD, "PHOTCODE", mode, "", photcode);
+  }
   return (config);
 }
@@ -70,4 +81,5 @@
     fprintf (stderr, "  -weight (filename)\n");
     fprintf (stderr, "  -resid (filename)\n");
+    fprintf (stderr, "  -photcode (photcode)\n");
     exit (2);
 }
