Index: trunk/pstamp/scripts/pstamp_get_image_job.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 26153)
+++ trunk/pstamp/scripts/pstamp_get_image_job.pl	(revision 26204)
@@ -53,22 +53,43 @@
 die $err if $err;
 
-my $params_file = $output_base . ".params";
+my $params_file = $output_base . ".mdc";
 if (! open(INPUT, "<$params_file") ) {
     die("failed to open params file: $params_file");
 }
 
+my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
+
 my $params = join "", (<INPUT>);
 
-print STDERR "\nparams is $params\n";
+my $data = $mdcParser->parse($params) or die("failed to parse metadata config doc");
+my $components = parse_md_list($data);
+my $n = scalar @$components;
+if ($n != 1) {
+    die("params file $params_file contains unexpected number of components: $n");
+}
+my $comp = $components->[0];
+my $stage = $comp->{stage};
+my $stage_id = $comp->{stage_id};
+my $component = $comp->{component};
+my $path_base = $comp->{path_base};
+my $camera = $comp->{camera};
+my $magicked = $comp->{magicked};
 
-my ($stage, $stage_id, $component, $path_base, $camera) = split " ", $params;
-if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
-   die "failed to parse params: $params";
+if ($verbose) {
+    print STDERR "\nstage is $stage\n";
+    print STDERR "stage_id is $stage_id\n";
+    print STDERR "path_base is $path_base\n";
+    print STDERR "path_base is $path_base\n";
+    print STDERR "CAMERA is $camera\n";
+    print STDERR "magicked is " . (defined $magicked ? $magicked : "undefined") . "\n";
 }
 
-print STDERR "\nCAMERA is $camera\n";
+if (!$camera or !$path_base or !$component or !$stage_id or !$stage) {
+       die "failed to parse params from: $params_file";
+}
+
 
 my $out_dir = dirname($output_base);
-my $prefix = basename($output_base);
+my $prefix = basename($output_base) . "_";
 my $results_file = $output_base . ".bundle_results";
 
@@ -86,8 +107,7 @@
     $command .= " --path_base $path_base --outdir $out_dir --results_file $results_file";
     $command .= " --prefix $prefix";
-    # ignore magic for now
-    $command .= " --no_magic";
-
+    $command .= " --magicked" if $magicked;
     $command .= " --dbname $dbname" if $dbname;
+    $command .= " --verbose" if $verbose;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
Index: trunk/pstamp/scripts/pstamp_job_run.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_job_run.pl	(revision 26153)
+++ trunk/pstamp/scripts/pstamp_job_run.pl	(revision 26204)
@@ -153,4 +153,5 @@
     $command .= " --dbname $dbname" if $dbname;
     $command .= " --dbserver $dbserver" if $dbserver;
+    $command .= " --verbose $verbose" if $verbose;
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
Index: trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- trunk/pstamp/scripts/pstampparse.pl	(revision 26153)
+++ 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
 {
