GNU Astronomy Utilities



12.3.12.2 TIFF files (tiff.h)

Outside of astronomy, the TIFF standard is arguably the most commonly used format to store high-precision data/images. Unlike FITS however, the TIFF standard only supports images (not tables), but like FITS, it has support for all standard data types (see Numeric data types) which is the primary reason other fields use it.

Another similarity of the TIFF and FITS standards is that TIFF supports multiple images in one file. The TIFF standard calls each one of these images (and their accompanying meta-data) a ‘directory’ (roughly equivalent to the FITS extensions). Unlike FITS however, the directories can only be identified by their number (counting from zero), recall that in FITS you can also use the extension name to identify it.

The functions described here allow easy reading (and later writing) of TIFF files within Gnuastro or for users of Gnuastro’s libraries. Currently only reading is supported, but if you are interested, please get in touch with us.

Function:
int
gal_tiff_name_is_tiff (char *name)

Return 1 if name has a TIFF suffix. This can be used to make sure that a given input file is TIFF. See gal_tiff_suffix_is_tiff for a list of recognized suffixes.

Function:
int
gal_tiff_suffix_is_tiff (char *name)

Return 1 if suffix is a recognized TIFF suffix. The recognized suffixes are tif, tiff, TIFF and TIFF.

Function:
size_t
gal_tiff_dir_string_read (char *string)

Return the number within string as a size_t number to identify a TIFF directory. Note that the directories start counting from zero.

Function:
gal_data_t *
gal_tiff_read (char *filename, size_t dir, size_t minmapsize, int quietmmap)

Read the dir directory within the TIFF file filename and return the contents of that TIFF directory as gal_data_t. If the directory’s image contains multiple channels, the output will be a list (see List of gal_data_t).

Function:
void
gal_tiff_write (gal_data_t *in, char *filename, int widthinpx, int heightinpix, int bitspersample, int numimg)

Write the given dataset (in) into filename (a TIFF file) with the specified image width in pixels (widthinpix),height in pixels (heightinpix), bits per sample (bitspersample), and number of images (numimg).