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 (
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
name has a JPEG suffix.
This can be used to make sure that a given input file is JPEG.
gal_jpeg_suffix_is_jpeg for a list of recognized suffixes.
suffix is a recognized JPEG suffix.
The recognized suffixes are
Read the JPEG file
filename and return the contents as
If the directory’s image contains multiple colors/channels, the output will be a list with one node per color/channel (see List of
Write the given dataset (
in) into filename (a JPEG file).
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