imexif.c - EXIF support for Imager
if (im_decode_exif(im, app1data, app1datasize)) { // exif block seen }
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.
These functions are available to other parts of Imager. They aren't intended to be called from outside of Imager.
im_decode_exif(im, data_base, data_size);
The data from data_base for data_size bytes will be scanned for EXIF data.
data_base
data_size
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.
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.
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.
To avoid relying upon tifflib when we're not processing an image we have some simple in-memory TIFF file management.
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)
Clean up the tiff structure initialized by tiff_init()
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)
Releases any memory associated with the stored IFD and resets the IFD pointers.
This is called by tiff_load_ifd() and tiff_final().
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.
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.
int value; if (tiff_get_tag_int(tiff, index, &value)) { // process value }
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.
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.
Retrieve a 16 bit unsigned integer from offset.
Retrieve a 32-bit unsigned integer from offset.
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.
Retrieve a 16-bit signed integer from offset.
Retrieve a 32-bit signed integer from offset.
Retrieve an unsigned rational from offset.
Retrieve an signed rational from offset.
Imager, jpeg.c
http://www.exif.org/
Tony Cook <tonyc@cpan.org>
$Revision$
To install Imager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Imager
CPAN shell
perl -MCPAN -e shell install Imager
For more information on module installation, please visit the detailed CPAN module installation guide.