Initial commit
This commit is contained in:
commit
5002fbeb91
5
README
Normal file
5
README
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Requires: libexif-dev on Debain or libexif-devel on Fedora/RHEL
|
||||||
|
|
||||||
|
Compile:
|
||||||
|
|
||||||
|
gcc -o exif_viewer exif_viewer.c $(pkg-config --cflags --libs libexif)
|
54
exif_viewer.c
Normal file
54
exif_viewer.c
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <libexif/exif-data.h>
|
||||||
|
|
||||||
|
// Prints EXIF entry
|
||||||
|
// Requires: pointer to ExifEntry
|
||||||
|
// pointer to user_data
|
||||||
|
void printExifEntry(ExifEntry *entry, void *user_data) {
|
||||||
|
char value[1024];
|
||||||
|
|
||||||
|
// If entry does not exist just quit
|
||||||
|
if (!entry) return;
|
||||||
|
|
||||||
|
// Get the value as a string
|
||||||
|
exif_entry_get_value(entry, value, sizeof(value));
|
||||||
|
if (*value) {
|
||||||
|
printf("%s: %s\n", exif_tag_get_name(entry->tag), value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// showExif
|
||||||
|
// Gets passed content from exif_data_foreach_content
|
||||||
|
// calls printExif
|
||||||
|
void showExif(ExifContent *content, void *user_data) {
|
||||||
|
if (!content) return;
|
||||||
|
|
||||||
|
// Iterate over all entries in the content and print them
|
||||||
|
exif_content_foreach_entry(content, printExifEntry, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
ExifData *exifData;
|
||||||
|
const char *file;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <file-path>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
file = argv[1];
|
||||||
|
exifData = exif_data_new_from_file(file);
|
||||||
|
if (!exifData) {
|
||||||
|
fprintf(stderr, "Error: Unable to open file %s\n", file);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate over all EXIF contents and print entries
|
||||||
|
exif_data_foreach_content(exifData, showExif, NULL);
|
||||||
|
|
||||||
|
// Free the EXIF data
|
||||||
|
exif_data_unref(exifData);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user