Index: trunk/pswarp/src/pswarpLoop.c
===================================================================
--- trunk/pswarp/src/pswarpLoop.c	(revision 18924)
+++ trunk/pswarp/src/pswarpLoop.c	(revision 19873)
@@ -288,8 +288,34 @@
     psFree(cells);
 
+    psRegion *trimsec = psMetadataLookupPtr(NULL, outCell->concepts, "CELL.TRIMSEC"); // Trim section
+    trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; // All pixels
+
     if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA concepts from input to output.");
         psFree(stats);
         psFree(view);
+        return false;
+    }
+
+    pmHDU *hdu = outFPA->hdu;           // HDU for the output warped image
+
+    // Copy header from target
+    {
+        pmFPAview *skyView = pmFPAviewAlloc(0); // View into skycell
+        skyView->chip = skyView->cell = 0;
+        pmCell *cell = pmFPAfileThisCell(config->files, skyView, "PSWARP.SKYCELL"); // Skycell cell
+        pmHDU *skyHDU = pmHDUFromCell(cell); // HDU
+        if (!skyHDU) {
+            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find skycell HDU.");
+            psFree(skyView);
+            psFree(view);
+            return false;
+        }
+        hdu->header = psMetadataCopy(hdu->header, skyHDU->header);
+    }
+
+    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header.");
+        psFree(stats);
         return false;
     }
@@ -345,15 +371,4 @@
             psWarning("Unable to perform statistics on warped image.");
         }
-    }
-
-    pmHDU *hdu = outFPA->hdu;           // HDU for the output warped image
-    if (!hdu->header) {
-        hdu->header = psMetadataAlloc();
-    }
-
-    if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header.");
-        psFree(stats);
-        return false;
     }
 
