GNU Astronomy Utilities

Next: , Previous: , Up: File input output   [Contents][Index] JPEG files (jpeg.h)

The JPEG file format is one of the most common formats for storing and transferring images, recognized by almost all image rendering and processing programs. In particular, because of its lossy compression algorithm, JPEG files can have low volumes, making it used heavily on the internet. For more on this file format, and a comparison with others, please see Recognized file formats.

For scientific purposes, the lossy compression and very limited dynamic range (8-bit integers) make JPEG very unattractive for storing of valuable data. However, because of its commonality, it will inevitably be needed in some situations. The functions here can be used to read and write JPEG images into Gnuastro’s Generic data container (gal_data_t). If the JPEG file has more than one color channel, each channel is treated as a separate node in a list of datasets (see List of gal_data_t).

gal_jpeg_name_is_jpeg (char *name)

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

gal_jpeg_suffix_is_jpeg (char *name)

Return 1 if suffix is a recognized JPEG suffix. The recognized suffixes are .jpg, .JPG, .jpeg, .JPEG, .jpe, .jif, .jfif and .jfi.

gal_data_t *
gal_jpeg_read (char *filename, size_t minmapsize, int quietmmap)

Read the JPEG file filename and return the contents as gal_data_t. If the directory’s image contains multiple colors/channels, the output will be a list with one node per color/channel (see List of gal_data_t).

gal_jpeg_write (gal_data_t *in, char *filename, uint8_t quality, float widthincm)

Write the given dataset (in) into filename (a JPEG file). If in is a list, then each node in the list will be a color channel, therefore there can only be 1, 3 or 4 nodes in the list. If the number of nodes is different, then this function will abort the program with a message describing the cause. The lossy JPEG compression level can be set through quality which is a value between 0 and 100 (inclusive, 100 being the best quality). The display width of the JPEG file in units of centimeters (to suggest to viewers/users, only a meta-data) can be set through widthincm.

Next: EPS files (eps.h), Previous: TIFF files (tiff.h), Up: File input output   [Contents][Index]