Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <libexif/exif-data.h>
- static void trim_spaces(char *buf){
- char *s = buf-1;
- for (; *buf; ++buf) {
- if (*buf != ' ') s = buf;
- }
- *++s = 0; /* nul terminate the string on the first of the final spaces */
- }
- static char* read_tag(ExifData *ed, ExifIfd eid, ExifTag tag){
- static char result[1024];
- ExifEntry *entry = exif_content_get_entry(ed->ifd[eid], tag);
- if (entry){
- char buf[1024];
- exif_entry_get_value(entry, buf, sizeof(buf));
- trim_spaces(buf);
- if (*buf) strcpy(result, buf);
- else strcpy(result, "NULL");
- }
- else strcpy(result, "NULL");
- return result;
- }
- int main(void){
- ExifData *ed;
- ed = exif_data_new_from_file("img01.jpg");
- if (!ed) {
- printf("File not readable or no EXIF data in file %s\n", argv[1]);
- return 1;
- }
- printf("Model : %s\n", read_tag(ed, EXIF_IFD_0, EXIF_TAG_MODEL));
- exif_data_unref(ed);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement