Index: trunk/ippScripts/scripts/detrend_resid_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 19642)
+++ trunk/ippScripts/scripts/detrend_resid_imfile.pl	(revision 19652)
@@ -44,5 +44,5 @@
     'dbname|d=s'        => \$dbname, # Database name
     'reduction=s'       => \$reduction, # Reduction class
-    'threads=s'       	=> \$threads,   # Number of threads to use for ppImage
+    'threads=s'         => \$threads,   # Number of threads to use for ppImage
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update,
@@ -87,13 +87,14 @@
 
 print "raw recipe: $recipe\n";
-$recipe = $ipprc->reduction($reduction, $recipe);
+$ppimage_recipe = $ipprc->reduction($reduction, $recipe);
+$jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_RESID';
 print "real recipe: $recipe\n";
 
 # Flags to specify the particular detrend to use
 use constant DETRENDS => {
-    'bias'     	       => '-bias',      # Specify the bias frame
-    'dark'     	       => '-dark',      # Specify the dark frame
+    'bias'             => '-bias',      # Specify the bias frame
+    'dark'             => '-dark',      # Specify the dark frame
     'dark_premask'     => '-dark',      # Specify the dark frame
-    'shutter'  	       => '-shutter',   # Specify the shutter frame
+    'shutter'          => '-shutter',   # Specify the shutter frame
     'flat_premask'     => '-flat',      # Specify the flat frame
     'domeflat_premask' => '-flat',      # Specify the flat frame
@@ -102,11 +103,11 @@
     'domeflat_raw'     => '-flat',      # Specify the flat frame
     'skyflat_raw'      => '-flat',      # Specify the flat frame
-    'flat'     	       => '-flat',      # Specify the flat frame
-    'domeflat' 	       => '-flat',      # Specify the flat frame
-    'skyflat'  	       => '-flat',      # Specify the flat frame
-    'fringe'   	       => '-fringe',    # Specify the fringe frame
-    'mask'     	       => '-mask',      # Specify the mask frame
-    'darkmask' 	       => '-mask',      # Specify the mask frame
-    'flatmask' 	       => '-mask',      # Specify the mask frame
+    'flat'             => '-flat',      # Specify the flat frame
+    'domeflat'         => '-flat',      # Specify the flat frame
+    'skyflat'          => '-flat',      # Specify the flat frame
+    'fringe'           => '-fringe',    # Specify the fringe frame
+    'mask'             => '-mask',      # Specify the mask frame
+    'darkmask'         => '-mask',      # Specify the mask frame
+    'flatmask'         => '-mask',      # Specify the mask frame
 };
 
@@ -146,5 +147,6 @@
 unless ($no_op) {
     my $command = "$ppImage -file $input_uri $outroot";
-    $command .= " -recipe PPIMAGE $recipe";
+    $command .= " -recipe PPIMAGE $ppimage_recipe";
+    $command .= " -recipe JPEG $jpeg_recipe";
     $command .= " -recipe PPSTATS RESIDUAL";
     $command .= " -F PPIMAGE.OUTPUT PPIMAGE.OUTPUT.RESID";
@@ -235,9 +237,9 @@
         $command .= " -det_id $det_id";
         $command .= " -iteration $iter";
-	$command .= " -ref_det_id $ref_det_id";
-	$command .= " -ref_iter $ref_iter";
+        $command .= " -ref_det_id $ref_det_id";
+        $command .= " -ref_iter $ref_iter";
         $command .= " -exp_id $exp_id";
         $command .= " -class_id $class_id";
-	$command .= " -path_base $outroot";
+        $command .= " -path_base $outroot";
         $command .= " -code $exit_code";
         $command .= " -dbname $dbname" if defined $dbname;
