tags:

views:

396

answers:

2

Hi,

Searched through net, could't find a way to read/write file metadata using C or C++, however, there are tools available for this, and also there are API's in C# and Java to do this. But I want to do it from scratch in C or C++.

For example, read/write image metadata.

Have found out that there are three formats in which metadata is written to files. EXIF, IPTC and XMP.

Thanks.

+1  A: 

Hello. There are different solutions. One is to define a structure (but make sure the field alignements are correct), then read the data, and use the structure to access the fields. Trivial example:

struct header {
    uint32_t len;
    unsigned char type;
    char name[16];
};

struct header hdr;

read(fd,&hdr,sizeof(hdr));

... access your fields using the structure ...

The topic is a bit more complex than this ;) But since you did not specified much more I think this still can help a bit.

antirez
Thanks for the structure. But you realize yourself that it's not that simple!
Rajendra Kumar Uppal
+1  A: 

Why would you want to do it from scratch?

Anyway, you need documentation and you may also want to look at an existing library for helps, expecially if you have no experience in the field.

Have you tried Exiv ?

Exiv2 is a C++ library and a command line utility to manage image metadata. It provides fast and easy read and write access to the Exif, IPTC and XMP metadata of images in various formats. Exiv2 is available as free software and with a commercial license, and is used in many projects.

Stéphane
Don't want to use any library. Thanks for the information about the library anyway.
Rajendra Kumar Uppal