Index: trunk/ippScripts/scripts/background_chip.pl
===================================================================
--- trunk/ippScripts/scripts/background_chip.pl	(revision 33053)
+++ trunk/ippScripts/scripts/background_chip.pl	(revision 33054)
@@ -42,5 +42,5 @@
 # Parse the command-line arguments
 my ( $chip_bg_id, $class_id, $camera, $outroot, $dbname, $reduction, $verbose,
-     $threads, $no_update, $save_temps, $no_op, $redirect, $deburned );
+     $threads, $no_update, $save_temps, $no_op, $redirect, $chip_path_base, $magicked );
 GetOptions(
     'chip_bg_id=s'      => \$chip_bg_id,    # chipBackgroundRun identifier
@@ -51,4 +51,6 @@
     'reduction=s'       => \$reduction, # Reduction class
     'threads=s'         => \$threads,   # Number of threads to use
+    'chip_path_base=s'  => \$chip_path_base, # optional chip_path_base
+    'magicked=s'        => \$magicked,  # magicked status of input
     'verbose'           => \$verbose,   # Print to stdout
     'no-update'         => \$no_update, # Don't update the database?
@@ -88,6 +90,17 @@
 # Get inputs
 my $in_path;                    # Input path
-my $magicked;                   # Input is magicked?
-{
+my $do_stats;
+my $dump_config;
+if ($chip_path_base and $no_update) {
+    # we are running outside of a chip_bg_run (perhaps by the postage stamp server) don't dump config
+    # or do stats. Get path to input from command line.
+    $in_path = $chip_path_base;
+    $magicked = 0 if !defined $magicked;
+    $do_stats = 0;
+    $dump_config = 0;
+} else {
+    # normal operation. Get input parameters from the database
+    $do_stats = 1;
+    $dump_config = 1;
     my $command = "bgtool -chipinputs -chip_bg_id $chip_bg_id -class_id $class_id";
     $command .= " -dbname $dbname" if defined $dbname;
@@ -153,11 +166,11 @@
     $command .= " -image $in_image";
     $command .= " -mask $in_mask";
-    $command .= " -stats $out_stats";
+    $command .= " -stats $out_stats" if $do_stats;
     $command .= " -background $in_bg" if $apply_bg;
     $command .= " -pattern $in_pattern" if $apply_pattern;
     $command .= " -recipe PPBACKGROUND $recipe_ppBackground";
-    $command .= " -recipe PPSTATS CHIPSTATS";
+    $command .= " -recipe PPSTATS CHIPSTATS" if $do_stats;
     $command .= " -dbname $dbname" if defined $dbname;
-    $command .= " -dumpconfig $out_config";
+    $command .= " -dumpconfig $out_config" if $dump_config;
     $command .= " -tracedest $traceDest -log $logDest";
 
@@ -171,7 +184,7 @@
 
 # Gather command-line arguments from statistics
-my $cmdflags;                   # Command-line flags to add
-my $quality;                    # Quality flag
-{
+my $cmdflags = "";                  # Command-line flags to add
+my $quality = 0;                    # Quality flag
+if ($do_stats) {
     &my_die("Couldn't find expected output file: $out_stats", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_stats);
 
@@ -191,7 +204,7 @@
 
 if (!$quality and !$no_op) {
-    &my_die("Couldn't find expected output file: $out_stats", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_image);
-    &my_die("Couldn't find expected output file: $out_stats", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_mask);
-    &my_die("Couldn't find expected output file: $out_stats", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_config);
+    &my_die("Couldn't find expected output file: $out_image", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_image);
+    &my_die("Couldn't find expected output file: $out_mask", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($out_mask);
+    &my_die("Couldn't find expected output file: $out_config", $chip_bg_id, $class_id, $PS_EXIT_SYS_ERROR) unless !$dump_config or $ipprc->file_exists($out_config);
 
 }
Index: trunk/ippScripts/scripts/background_warp.pl
===================================================================
--- trunk/ippScripts/scripts/background_warp.pl	(revision 33053)
+++ trunk/ippScripts/scripts/background_warp.pl	(revision 33054)
@@ -38,4 +38,5 @@
 
 my ($warp_bg_id, $skycell_id, $tess_dir, $reduction, $camera, $dbname, $outroot, $threads, $verbose, $no_update, $no_op, $redirect, $save_temps);
+my ($astrometry, $imageName, $maskName, $magicked);
 GetOptions(
     'warp_bg_id|i=s'      => \$warp_bg_id, # Warp identifier
@@ -46,4 +47,8 @@
     'reduction=s'         => \$reduction, # Reduction class
     'outroot=s'           => \$outroot, # Output root name
+    'image-list=s'        => \$imageName, # list of input image files
+    'mask-list=s'         => \$maskName, # list of input mask files
+    'astrometry=s'        => \$astrometry,
+    'magicked=s'          => \$magicked,
     'threads=s'           => \$threads,   # Number of threads to use for pswarp
     'verbose'             => \$verbose,   # Print to stdout
@@ -64,5 +69,20 @@
     and defined $outroot;
 
-my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $warp_bg_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
+if ($imageName) {
+    # we have been invoked in a special mode where the caller tells us all about the inputs
+    # This is used by the postage stamp server to make non-background corrected images without
+    # the existence of a warpBackgroundRun (or chipBackgroundRun)
+    # Make sure all of the inputs were supplied
+    if (!(defined $maskName and defined $astrometry and defined $magicked)) {
+        print STDERR "mask-list, astrometry, and magicked must be supplied if image-list is used\n";
+        if ($warp_bg_id) {
+            my_die( "invalid argument list.", $warp_bg_id, $skycell_id, $PS_EXIT_CONFIG_ERROR );
+        }
+        exit $PS_EXIT_CONFIG_ERROR;
+    }
+}
+
+my $ipprc = PS::IPP::Config->new( $camera ) or 
+my_die( "Unable to set up", $warp_bg_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 
 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id) or my_die( "Unable to get log filename", $warp_bg_id, $skycell_id, $PS_EXIT_SYS_ERROR );
@@ -97,9 +117,9 @@
 # Get list of filenames
 my $tempOutRoot = "/tmp/background.warp.$warp_bg_id.$skycell_id";
-my ($imageFile, $imageName) = tempfile( "$tempOutRoot.image.list.XXXX",  UNLINK => !$save_temps);
-my ($maskFile, $maskName) = tempfile( "$tempOutRoot.mask.list.XXXX",   UNLINK => !$save_temps);
-my $astrometry;                 # Astrometry filename
-my $magicked;                   # Magicked status
-{
+if (!defined $imageName) {
+    # go find our inputs
+    my ($imageFile, $maskFile);
+    ($imageFile, $imageName) = tempfile( "$tempOutRoot.image.list.XXXX",  UNLINK => !$save_temps);
+    ($maskFile, $maskName) = tempfile( "$tempOutRoot.mask.list.XXXX",   UNLINK => !$save_temps);
     my $command = "$bgtool -warpinputs";
     $command .= " -warp_bg_id $warp_bg_id";
@@ -132,7 +152,7 @@
         $astrometry = $astrom;
     }
-}
-close $imageFile;
-close $maskFile;
+    close $imageFile;
+    close $maskFile;
+}
 
 &my_die("Can't find input astrometry: $astrometry", $warp_bg_id, $skycell_id, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($astrometry);
