Index: trunk/psLib/src/fits/psFits.c
===================================================================
--- trunk/psLib/src/fits/psFits.c	(revision 25439)
+++ trunk/psLib/src/fits/psFits.c	(revision 25478)
@@ -895,4 +895,15 @@
         break;
 
+    case PS_TYPE_U64:
+        bitpix = LONGLONG_IMG;
+        bzero = -1.0 * INT64_MIN;
+        datatype = TLONGLONG;
+        break;
+
+    case PS_TYPE_S64:
+        bitpix = LONGLONG_IMG;
+        datatype = TLONGLONG;
+        break;
+
     case PS_TYPE_F32:
         bitpix = FLOAT_IMG;
@@ -921,4 +932,13 @@
                     _("Specified type, %s, is not supported."),
                     typeStr);
+            if (bitPix) {
+                *bitPix = 0;
+            }
+            if (dataType) {
+                *dataType = 0;
+            }
+            if (bZero) {
+                *bZero = 0;
+            }
             return false;
         }
@@ -960,2 +980,82 @@
     return PS_FITS_COMPRESS_NONE;
 }
+
+
+
+#if 0
+/// Options for FITS I/O
+typedef struct {
+    char *extword;                      ///< user-specified word to name extensions (NULL implies EXTNAME)
+    struct {
+        bool compression;               ///< Compression convention: handling of compressed images
+        bool psBitpix;                  ///< Custom floating-point image
+    } conventions;                      ///< Conventions to honour
+    // The following options are particular to writing images; they needn't be set for anything else.
+    psFitsFloat floatType;              ///< Desired custom floating-point for output images
+    int bitpix;                         ///< Desired BITPIX for output images; 0 to use as provided
+    psFitsScaling scaling;              ///< Scaling scheme to use when quantising floating-point values
+    bool fuzz;                          ///< Fuzz the values when quantising floating-point values?
+    double bscale, bzero;               ///< Manually specified BSCALE and BZERO (for SCALE_MANUAL)
+    double mean, stdev;                 ///< Mean and standard deviation of image
+    int stdevBits;                      ///< Number of bits to sample a standard deviation (for SCALE_STDEV_*)
+    float stdevNum;                     ///< Number of standard deviations to pad off the edge
+} psFitsOptions;
+
+bool psFitsCopyCompression(psFits *target, psFits *source)
+{
+    PS_ASSERT_FITS_NON_NULL(target, false);
+    PS_ASSERT_FITS_NON_NULL(source, false);
+
+    psMetadata *header = psMetadataReadHeader(NULL, source); // Header of source file
+
+    bool mdok;                          // Status of MD lookup
+    psString compTypeStr = psMetadataLookupStr(&mdok, header, "ZCMPTYPE"); // Compression type
+    psFitsCompressionType compType = psFitsCompressionTypeFromString(compTypeStr); // Compression type
+
+    if (!target->options) {
+        target->options = psFitsOptionsAlloc();
+    }
+
+    target->options->floatType = psFitsFloatImageCheck(source); // Custom floating-point type
+
+
+
+
+
+    target->options = psFitsOptionsAlloc();
+    target->options->scaling = PS_FITS_SCALE_MANUAL;
+    target->options->fuzz = false;
+    target->options->bitpix = bitpix;
+    target->options->bscale = bscale;
+    target->options->bzero = bzero;
+
+    psFitsSetCompression(sfile->fits, compType, tiles, 8, 0, 0);
+
+
+
+
+    // Get current BITPIX, BSCALE, BZERO, EXTNAME
+    // Probably not necessary to look the numerical values up in this
+    // way, but guards against changes to psLib and cfitsio FITS
+    // handling.
+    psMetadataItem *bitpixItem = psMetadataLookup(in->header, "BITPIX");
+    psAssert(bitpixItem, "Every FITS image should have BITPIX");
+    int bitpix = psMetadataItemParseS32(bitpixItem);
+    psMetadataItem *bscaleItem = psMetadataLookup(in->header, "BSCALE");
+
+    float bscale;
+    if (!bscaleItem) {
+        psWarning("BSCALE isn't set; defaulting to unity");
+        bscale = 1.0;
+    } else {
+        bscale = psMetadataItemParseF32(bscaleItem);
+    }
+    psMetadataItem *bzeroItem = psMetadataLookup(in->header, "BZERO");
+    float bzero;
+    if (!bzeroItem) {
+        psWarning("BZERO isn't set; defaulting to zero");
+        bzero = 0.0;
+    } else {
+        bzero = psMetadataItemParseF32(bzeroItem);
+    }
+#endif
