FPACK FITS Image Compression Program
Overview
Quick links
- fpack optimally compresses FITS format images.
- funpack restores the compressed file back to its original state.
- fpack supports Rice, Hcompress, GZIP, and PLIO compression.
- Advantages of fpack (using Rice) over GZIP :
- Compressed images are typically 30% smaller
- Compression is 3 times faster than GZIP
- Uncompression is same speed as GUNZIP
- fpack also supports lossy techniques for much higher compression (10x to 100x).
- Source Code - Unix .tar file, v1.1.2, 10 September 2008
See simple build instructionsUser's Guide for fpack and funpack (PDF format, 10 pages)
Floating-point Image compression study - PDF format poster presented at the October 2009 ADASS meeting in Sapporo, Japan. Demonstrates how floating point images can be compressed by up to a factor of 10 using fpack without loss of significant astrometric or photometric precision.
PASP paper: "Lossless Astronomical Image Compression and the Effects of Noise" by W. Pence, R. Seaman, and R. White. (PDF format, 20 pages) A preprint is also available.
- BZIP2 Feasibility Study: studies the performance of BZIP2 compared to Rice, Hcompress, and GZIP. Concludes that BZIP2 offers no unique advantages that would justify supporting it in the tiled image compression convention.
Binary Executables for common platforms
(Set executable permission with "chmod a+x fpack" and "chmod a+x funpack").
More Details
fpack is a utility program for optimally compressing images in the FITS data format. The associated funpack program will restore the compressed file back to its original state. These programs may be run from the host operating system command line and are analogous to the gzip and gunzip utility programs, except that they are specifically optimized for FITS format images and offer a wider choice of compression options.fpack uses the tiled image compression convention for storing the compressed images. This convention can in principle support any number of of different compression algorithms; currently GZIP, Rice, Hcompress, and the IRAF pixel list compression algorithms have been implemented.
The main advantages of fpack compared to the commonly used technique of externally compressing the whole FITS file with gzip are:
- It is generally faster and offers better compression than gzip.
- The FITS header keywords remain uncompressed for fast access.
- Each HDU of a multi-extension FITS file is compressed separately, so it is not necessary to uncompress the entire file to read a single image in a multi-extension file.
- Dividing the image into tiles before compression enables faster access to small subsections of the image.
- The compressed image is itself a valid FITS file and can be manipulated by other general FITS utility software.
- Lossy compression can be used for much higher compression in cases where it is not necessary to exactly preserve the original image.
- The CHECKSUM keywords are automatically updated to help verify the integrity of the files.
- Software that supports the tiled image compression technique can directly read and write the FITS images in their compressed form.
See the PDF format User's Guide for more detailed information on using fpack and funpack. Also see the PASP paper or preprint on lossless astronomical image compression and the presentation by Rob Seaman et al. at the 2006 Astronomical Data Analysis Software and Systems conference for more discussion about fpack and the growing importance of data compression in astronomy.
Download and Build the Source Code
You may build the fpack and funpack programs from the fpack and funpack C source code on Unix and Mac OS systems. You should first download and build the CFITSIO library. Then untar the fpack and funpack source code into the CFITSIO directory (overwriting any older version of the programs that may have been distributed with CFITSIO), and then enter the commands "make fpack" and "make funpack" in that directory. This will create the fpack and funpack executable files which may be moved to any other suitable directory (e.g. your local /bin directory).
Origins
The fpack and funpack utilities were originally designed and written by Rob Seaman (NOAO). William Pence (NASA/GSFC) added further enhancements to the utilities and to the image compression algorithms in the underlying CFITSIO library. Rick White (STScI) wrote the code for the Rice and Hcompress algorithms.
