NAME
imexif.c - EXIF support for Imager
SYNOPSIS
if (im_decode_exif(im, app1data, app1datasize)) {
// exif block seen
}
DESCRIPTION
This code provides a basic EXIF data decoder. It is intended to be called from the JPEG reader code when an APP1 data block is found, and will set tags in the supplied image.
PUBLIC FUNCTIONS
These functions are available to other parts of Imager. They aren't intended to be called from outside of Imager.
- im_decode_exif
-
im_decode_exif(im, data_base, data_size);
The data from
data_basefordata_sizebytes will be scanned for EXIF data.Any data found will be used to set tags in the supplied image.
The intent is that invalid EXIF data will simply fail to set tags, and write to the log. In no case should this code exit when supplied invalid data.
Returns true if an EXIF header was seen.
INTERNAL FUNCTIONS
EXIF Processing
-
save_ifd0_tags(im, tiff, &exif_ifd_offset, &gps_ifd_offset)
Scans the currently loaded IFD for tags expected in IFD0 and sets them in the image.
Sets *exif_ifd_offset to the offset of the EXIF IFD if found.
-
save_exif_ifd_tags(im, tiff)
Scans the currently loaded IFD for the tags expected in the EXIF IFD and sets them as tags in the image.
- process_maker_note
-
This is a stub for processing the maker note tag.
Maker notes aren't covered by EXIF itself and in general aren't documented by the manufacturers.
High level TIFF functions
To avoid relying upon tifflib when we're not processing an image we have some simple in-memory TIFF file management.
- tiff_init
-
imtiff tiff; if (tiff_init(tiff, data_base, data_size)) { // success }
Initialize the tiff data structure.
Scans for the byte order and version markers, and stores the offset to the first IFD (IFD0 in EXIF) in first_ifd_offset.
- tiff_final
-
tiff_final(&tiff)
Clean up the tiff structure initialized by tiff_init()
- tiff_load_ifd
-
if (tiff_load_ifd(tiff, offset)) { // process the ifd }
Loads the IFD from the given offset into the tiff objects ifd.
This can fail if the IFD extends beyond end of file, or if any data offsets combined with their sizes, extends beyond end of file.
Returns true on success.
- tiff_clear_ifd
-
tiff_clear_ifd(tiff)
Releases any memory associated with the stored IFD and resets the IFD pointers.
This is called by tiff_load_ifd() and tiff_final().
- tiff_get_tag_double
-
double value; if (tiff_get_tag(tiff, index, &value)) { // process value }Attempts to retrieve a double value from the given index in the current IFD.
The value must have a count of 1.
- tiff_get_tag_double
-
double value; if (tiff_get_tag(tiff, index, &value)) { // process value }Attempts to retrieve a double value from the given index in the current IFD.
The value must have a count of 1.
- tiff_get_tag_int_array
-
int value; if (tiff_get_tag_int_array(tiff, index, &value, array_index)) { // process value }Attempts to retrieve an integer value from the given index in the current IFD.
- tiff_get_tag_int
-
int value; if (tiff_get_tag_int(tiff, index, &value)) { // process value }Attempts to retrieve an integer value from the given index in the current IFD.
The value must have a count of 1.
Table-based tag setters
This set of functions checks for matches between the current IFD and tags supplied in an array, when there's a match it sets the appropriate tag in the image.
-
Scans the IFD for integer tags and sets them in the image,
-
Scans the IFD for rational tags and sets them in the image.
-
Scans the IFD for string tags and sets them in the image.
-
Scans the IFD for arrays of numbers and sets them in the image.
-
This function maps integer values to descriptions for those values.
In general we handle the integer value through copy_int_tags() and then the same tage with a "_name" suffix here.
Low level data access functions
These functions use the byte order in the tiff object to extract various types of data from the tiff data.
These functions will abort if called with an out of range offset.
The intent is that any offset checks should have been done by the caller.
- tiff_get16
-
Retrieve a 16 bit unsigned integer from offset.
- tiff_get32
-
Retrieve a 32-bit unsigned integer from offset.
- tiff_get_bytes
-
Retrieve a byte string from offset.
This isn't used much, you can usually deal with the data in-situ. This is intended for use when you need to modify the data in some way.
- tiff_get16s
-
Retrieve a 16-bit signed integer from offset.
- tiff_get32s
-
Retrieve a 32-bit signed integer from offset.
- tiff_get_rat
-
Retrieve an unsigned rational from offset.
- tiff_get_rats
-
Retrieve an signed rational from offset.
SEE ALSO
Imager, jpeg.c
http://www.exif.org/
AUTHOR
Tony Cook <tonyc@cpan.org>
REVISION
$Revision$