I have a JPG file that was taken using BlackBerry 10 Dev Alpha. This code (a slightly modified version of this example) prints the result correctly
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;
}
Which means the output of:
printf("Model : %s\n", read_tag(ed, EXIF_IFD_0, EXIF_TAG_MODEL));
is:
Model : BlackBerry 10 Dev Alpha
Now I wonder how to replace "BlackBerry 10 Dev Alpha" (EXIF_TAG_MODEL) with another value, e.g "Nokia 3330". I already take a look at another example . Unfortunately I found it quite hard to read. Maybe someone has a shorter/straightforward code?
libexif doesn't support directly loading JPG's in. You'll need another package to read in the JPG and extract the EXIF header (or you could write something yourself).
Note that in the example it simply creates a new exif header, then saves it to file using fwrite, and then appends the raw JPG data without exif information on the end in this part of the code here:
There is an excellent Github project called exifyay that uses libexif and has two extra libs that handle reading in JPGS. It is a python project but the sources for the libraries are C. You can find exifyay here (note I am not involved in any way with exifyay or libexif)
I have just recently compiled libexif and merged sources from exifyay into a VS2010 project here. There is an example in the folder 'contrib\examples\LibexifExample'. If you don't like downloading random links here is a sample of the code I got working: