Loading src/exif.c +237 −228 Original line number Original line Diff line number Diff line Loading @@ -42,118 +42,117 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* remove all spaces on the right end of a string */ /* remove all spaces on the right end of a string */ void exif_trim_spaces(char *str) void exif_trim_spaces(char *str) { { char *end; char *end; for (end = str; *str!='\0'; str++) for (end = str; *str != '\0'; str++) { { if (*str != ' ') { if (*str != ' ') end = str + 1; { } end = str + 1; } } *end = '\0'; } *end = '\0'; } } /* show given exif tag content with tag name */ /* show given exif tag content with tag name */ void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize) void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag, char *buffer, unsigned int maxsize) { { char s[EXIF_MAX_DATA]; char s[EXIF_MAX_DATA]; ExifEntry *entry = NULL; ExifEntry *entry = NULL; if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { entry = exif_content_get_entry(d->ifd[ifd], tag); entry = exif_content_get_entry(d->ifd[ifd], tag); if (entry != NULL) { if (entry != NULL) /* Get the contents of the tag in human-readable form */ { exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Get the contents of the tag in human-readable form */ exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Don't bother printing it if it's entirely blank */ exif_trim_spaces(s); /* Don't bother printing it if it's entirely blank */ if (*s != '\0') { exif_trim_spaces(s); D(("%s: %s\n", if (*s != '\0') exif_tag_get_name_in_ifd(tag, ifd), s)); { snprintf(buffer, (size_t) maxsize, D(("%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s)); "%s: %s\n", snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s); exif_tag_get_name_in_ifd(tag, } ifd), s); } } } } } } } /* show given exif tag content without tag name */ /* show given exif tag content without tag name */ void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize) void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag, char *buffer, unsigned int maxsize) { { char s[EXIF_MAX_DATA]; char s[EXIF_MAX_DATA]; ExifEntry *entry = NULL; ExifEntry *entry = NULL; if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { entry = exif_content_get_entry(d->ifd[ifd], tag); entry = exif_content_get_entry(d->ifd[ifd], tag); if (entry != NULL) { if (entry != NULL) /* Get the contents of the tag in human-readable form */ { exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Get the contents of the tag in human-readable form */ exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Don't bother printing it if it's entirely blank */ exif_trim_spaces(s); /* Don't bother printing it if it's entirely blank */ if (*s != '\0') { exif_trim_spaces(s); D(("%s - %s\n", if (*s != '\0') exif_tag_get_name_in_ifd(tag, ifd), s)); { snprintf(buffer, (size_t) maxsize, "%s", D(("%s - %s\n", exif_tag_get_name_in_ifd(tag,ifd), s)); s); snprintf(buffer, (size_t)maxsize, "%s", s); } } } } } } } } /* Show the given MakerNote tag if it exists */ /* Show the given MakerNote tag if it exists */ void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize) void exif_get_mnote_tag(ExifData * d, unsigned int tag, char *buffer, unsigned int maxsize) { { ExifMnoteData *mn = NULL; ExifMnoteData *mn = NULL; int i, num; int i, num; char buf[1024]; char buf[1024]; if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { mn = exif_data_get_mnote_data(d); mn = exif_data_get_mnote_data(d); } else { } return; else } { return; if (mn != NULL) { } num = exif_mnote_data_count(mn); if ( mn != NULL ) /* Loop through all MakerNote tags, searching for the desired one */ { for (i = 0; i < num; ++i) { num = exif_mnote_data_count(mn); D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), /* Loop through all MakerNote tags, searching for the desired one */ exif_mnote_data_get_id(mn, i), for (i=0; i < num; ++i) exif_mnote_data_get_name(mn, i), { exif_mnote_data_get_title(mn, i))); D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), exif_mnote_data_get_id(mn, i), if (exif_mnote_data_get_id(mn, i) == tag) { exif_mnote_data_get_name(mn,i), if (exif_mnote_data_get_value exif_mnote_data_get_title(mn, i) )); (mn, i, buf, sizeof(buf))) { /* Don't bother printing it if it's entirely blank */ if (exif_mnote_data_get_id(mn, i) == tag) exif_trim_spaces(buf); { if (*buf != '\0') { if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) D(("%s\n", buf)); { snprintf(buffer, /* Don't bother printing it if it's entirely blank */ (size_t) maxsize, exif_trim_spaces(buf); "%s: %s\n", if (*buf != '\0') exif_mnote_data_get_title { (mn, i), buf); D(("%s\n", buf)); } snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf); } } } } } } } } } } } Loading @@ -161,80 +160,75 @@ void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned in /* get gps coordinates if available */ /* get gps coordinates if available */ void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize) void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize) { { char buf[EXIF_STD_BUF_LEN]; char buf[EXIF_STD_BUF_LEN]; buf[0] = '\0'; buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF, buf, sizeof(buf)); exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF, if ( buf[0] != '\0' ) buf, sizeof(buf)); { if (buf[0] != '\0') { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "GPS: %s ", buf); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), } "GPS: %s ", buf); else } else { { return; return; } } buf[0] = '\0'; buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf, exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf, sizeof(buf)); sizeof(buf)); if ( buf[0] != '\0' ) if (buf[0] != '\0') { { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf); "%s ", buf); } } else { else return; { } return; } buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF, buf[0] = '\0'; buf, sizeof(buf)); exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF, buf, sizeof(buf)); if (buf[0] != '\0') { if ( buf[0] != '\0' ) snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), { ", %s ", buf); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), ", %s ", buf); } else { } return; else } { return; buf[0] = '\0'; } exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf, sizeof(buf)); buf[0] = '\0'; if (buf[0] != '\0') { exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf, sizeof(buf)); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), if ( buf[0] != '\0' ) "%s ", buf); { } else { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf); return; } } else { buf[0] = '\0'; return; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf, } sizeof(buf)); if (buf[0] != '\0') { buf[0] = '\0'; snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf, sizeof(buf)); "(%s)\n", buf); if ( buf[0] != '\0' ) } else { { return; snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "(%s)\n", buf); } } else { return; } } } /* return data structure with exif data if available */ /* return data structure with exif data if available */ ExifData * exif_get_data(char *path) ExifData *exif_get_data(char *path) { { ExifData *ed = NULL; ExifData *ed = NULL; /* Load an ExifData object from an EXIF file */ /* Load an ExifData object from an EXIF file */ ed = exif_data_new_from_file(path); ed = exif_data_new_from_file(path); if (ed == NULL) if (ed == NULL) { { D(("File not readable or no Exif data present in %s\n", D(("File not readable or no Exif data present in %s\n", path)); path)); } } return(ed); return (ed); } } Loading @@ -243,76 +237,91 @@ ExifData * exif_get_data(char *path) /* get all exif data in readable form */ /* get all exif data in readable form */ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) { { ExifEntry *entry = NULL; ExifEntry *entry = NULL; char buf[EXIF_STD_BUF_LEN]; char buf[EXIF_STD_BUF_LEN]; unsigned short int i = 0; unsigned short int i = 0; if ( (buffer == NULL) || (maxsize == 0) ) if ((buffer == NULL) || (maxsize == 0)) { { return; return; } else if (ed == NULL) { } snprintf(buffer, (size_t) maxsize, "%s\n", else if (ed == NULL) "No Exif data in file."); { return; snprintf(buffer, (size_t)maxsize, "%s\n", "No Exif data in file."); } else { return; /* show normal exif tags. list must be defined in exif_cfg.h */ } while ((i < USHRT_MAX) else && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT)) { { exif_get_tag(ed, Exif_tag_list[i].ifd, /* show normal exif tags. list must be defined in exif_cfg.h */ Exif_tag_list[i].tag, while ( (i < USHRT_MAX) && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT) ) buffer + strlen(buffer), { maxsize - strlen(buffer)); exif_get_tag(ed, Exif_tag_list[i].ifd, Exif_tag_list[i].tag, buffer + strlen(buffer), maxsize - strlen(buffer)); i++; i++; } } /* show vendor specific makernote tags */ /* show vendor specific makernote tags */ entry = entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_MAKE); exif_content_get_entry(ed->ifd[EXIF_IFD_0], if (entry != NULL) EXIF_TAG_MAKE); { if (entry != NULL) { if (exif_entry_get_value(entry, buf, sizeof(buf))) if (exif_entry_get_value(entry, buf, sizeof(buf))) { { exif_trim_spaces(buf); exif_trim_spaces(buf); if ((strcmp(buf, "NIKON CORPORATION") == 0) if ( (strcmp(buf, "NIKON CORPORATION") == 0) || (strcmp(buf, "Nikon") == 0) || (strcmp(buf, "Nikon") == 0) || (strcmp(buf, "NIKON") == 0) || (strcmp(buf, "NIKON") == 0) ) { ) /* show nikon makernote exif tags. list must be defined in exif_cfg.h */ { i = 0; /* show nikon makernote exif tags. list must be defined in exif_cfg.h */ while ((i < USHRT_MAX) i=0; && while ( (i < USHRT_MAX) && (Exif_makernote_nikon_tag_list[i] != EXIF_NIKON_MAKERNOTE_END) ) (Exif_makernote_nikon_tag_list { [i] != exn_get_mnote_nikon_tags(ed, Exif_makernote_nikon_tag_list[i], EXIF_NIKON_MAKERNOTE_END)) buffer + strlen(buffer), maxsize - strlen(buffer)); { i++; exn_get_mnote_nikon_tags } (ed, Exif_makernote_nikon_tag_list } [i], else if ( (strcmp(buf, "Canon") == 0) ) buffer + { strlen(buffer), /* show canon makernote exif tags. list must be defined in exif_cfg.h */ maxsize - i=0; strlen(buffer)); while ( (i < USHRT_MAX) && (Exif_makernote_canon_tag_list[i] != EXIF_CANON_MAKERNOTE_END) ) i++; { } exc_get_mnote_canon_tags(ed, Exif_makernote_canon_tag_list[i], buffer + strlen(buffer), maxsize - strlen(buffer)); } else if ((strcmp(buf, "Canon") == 0)) { i++; /* show canon makernote exif tags. list must be defined in exif_cfg.h */ } i = 0; while ((i < USHRT_MAX) } && else (Exif_makernote_canon_tag_list { [i] != } EXIF_CANON_MAKERNOTE_END)) } { exc_get_mnote_canon_tags } (ed, Exif_makernote_canon_tag_list /* show gps coordinates */ [i], exif_get_gps_coords(ed, buffer + strlen(buffer), maxsize - strlen(buffer)); buffer + strlen(buffer), } maxsize - strlen(buffer)); i++; } } else { } } } /* show gps coordinates */ exif_get_gps_coords(ed, buffer + strlen(buffer), maxsize - strlen(buffer)); } } } #endif #endif src/exif.h +11 −6 Original line number Original line Diff line number Diff line Loading @@ -32,11 +32,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define EXIF_STD_BUF_LEN 128 #define EXIF_STD_BUF_LEN 128 extern void exif_trim_spaces(char *str); extern void exif_trim_spaces(char *str); extern void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize); extern void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag, extern void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize); extern void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag, extern void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern ExifData * exif_get_data(char *path); extern void exif_get_mnote_tag(ExifData * d, unsigned int tag, extern void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize); extern ExifData *exif_get_data(char *path); extern void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize); #endif #endif src/exif_canon.c +15 −15 Original line number Original line Diff line number Diff line Loading @@ -36,26 +36,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* get interesting canon maker note tags in readable form */ /* get interesting canon maker note tags in readable form */ void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize) void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag, char *buffer, unsigned int maxsize) { { /* char buf[EXIF_STD_BUF_LEN]; /* char buf[EXIF_STD_BUF_LEN]; buf[0] = '\0'; buf[0] = '\0'; exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf)); exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf)); exif_trim_spaces(buf); */ exif_trim_spaces(buf); */ switch(tag) switch (tag) { { default: default: { { /* normal makernote tags without special treatment */ /* normal makernote tags without special treatment */ exif_get_mnote_tag(ed, tag, buffer, maxsize); exif_get_mnote_tag(ed, tag, buffer, maxsize); } } break; break; } } return; return; } } #endif #endif src/exif_canon.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libexif/exif-data.h> #include <libexif/exif-data.h> extern void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize); extern void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag, char *buffer, unsigned int maxsize); #endif #endif src/exif_cfg.h +48 −52 Original line number Original line Diff line number Diff line Loading @@ -28,78 +28,74 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libexif/exif-data.h> #include <libexif/exif-data.h> typedef struct typedef struct { { ExifIfd ifd; /* section */ ExifIfd ifd; /* section */ ExifTag tag; /* tag */ ExifTag tag; /* tag */ } t_EXIF_INFO; } t_EXIF_INFO; /* show these standard tags. section must be given first, than the tag itself */ /* show these standard tags. section must be given first, than the tag itself */ /* definition: http://libexif.sourceforge.net/api/exif-tag_8h.html */ /* definition: http://libexif.sourceforge.net/api/exif-tag_8h.html */ const t_EXIF_INFO Exif_tag_list [] = const t_EXIF_INFO Exif_tag_list[] = { { { EXIF_IFD_0, EXIF_TAG_MAKE }, {EXIF_IFD_0, EXIF_TAG_MAKE}, { EXIF_IFD_0, EXIF_TAG_MODEL }, {EXIF_IFD_0, EXIF_TAG_MODEL}, { EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION }, {EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION}, { EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL }, {EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME}, { EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_FNUMBER }, {EXIF_IFD_EXIF, EXIF_TAG_FNUMBER}, { EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS }, {EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS}, { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH }, {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH}, { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM }, {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM}, { EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE }, {EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE}, { EXIF_IFD_EXIF, EXIF_TAG_FLASH }, {EXIF_IFD_EXIF, EXIF_TAG_FLASH}, { EXIF_IFD_COUNT, 0 } /* end marker */ {EXIF_IFD_COUNT, 0} /* end marker */ }; }; /* Nikon */ /* Nikon */ #define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */ #define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */ /* show these nikon makernote tags */ /* show these nikon makernote tags */ const unsigned int Exif_makernote_nikon_tag_list [] = const unsigned int Exif_makernote_nikon_tag_list[] = { { 6, 6, 8, /* Flash Setting */ 8, /* Flash Setting */ 9, /* Flash Mode */ 9, /* Flash Mode */ 135, /* Flash used */ 135, /* Flash used */ 18, /* Flash Exposure Comp */ 18, /* Flash Exposure Comp */ 168, /* Flash info: control mode */ 168, /* Flash info: control mode */ 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */ 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */ 5, /* White Balance */ 5, /* White Balance */ 132, /* Lens */ 132, /* Lens */ 171, /* Digital Vari-Program */ 171, /* Digital Vari-Program */ 34, /* Active D-Lighting */ 34, /* Active D-Lighting */ 35, /* PictureControlData */ 35, /* PictureControlData */ 183, /* AFInfo2 */ 183, /* AFInfo2 */ EXIF_NIKON_MAKERNOTE_END /* end marker */ EXIF_NIKON_MAKERNOTE_END /* end marker */ }; }; /* Canon */ /* Canon */ #define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */ #define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */ /* show these canon makernote tags */ /* show these canon makernote tags */ const unsigned int Exif_makernote_canon_tag_list [] = const unsigned int Exif_makernote_canon_tag_list[] = { { 8, /* Image Number */ 8, /* Image Number */ 9, /* Owner Name */ 9, /* Owner Name */ EXIF_CANON_MAKERNOTE_END /* end marker */ EXIF_CANON_MAKERNOTE_END /* end marker */ }; }; Loading Loading
src/exif.c +237 −228 Original line number Original line Diff line number Diff line Loading @@ -42,118 +42,117 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* remove all spaces on the right end of a string */ /* remove all spaces on the right end of a string */ void exif_trim_spaces(char *str) void exif_trim_spaces(char *str) { { char *end; char *end; for (end = str; *str!='\0'; str++) for (end = str; *str != '\0'; str++) { { if (*str != ' ') { if (*str != ' ') end = str + 1; { } end = str + 1; } } *end = '\0'; } *end = '\0'; } } /* show given exif tag content with tag name */ /* show given exif tag content with tag name */ void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize) void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag, char *buffer, unsigned int maxsize) { { char s[EXIF_MAX_DATA]; char s[EXIF_MAX_DATA]; ExifEntry *entry = NULL; ExifEntry *entry = NULL; if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { entry = exif_content_get_entry(d->ifd[ifd], tag); entry = exif_content_get_entry(d->ifd[ifd], tag); if (entry != NULL) { if (entry != NULL) /* Get the contents of the tag in human-readable form */ { exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Get the contents of the tag in human-readable form */ exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Don't bother printing it if it's entirely blank */ exif_trim_spaces(s); /* Don't bother printing it if it's entirely blank */ if (*s != '\0') { exif_trim_spaces(s); D(("%s: %s\n", if (*s != '\0') exif_tag_get_name_in_ifd(tag, ifd), s)); { snprintf(buffer, (size_t) maxsize, D(("%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s)); "%s: %s\n", snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_tag_get_name_in_ifd(tag,ifd), s); exif_tag_get_name_in_ifd(tag, } ifd), s); } } } } } } } /* show given exif tag content without tag name */ /* show given exif tag content without tag name */ void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize) void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag, char *buffer, unsigned int maxsize) { { char s[EXIF_MAX_DATA]; char s[EXIF_MAX_DATA]; ExifEntry *entry = NULL; ExifEntry *entry = NULL; if ( (d != NULL) && (buffer != NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { entry = exif_content_get_entry(d->ifd[ifd], tag); entry = exif_content_get_entry(d->ifd[ifd], tag); if (entry != NULL) { if (entry != NULL) /* Get the contents of the tag in human-readable form */ { exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Get the contents of the tag in human-readable form */ exif_entry_get_value(entry, s, EXIF_MAX_DATA); /* Don't bother printing it if it's entirely blank */ exif_trim_spaces(s); /* Don't bother printing it if it's entirely blank */ if (*s != '\0') { exif_trim_spaces(s); D(("%s - %s\n", if (*s != '\0') exif_tag_get_name_in_ifd(tag, ifd), s)); { snprintf(buffer, (size_t) maxsize, "%s", D(("%s - %s\n", exif_tag_get_name_in_ifd(tag,ifd), s)); s); snprintf(buffer, (size_t)maxsize, "%s", s); } } } } } } } } /* Show the given MakerNote tag if it exists */ /* Show the given MakerNote tag if it exists */ void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize) void exif_get_mnote_tag(ExifData * d, unsigned int tag, char *buffer, unsigned int maxsize) { { ExifMnoteData *mn = NULL; ExifMnoteData *mn = NULL; int i, num; int i, num; char buf[1024]; char buf[1024]; if ( (d!=NULL) && (buffer!=NULL) && (maxsize > 0) ) if ((d != NULL) && (buffer != NULL) && (maxsize > 0)) { { mn = exif_data_get_mnote_data(d); mn = exif_data_get_mnote_data(d); } else { } return; else } { return; if (mn != NULL) { } num = exif_mnote_data_count(mn); if ( mn != NULL ) /* Loop through all MakerNote tags, searching for the desired one */ { for (i = 0; i < num; ++i) { num = exif_mnote_data_count(mn); D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), /* Loop through all MakerNote tags, searching for the desired one */ exif_mnote_data_get_id(mn, i), for (i=0; i < num; ++i) exif_mnote_data_get_name(mn, i), { exif_mnote_data_get_title(mn, i))); D(("%d/%d %d 0x%2x %s; %s\n", i, num, exif_mnote_data_get_id(mn, i), exif_mnote_data_get_id(mn, i), if (exif_mnote_data_get_id(mn, i) == tag) { exif_mnote_data_get_name(mn,i), if (exif_mnote_data_get_value exif_mnote_data_get_title(mn, i) )); (mn, i, buf, sizeof(buf))) { /* Don't bother printing it if it's entirely blank */ if (exif_mnote_data_get_id(mn, i) == tag) exif_trim_spaces(buf); { if (*buf != '\0') { if (exif_mnote_data_get_value(mn, i, buf, sizeof(buf))) D(("%s\n", buf)); { snprintf(buffer, /* Don't bother printing it if it's entirely blank */ (size_t) maxsize, exif_trim_spaces(buf); "%s: %s\n", if (*buf != '\0') exif_mnote_data_get_title { (mn, i), buf); D(("%s\n", buf)); } snprintf(buffer, (size_t)maxsize, "%s: %s\n", exif_mnote_data_get_title(mn, i), buf); } } } } } } } } } } } Loading @@ -161,80 +160,75 @@ void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned in /* get gps coordinates if available */ /* get gps coordinates if available */ void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize) void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize) { { char buf[EXIF_STD_BUF_LEN]; char buf[EXIF_STD_BUF_LEN]; buf[0] = '\0'; buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF, buf, sizeof(buf)); exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE_REF, if ( buf[0] != '\0' ) buf, sizeof(buf)); { if (buf[0] != '\0') { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "GPS: %s ", buf); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), } "GPS: %s ", buf); else } else { { return; return; } } buf[0] = '\0'; buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf, exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LATITUDE, buf, sizeof(buf)); sizeof(buf)); if ( buf[0] != '\0' ) if (buf[0] != '\0') { { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf); "%s ", buf); } } else { else return; { } return; } buf[0] = '\0'; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF, buf[0] = '\0'; buf, sizeof(buf)); exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE_REF, buf, sizeof(buf)); if (buf[0] != '\0') { if ( buf[0] != '\0' ) snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), { ", %s ", buf); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), ", %s ", buf); } else { } return; else } { return; buf[0] = '\0'; } exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf, sizeof(buf)); buf[0] = '\0'; if (buf[0] != '\0') { exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_LONGITUDE, buf, sizeof(buf)); snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), if ( buf[0] != '\0' ) "%s ", buf); { } else { snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "%s ", buf); return; } } else { buf[0] = '\0'; return; exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf, } sizeof(buf)); if (buf[0] != '\0') { buf[0] = '\0'; snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), exif_get_tag_content(ed, EXIF_IFD_GPS, EXIF_TAG_GPS_MAP_DATUM, buf, sizeof(buf)); "(%s)\n", buf); if ( buf[0] != '\0' ) } else { { return; snprintf(buffer + strlen(buffer), maxsize - strlen(buffer), "(%s)\n", buf); } } else { return; } } } /* return data structure with exif data if available */ /* return data structure with exif data if available */ ExifData * exif_get_data(char *path) ExifData *exif_get_data(char *path) { { ExifData *ed = NULL; ExifData *ed = NULL; /* Load an ExifData object from an EXIF file */ /* Load an ExifData object from an EXIF file */ ed = exif_data_new_from_file(path); ed = exif_data_new_from_file(path); if (ed == NULL) if (ed == NULL) { { D(("File not readable or no Exif data present in %s\n", D(("File not readable or no Exif data present in %s\n", path)); path)); } } return(ed); return (ed); } } Loading @@ -243,76 +237,91 @@ ExifData * exif_get_data(char *path) /* get all exif data in readable form */ /* get all exif data in readable form */ void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize) { { ExifEntry *entry = NULL; ExifEntry *entry = NULL; char buf[EXIF_STD_BUF_LEN]; char buf[EXIF_STD_BUF_LEN]; unsigned short int i = 0; unsigned short int i = 0; if ( (buffer == NULL) || (maxsize == 0) ) if ((buffer == NULL) || (maxsize == 0)) { { return; return; } else if (ed == NULL) { } snprintf(buffer, (size_t) maxsize, "%s\n", else if (ed == NULL) "No Exif data in file."); { return; snprintf(buffer, (size_t)maxsize, "%s\n", "No Exif data in file."); } else { return; /* show normal exif tags. list must be defined in exif_cfg.h */ } while ((i < USHRT_MAX) else && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT)) { { exif_get_tag(ed, Exif_tag_list[i].ifd, /* show normal exif tags. list must be defined in exif_cfg.h */ Exif_tag_list[i].tag, while ( (i < USHRT_MAX) && (Exif_tag_list[i].ifd != EXIF_IFD_COUNT) ) buffer + strlen(buffer), { maxsize - strlen(buffer)); exif_get_tag(ed, Exif_tag_list[i].ifd, Exif_tag_list[i].tag, buffer + strlen(buffer), maxsize - strlen(buffer)); i++; i++; } } /* show vendor specific makernote tags */ /* show vendor specific makernote tags */ entry = entry = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_MAKE); exif_content_get_entry(ed->ifd[EXIF_IFD_0], if (entry != NULL) EXIF_TAG_MAKE); { if (entry != NULL) { if (exif_entry_get_value(entry, buf, sizeof(buf))) if (exif_entry_get_value(entry, buf, sizeof(buf))) { { exif_trim_spaces(buf); exif_trim_spaces(buf); if ((strcmp(buf, "NIKON CORPORATION") == 0) if ( (strcmp(buf, "NIKON CORPORATION") == 0) || (strcmp(buf, "Nikon") == 0) || (strcmp(buf, "Nikon") == 0) || (strcmp(buf, "NIKON") == 0) || (strcmp(buf, "NIKON") == 0) ) { ) /* show nikon makernote exif tags. list must be defined in exif_cfg.h */ { i = 0; /* show nikon makernote exif tags. list must be defined in exif_cfg.h */ while ((i < USHRT_MAX) i=0; && while ( (i < USHRT_MAX) && (Exif_makernote_nikon_tag_list[i] != EXIF_NIKON_MAKERNOTE_END) ) (Exif_makernote_nikon_tag_list { [i] != exn_get_mnote_nikon_tags(ed, Exif_makernote_nikon_tag_list[i], EXIF_NIKON_MAKERNOTE_END)) buffer + strlen(buffer), maxsize - strlen(buffer)); { i++; exn_get_mnote_nikon_tags } (ed, Exif_makernote_nikon_tag_list } [i], else if ( (strcmp(buf, "Canon") == 0) ) buffer + { strlen(buffer), /* show canon makernote exif tags. list must be defined in exif_cfg.h */ maxsize - i=0; strlen(buffer)); while ( (i < USHRT_MAX) && (Exif_makernote_canon_tag_list[i] != EXIF_CANON_MAKERNOTE_END) ) i++; { } exc_get_mnote_canon_tags(ed, Exif_makernote_canon_tag_list[i], buffer + strlen(buffer), maxsize - strlen(buffer)); } else if ((strcmp(buf, "Canon") == 0)) { i++; /* show canon makernote exif tags. list must be defined in exif_cfg.h */ } i = 0; while ((i < USHRT_MAX) } && else (Exif_makernote_canon_tag_list { [i] != } EXIF_CANON_MAKERNOTE_END)) } { exc_get_mnote_canon_tags } (ed, Exif_makernote_canon_tag_list /* show gps coordinates */ [i], exif_get_gps_coords(ed, buffer + strlen(buffer), maxsize - strlen(buffer)); buffer + strlen(buffer), } maxsize - strlen(buffer)); i++; } } else { } } } /* show gps coordinates */ exif_get_gps_coords(ed, buffer + strlen(buffer), maxsize - strlen(buffer)); } } } #endif #endif
src/exif.h +11 −6 Original line number Original line Diff line number Diff line Loading @@ -32,11 +32,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define EXIF_STD_BUF_LEN 128 #define EXIF_STD_BUF_LEN 128 extern void exif_trim_spaces(char *str); extern void exif_trim_spaces(char *str); extern void exif_get_tag(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize); extern void exif_get_tag(ExifData * d, ExifIfd ifd, ExifTag tag, extern void exif_get_tag_content(ExifData *d, ExifIfd ifd, ExifTag tag, char* buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern void exif_get_mnote_tag(ExifData *d, unsigned int tag, char* buffer, unsigned int maxsize); extern void exif_get_tag_content(ExifData * d, ExifIfd ifd, ExifTag tag, extern void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern ExifData * exif_get_data(char *path); extern void exif_get_mnote_tag(ExifData * d, unsigned int tag, extern void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize); char *buffer, unsigned int maxsize); extern void exif_get_gps_coords(ExifData * ed, char *buffer, unsigned int maxsize); extern ExifData *exif_get_data(char *path); extern void exif_get_info(ExifData * ed, char *buffer, unsigned int maxsize); #endif #endif
src/exif_canon.c +15 −15 Original line number Original line Diff line number Diff line Loading @@ -36,26 +36,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* get interesting canon maker note tags in readable form */ /* get interesting canon maker note tags in readable form */ void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize) void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag, char *buffer, unsigned int maxsize) { { /* char buf[EXIF_STD_BUF_LEN]; /* char buf[EXIF_STD_BUF_LEN]; buf[0] = '\0'; buf[0] = '\0'; exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf)); exif_get_tag(ed, EXIF_IFD_EXIF, EXIF_TAG_FLASH, buf, sizeof(buf)); exif_trim_spaces(buf); */ exif_trim_spaces(buf); */ switch(tag) switch (tag) { { default: default: { { /* normal makernote tags without special treatment */ /* normal makernote tags without special treatment */ exif_get_mnote_tag(ed, tag, buffer, maxsize); exif_get_mnote_tag(ed, tag, buffer, maxsize); } } break; break; } } return; return; } } #endif #endif
src/exif_canon.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libexif/exif-data.h> #include <libexif/exif-data.h> extern void exc_get_mnote_canon_tags(ExifData *ed, unsigned int tag, char * buffer, unsigned int maxsize); extern void exc_get_mnote_canon_tags(ExifData * ed, unsigned int tag, char *buffer, unsigned int maxsize); #endif #endif
src/exif_cfg.h +48 −52 Original line number Original line Diff line number Diff line Loading @@ -28,78 +28,74 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <libexif/exif-data.h> #include <libexif/exif-data.h> typedef struct typedef struct { { ExifIfd ifd; /* section */ ExifIfd ifd; /* section */ ExifTag tag; /* tag */ ExifTag tag; /* tag */ } t_EXIF_INFO; } t_EXIF_INFO; /* show these standard tags. section must be given first, than the tag itself */ /* show these standard tags. section must be given first, than the tag itself */ /* definition: http://libexif.sourceforge.net/api/exif-tag_8h.html */ /* definition: http://libexif.sourceforge.net/api/exif-tag_8h.html */ const t_EXIF_INFO Exif_tag_list [] = const t_EXIF_INFO Exif_tag_list[] = { { { EXIF_IFD_0, EXIF_TAG_MAKE }, {EXIF_IFD_0, EXIF_TAG_MAKE}, { EXIF_IFD_0, EXIF_TAG_MODEL }, {EXIF_IFD_0, EXIF_TAG_MODEL}, { EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION }, {EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION}, { EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL }, {EXIF_IFD_EXIF, EXIF_TAG_DATE_TIME_ORIGINAL}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_TIME}, { EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_SHUTTER_SPEED_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_FNUMBER }, {EXIF_IFD_EXIF, EXIF_TAG_FNUMBER}, { EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_APERTURE_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_BIAS_VALUE}, { EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS }, {EXIF_IFD_EXIF, EXIF_TAG_ISO_SPEED_RATINGS}, { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH }, {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH}, { EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM }, {EXIF_IFD_EXIF, EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_MODE}, { EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM }, {EXIF_IFD_EXIF, EXIF_TAG_EXPOSURE_PROGRAM}, { EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE }, {EXIF_IFD_EXIF, EXIF_TAG_SCENE_CAPTURE_TYPE}, { EXIF_IFD_EXIF, EXIF_TAG_FLASH }, {EXIF_IFD_EXIF, EXIF_TAG_FLASH}, { EXIF_IFD_COUNT, 0 } /* end marker */ {EXIF_IFD_COUNT, 0} /* end marker */ }; }; /* Nikon */ /* Nikon */ #define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */ #define EXIF_NIKON_MAKERNOTE_END 0 /* end marker: if 0 used as a tag we must find something else */ /* show these nikon makernote tags */ /* show these nikon makernote tags */ const unsigned int Exif_makernote_nikon_tag_list [] = const unsigned int Exif_makernote_nikon_tag_list[] = { { 6, 6, 8, /* Flash Setting */ 8, /* Flash Setting */ 9, /* Flash Mode */ 9, /* Flash Mode */ 135, /* Flash used */ 135, /* Flash used */ 18, /* Flash Exposure Comp */ 18, /* Flash Exposure Comp */ 168, /* Flash info: control mode */ 168, /* Flash info: control mode */ 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */ 2, /* ISO. Has some more info than EXIF_TAG_ISO_SPEED_RATINGS but also fails on Lo.1 */ 5, /* White Balance */ 5, /* White Balance */ 132, /* Lens */ 132, /* Lens */ 171, /* Digital Vari-Program */ 171, /* Digital Vari-Program */ 34, /* Active D-Lighting */ 34, /* Active D-Lighting */ 35, /* PictureControlData */ 35, /* PictureControlData */ 183, /* AFInfo2 */ 183, /* AFInfo2 */ EXIF_NIKON_MAKERNOTE_END /* end marker */ EXIF_NIKON_MAKERNOTE_END /* end marker */ }; }; /* Canon */ /* Canon */ #define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */ #define EXIF_CANON_MAKERNOTE_END 0xFFFF /* end marker: if this is used as a tag we must find something else */ /* show these canon makernote tags */ /* show these canon makernote tags */ const unsigned int Exif_makernote_canon_tag_list [] = const unsigned int Exif_makernote_canon_tag_list[] = { { 8, /* Image Number */ 8, /* Image Number */ 9, /* Owner Name */ 9, /* Owner Name */ EXIF_CANON_MAKERNOTE_END /* end marker */ EXIF_CANON_MAKERNOTE_END /* end marker */ }; }; Loading