libgphoto2 (libgphoto2): libgphoto2/exif.h Source File

- Main Page
- Data Structures
- Files
- Directories
- Related Pages

- File List
- Globals

# exif.h

    00001 #ifndef _gphoto_exif_
    00002 #define _gphoto_exif_
    00003 #include <stdio.h>
    00004 #include <stdlib.h>
    00005 #include <string.h>
    00006 #include <time.h>
    00007 #include <sys/time.h>
    00008 #include <sys/times.h>
    00009 #include <fcntl.h>
    00010
    00011 /*
    00012  * EXIF file format support library. This API allows to parse, read and
    00013  * modify EXIF data structures. It provides a low-level API which allows
    00014  * to manipulate EXIF tags in a generic way, and a higher-level API which
    00015  * provides more advanced functions such as comment editing, thumbnail
    00016  * extraction, etc.
    00017  *
    00018  * In the future, vendor-proprietary exif extensions might be supported.
    00019  */
    00020
    00021
    00022 /*
    00023  * Tag data type information.
    00024  */
    00025 typedef enum {
    00026         EXIF_NOTYPE     = 0,    /* placeholder */
    00027         EXIF_BYTE       = 1,    /* 8-bit unsigned integer */
    00028         EXIF_ASCII      = 2,    /* 8-bit bytes w/ last byte null */
    00029         EXIF_SHORT      = 3,    /* 16-bit unsigned integer */
    00030         EXIF_LONG       = 4,    /* 32-bit unsigned integer */
    00031         EXIF_RATIONAL   = 5,    /* 64-bit unsigned fraction */
    00032         EXIF_SBYTE      = 6,    /* !8-bit signed integer */
    00033         EXIF_UNDEFINED  = 7,    /* !8-bit untyped data */
    00034         EXIF_SSHORT     = 8,    /* !16-bit signed integer */
    00035         EXIF_SLONG      = 9,    /* !32-bit signed integer */
    00036         EXIF_SRATIONAL  = 10,   /* !64-bit signed fraction */
    00037         EXIF_FLOAT      = 11,   /* !32-bit IEEE floating point */
    00038         EXIF_DOUBLE     = 12    /* !64-bit IEEE floating point */
    00039 } EXIFDataType;
    00040
    00041
    00042 typedef struct exif_parser {
    00043   char *header,*data,*ifds[10];
    00044   int ifdtags[10];  /* How many tags in each ifd */
    00045   int ifdcnt;       /* Number of IFD's, assumed to be < 10  */
    00046   unsigned int exiflen;
    00047   int preparsed,endian;
    00048 } exifparser;
    00049
    00050 typedef struct {
    00051     int tag;            /* Tag ID, see exif_tags.h */
    00052     EXIFDataType type;  /* Tag data type, see exif_tags.h */
    00053     int size;           /* Length of the data, in bytes. */
    00054     char *data;         /* The data itself, not an offset */
    00055     int num;     /* When type is (s)rational, we */
    00056     int den;   /* store the value here... */
    00057     int intval;
    00058 } ExifData;
    00059
    00060 extern int exif_debug; /* Non-zero for debug messages */
    00061
    00062 /*
    00063  * Parse an exif header, return size of the rest of the file.
    00064  */
    00065 int exif_parse_data(exifparser *exifdat);
    00066
    00067 /*
    00068  * Returns the value of a field, identified by its tag and the IFD.
    00069  */
    00070 int gpi_exif_get_field( int tag_number, int ifd, exifparser *exifdat, ExifData *tag_data);
    00071
    00072 /*
    00073  * Gets a numeric tag
    00074  */
    00075 int gpi_exif_get_int_field( int tag_number, int ifd, exifparser *exifdat);
    00076
    00077 /*
    00078  * Gets an ASCII tag.
    00079  */
    00080 char * gpi_exif_get_ascii_field( int tag_number, int ifd, exifparser *exifdat);
    00081
    00082 /*
    00083  * Returns the name of a given tag number
    00084  */
    00085 char *gpi_exif_get_tagname(int tag_number);
    00086
    00087 /*
    00088  * Returns a pointer to the thumbnail data if it
    00089  * exists.
    00090  */
    00091 unsigned char *gpi_exif_get_thumbnail(exifparser *exifdat);
    00092
    00093 /*
    00094  * The same as gpi_exif_get_thumbnail but returns
    00095  * also the thumbnail size
    00096  */
    00097 unsigned char *gpi_exif_get_thumbnail_and_size(exifparser *exifdat, long *size);
    00098
    00099 /*
    00100  * Gets the comment field if it exists.
    00101  */
    00102 int gpe_get_comment(exifparser *exifdat, char *comment);
    00103
    00104 /*
    00105  * Sets the comment field.
    00106  */
    00107 int gpe_set_comment(exifparser *exifdat, char *comment);
    00108
    00109 /*
    00110  * COMMENT ME
    00111  */
    00112 int gpi_exif_stat(exifparser *exifdata);
    00113 int gpe_dump_exif(exifparser *exifdata);
    00114
    00115 /*
    00116  * Now, all the 'defines'
    00117  */
    00118
    00119 #define EXIF_InteroperabilityIndex 0x1
    00120 #define EXIF_InteroperabilityVersion    0x2
    00121 #define EXIF_RelatedImageFileFormat 0x1000
    00122 #define EXIF_RelatedImageWidth 0x1001
    00123 #define EXIF_RelatedImageLength 0x1002
    00124
    00125 #define EXIF_NewSubFileType              0xFE
    00126 #define EXIF_ImageWidth                  0x100
    00127 #define EXIF_ImageLength                 0x101
    00128 #define EXIF_BitsPerSample               0x102
    00129 #define EXIF_Compression                 0x103
    00130 #define EXIF_PhotometricInterpretation   0x106
    00131 #define EXIF_FillOrder                   0x10A
    00132 #define EXIF_DocumentName                0x10D
    00133 #define EXIF_ImageDescription            0x10E
    00134 #define EXIF_Make                        0x10F
    00135 #define EXIF_Model                       0x110
    00136 #define EXIF_StripOffsets                0x111
    00137 #define EXIF_Orientation                 0x112
    00138 #define EXIF_SamplesPerPixel             0x115
    00139 #define EXIF_RowsPerStrip                0x116
    00140 #define EXIF_StripByteCounts             0x117
    00141 #define EXIF_XResolution                 0x11A
    00142 #define EXIF_YResolution                 0x11B
    00143 #define EXIF_PlanarConfiguration         0x11C
    00144 #define EXIF_ResolutionUnit              0x128
    00145 #define EXIF_TransferFunction            0x12D
    00146 #define EXIF_Software                    0x131
    00147 #define EXIF_DateTime                    0x132
    00148 #define EXIF_Artist                      0x13B
    00149 #define EXIF_WhitePoint                  0x13E
    00150 #define EXIF_PrimaryChromaticities       0x13F
    00151 #define EXIF_TransferRange               0x156
    00152 #define EXIF_JPEGProc                    0x200
    00153 #define EXIF_JPEGInterchangeFormat       0x201
    00154 #define EXIF_JPEGInterchangeFormatLength 0x202
    00155 #define EXIF_YCbCrCoefficients           0x211
    00156 #define EXIF_YCbCrSubSampling            0x212
    00157 #define EXIF_YCbCrPositioning            0x213
    00158 #define EXIF_ReferenceBlackWhite         0x214
    00159 #define EXIF_CFARepeatPatternDim        0x828D
    00160 #define EXIF_CFAPattern                 0x828E
    00161 #define EXIF_BatteryLevel               0x828F
    00162 #define EXIF_Copyright                  0x8298
    00163 #define EXIF_ExposureTime               0x829A
    00164 #define EXIF_FNumber                    0x829D
    00165 /* Be careful: the next tag's official name is IPTC/NAA but
    00166    we can't do a define with a "/" */
    00167 #define EXIF_IPTC_NAA                   0x83BB
    00168 #define EXIF_ExifOffset                 0x8769
    00169 #define EXIF_InterColorProfile          0x8773
    00170 #define EXIF_ExposureProgram            0x8822
    00171 #define EXIF_SpectralSensitivity        0x8824
    00172 #define EXIF_GPSInfo                    0x8825
    00173 #define EXIF_ISOSpeedRatings            0x8827
    00174 #define EXIF_OECF                       0x8828
    00175 #define EXIF_ExifVersion                0x9000
    00176 #define EXIF_DateTimeOriginal           0x9003
    00177 #define EXIF_DateTimeDigitized          0x9004
    00178 #define EXIF_ComponentsConfiguration    0x9101
    00179 #define EXIF_CompressedBitsPerPixel     0x9102
    00180 #define EXIF_ShutterSpeedValue          0x9201
    00181 #define EXIF_ApertureValue              0x9202
    00182 #define EXIF_BrightnessValue            0x9203
    00183 #define EXIF_ExposureBiasValue          0x9204
    00184 #define EXIF_MaxApertureValue           0x9205
    00185 #define EXIF_SubjectDistance            0x9206
    00186 #define EXIF_MeteringMode               0x9207
    00187 #define EXIF_LightSource                0x9208
    00188 #define EXIF_Flash                      0x9209
    00189 #define EXIF_FocalLength                0x920A
    00190 #define EXIF_MakerNote                  0x927C
    00191 #define EXIF_UserComment                0x9286
    00192 #define EXIF_SubSecTime                 0x9290
    00193 #define EXIF_SubSecTimeOriginal         0x9291
    00194 #define EXIF_SubSecTimeDigitized        0x9292
    00195 #define EXIF_FlashPixVersion            0xA000
    00196 #define EXIF_ColorSpace                 0xA001
    00197 #define EXIF_ExifImageWidth             0xA002
    00198 #define EXIF_ExifImageLength            0xA003
    00199 #define EXIF_InteroperabilityOffset     0xA005
    00200 #define EXIF_FlashEnergy                0xA20B  /* 0x920B in TIFF/EP */
    00201 #define EXIF_SpatialFrequencyResponse   0xA20C  /* 0x920C    -  - */
    00202 #define EXIF_FocalPlaneXResolution      0xA20E  /* 0x920E    -  - */
    00203 #define EXIF_FocalPlaneYResolution      0xA20F  /* 0x920F    -  - */
    00204 #define EXIF_FocalPlaneResolutionUnit   0xA210  /* 0x9210    -  - */
    00205 #define EXIF_SubjectLocation            0xA214  /* 0x9214    -  - */
    00206 #define EXIF_ExposureIndex              0xA215  /* 0x9215    -  - */
    00207 #define EXIF_SensingMethod              0xA217  /* 0x9217    -  - */
    00208 #define EXIF_FileSource                 0xA300
    00209 #define EXIF_SceneType                  0xA301
    00210
    00211 #endif /* _gphoto_exif_ */