Index: trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- trunk/pstamp/scripts/pstampparse.pl	(revision 26151)
+++ trunk/pstamp/scripts/pstampparse.pl	(revision 26204)
@@ -394,4 +394,6 @@
         print ARGSLIST "$args\n";
         close ARGSLIST or my_die("failed to close $argslist", $PS_EXIT_UNKNOWN_ERROR);
+
+        write_params($output_base, $image);
 
         my $newState = "run";
@@ -638,11 +640,7 @@
         my $exp_id = $image->{exp_id};
             
-        my $output_base = "$out_dir/${rownum}_${job_num}_";
-        my $params = "${output_base}.params";
-
-        # copy the argument list to a file
-        open PARAMS, ">$params" or my_die("failed to open $params", $PS_EXIT_UNKNOWN_ERROR);
-        print PARAMS "$stage $image->{stage_id} $image->{component} $image->{path_base} $image->{camera}\n";
-        close PARAMS or my_die("failed to close $params", $PS_EXIT_UNKNOWN_ERROR);
+        my $output_base = "$out_dir/${rownum}_${job_num}";
+
+        write_params($output_base, $image);
 
         my $newState = "run";
@@ -877,4 +875,29 @@
 }
 
+sub write_params {
+    my $output_base = shift;
+    my $image = shift;
+
+    # write the contents of this "image" as a metadata config doc
+    # Simply treat all values as strings. This is ok since we are only going to
+    # read it from another perl script
+    my $mdc_file = "${output_base}.mdc";
+    open P, ">$mdc_file" or my_die("failed to open $mdc_file", $PS_EXIT_UNKNOWN_ERROR);
+
+    print P "params METADATA\n";
+
+    foreach my $key (keys %$image) {
+        my $value = $image->{$key};
+        if (defined $value) {
+            printf P "  %-20s STR     %s\n", $key, $value;
+        } else {
+            printf STDERR "skipping undefined value for $key\n";
+        }
+    }
+
+    print P "END\n";
+    close P or my_die("failed to close $mdc_file", $PS_EXIT_UNKNOWN_ERROR);
+}
+
 sub my_die
 {
