Index: trunk/pstamp/src/pstampfinish.c
===================================================================
--- trunk/pstamp/src/pstampfinish.c	(revision 16898)
+++ trunk/pstamp/src/pstampfinish.c	(revision 16933)
@@ -182,5 +182,5 @@
 }
 
-static bool finishRequest(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs)
+static bool buildResultsFile(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs)
 {
     // build results file in dsRoot/pReq->outFileset
@@ -238,5 +238,5 @@
     psString command = NULL;
 
-    psStringAppend(&command, "dsreg --add --type PSRESPONSE --product %s --fileset %s", 
+    psStringAppend(&command, "dsreg --add --type PSRESULTS --product %s --fileset %s", 
             options->dsProduct, fileset_id);
 
@@ -266,4 +266,14 @@
         psError(PS_ERR_UNKNOWN, true, "dsreg failed with status: %d", status);
         return false;
+    }
+
+    return true;
+}
+static bool finishRequest(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs)
+{
+    if (pReq->resultsFile) {
+        if (!buildResultsFile(options, pReq, stoppedJobs)) {
+            return false;
+        }
     }
     // update the database setting the request state to stop
Index: trunk/pstamp/src/pstampparse.c
===================================================================
--- trunk/pstamp/src/pstampparse.c	(revision 16898)
+++ trunk/pstamp/src/pstampparse.c	(revision 16933)
@@ -72,8 +72,9 @@
         psArgumentRemove(argnum, &argc, argv);
     }
+
     if ((argnum = psArgumentGet(argc, argv, "-req_id"))) {
         psArgumentRemove(argnum, &argc, argv);
         if (argnum == argc) {
-            fprintf(stderr, "value required for mode\n");
+            fprintf(stderr, "value required for req_id\n");
             usage();
         }
@@ -598,15 +599,23 @@
 
 static bool
-queueOneJob (pspOptions *options, psString uri, psString outputBase, psString commandArgs)
+queueOneJob (pspOptions *options, psString job_type, psString uri, psString outputBase, psString commandArgs)
 {
     psString cmd = NULL;
 
-    psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -uri %s -outputBase ", options->req_id, uri);
+    psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -job_type %s -uri %s ", 
+        options->req_id, job_type, uri);
     
-    if (options->outputDirectory) {
-        psStringAppend(&cmd, "%s/", options->outputDirectory);
-    }
+    if (outputBase != NULL) {
+        psStringAppend(&cmd, "-outputBase ");
     
-    psStringAppend(&cmd, "%s -args '%s' >/dev/null", outputBase, commandArgs);
+        if (options->outputDirectory) {
+            psStringAppend(&cmd, "%s/", options->outputDirectory);
+        }
+        psStringAppend(&cmd, "%s", outputBase);
+    }
+    if (commandArgs) {
+        psStringAppend(&cmd, " -args '%s'", commandArgs);
+    }
+    psStringAppend(&cmd, " > /dev/null");
 
     if (options->verbose) {
@@ -626,5 +635,5 @@
 
 static bool
-queueJobs (pspOptions *options, psArray *uris, psString user_tag, psString commandArgs)
+queueJobs (pspOptions *options, psString job_type, psArray *uris, psString user_tag, psString commandArgs)
 {
     int numURIs = psArrayLength(uris);
@@ -633,5 +642,5 @@
     if (numURIs == 1) {
         // use the user tag as the outputBase
-        status = queueOneJob(options, uris->data[0], user_tag, commandArgs);
+        status = queueOneJob(options, job_type, uris->data[0], user_tag, commandArgs);
     } else {
         for (int i = 0; i< numURIs; i++) {
@@ -641,5 +650,5 @@
             psStringAppend(&outputBase, "%s_%d", user_tag, i);
 
-            status = queueOneJob(options, uris->data[i], outputBase, commandArgs);
+            status = queueOneJob(options, job_type, uris->data[i], outputBase, commandArgs);
             psFree(outputBase);
 
@@ -653,4 +662,53 @@
 }
 
+static bool
+turnOffResultsFile(pspOptions *options)
+{
+    // turn off the creation of a results file for this request
+    char * query = "UPDATE pstampRequest SET resultsFile = 0 WHERE req_id = %" PRId64;
+    return p_psDBRunQuery(options->config->database, query, options->req_id);
+}
+
+static bool
+queueGetImageJob(pspOptions *options, psArray *uris, psString req_type)
+{
+    FILE        *listFile;
+    psString    fileName = NULL;
+    psString    img_type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE");
+
+    if (! turnOffResultsFile(options)) { 
+        fprintf(stderr, "failed to update resultsFile for request %" PRId64 "\n", options->req_id);
+        return false;
+    }
+
+    if (options->outputDirectory == NULL) {
+        fprintf(stderr, "outputDirectory is required\n");
+        return false;
+    }
+    psStringAppend(&fileName, "%s/filelist", options->outputDirectory);
+
+    listFile = fopen(fileName, "w");
+    if (listFile == NULL) {
+        psError(PS_ERR_UNKNOWN, true, "failed to open get_image file list: %s\n", fileName);
+        return false;
+    }
+
+    for (int i=0; i<psArrayLength(uris); i++) {
+        fprintf(listFile, "%s|%s\n", (psString) uris->data[i], img_type);
+    }
+    fclose(listFile);
+
+    psString cmd = NULL;
+    psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -job_type get_image -uri %s -outputBase %s", 
+        options->req_id, fileName, options->outputDirectory);
+    
+    int rstatus = system(cmd);
+    if (rstatus) {
+        fprintf(stderr, "%s failed with status: %d\n", cmd, rstatus);
+    }
+
+    return rstatus == 0;
+}
+
 
 static bool
@@ -658,7 +716,14 @@
 {
     bool status;
+    psString job_type = psMetadataLookupStr(&status, options->md, "JOB_TYPE");
+
+    if (job_type == NULL) {
+        // XXX: compatiabilty hack change to error at some point
+        job_type = "stamp";
+    }
+
     psString cmd_mode = psMetadataLookupStr(&status, options->md, "CMD_MODE");
 
-    // if mode is set on the command line ignore the value in the request file
+    // if cmd_mode is set on the command line ignore the value in the request file
     if (options->mode == PSP_MODE_UNKNOWN) {
         if (cmd_mode != NULL) {
@@ -682,26 +747,27 @@
         return false;
     }
+
     psString roiString = parseROI(options);
-#ifdef notdef
-    if (!roiString) {
-        return false;
-    }
-#endif
 
     psArray *uris = NULL;
+
     if (!strcmp(req_type, "byid")) {
         // directly by exp_id, chip_id, warp_id etc
+
         uris = parseByID(options);
     } else if (!strcmp(req_type, "byexp")) {
         // images that resulted from a given exposure
+
         uris = parseByExp(options);
     } else if (!strcmp(req_type, "bycoord")) {
         // images from a particular region of the sky
+
         if (!roiString) {
-            fprintf(stderr, "req_type: bycoord with NULL ROI\n");
+            fprintf(stderr, "Region of interest required with req_type: bycoord\n");
             return false;
         }
         uris = parseByCoord(options);
     } else {
+
         psError(PS_ERR_UNKNOWN, true, "unknown REQ_TYPE: %s", req_type);
         return false;
@@ -728,24 +794,32 @@
             psStringAppend(&commandArgs, " -chip %s", class_id); 
         }
-
         psString user_tag = psMetadataLookupStr(&status, options->md, "USER_TAG");
-        if (user_tag == NULL) {
-            psError(PS_ERR_UNKNOWN, true, "no user tag in request file");
-            return false;
-        }
 
         if (options->mode == PSP_MODE_LIST_JOB) {
             if (numURIs == 1) {
-                printf("%s %s %s\n", (psString) uris->data[0], user_tag, commandArgs);
+                printf("%s %s %s %s\n", job_type, (psString) uris->data[0],
+                    user_tag ? user_tag : "", commandArgs ? commandArgs : "") ;
             } else {
                 // add an integer to the user_tag
                 for (int i = 0; i < numURIs; i++) {
-                    printf("%s %s_%d %s\n", (psString) uris->data[i], user_tag, i, commandArgs);
+                    printf("%s %s %s_%d %s\n", job_type, (psString) uris->data[i], user_tag, i,
+                        commandArgs ? commandArgs :"");
                 }
             }
         } else if (options->mode == PSP_MODE_QUEUE_JOB) {
 
-            if (!queueJobs(options, uris, user_tag, commandArgs)) {
-                return false;
+            if (!strcmp(job_type, "stamp")) {
+                // Postage stamp job
+                if (user_tag == NULL) {
+                    psError(PS_ERR_UNKNOWN, true, "no user tag in request file");
+                    return false;
+                }
+
+                if (!queueJobs(options, job_type, uris, user_tag, commandArgs)) {
+                    return false;
+                }
+            } else {
+
+                return queueGetImageJob(options, uris, req_type);
             }
 
Index: trunk/pstamp/src/pstamprequest.c
===================================================================
--- trunk/pstamp/src/pstamprequest.c	(revision 16898)
+++ trunk/pstamp/src/pstamprequest.c	(revision 16933)
@@ -105,9 +105,9 @@
     psMetadata *md = psMetadataAlloc();
     int         argnum;
-    bool        gotStyle = false;
+    bool        gotStyle  = false;
     bool        needCoord = false;
     bool        gotCenter = false;
-    bool        gotRange = false;
-    bool        needROI = true;
+    bool        gotRange  = false;
+    bool        needROI   = true;
     bool        makeStamps = true;
 
@@ -116,6 +116,7 @@
     psMetadataAdd (md, PS_LIST_TAIL, "VERSION", PS_DATA_STRING, "", STAMP_REQUEST_VERSION);
 
+    // These mode arguments should be consistent with pstampparse
     if ((argnum = psArgumentGet(argc, argv, "-list"))) {
-        psMetadataAdd (md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "LIST_URI");
+        psMetadataAdd (md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "list_uri");
         psArgumentRemove(argnum, &argc, argv);
         // we don't need coordinates if we're listing unless mode is -bycoord. May be set true below.
@@ -123,4 +124,15 @@
         makeStamps = false;
     }
+
+    if ((argnum = psArgumentGet(argc, argv, "-get_image"))) {
+        psMetadataAdd (md, PS_LIST_TAIL, "JOB_TYPE", PS_DATA_STRING, "", "get_image");
+        psArgumentRemove(argnum, &argc, argv);
+        // we don't need coordinates if we're listing unless mode is -bycoord. May be set true below.
+        needROI = false;    
+        makeStamps = false;
+    } else {
+        psMetadataAdd (md, PS_LIST_TAIL, "JOB_TYPE", PS_DATA_STRING, "", "stamp");
+    }
+
 
     // get project from command line
