ExifTool Forum

ExifTool => Developers => Topic started by: nagibator on July 12, 2018, 04:38:43 AM

Title: Fetch image metadata via C++ interface
Post by: nagibator on July 12, 2018, 04:38:43 AM
Hi guys. I'm trying to get metadata from image. I've created simple C++ project in Xcode, added Exif sources and added simple example.

int main(int argc, char **argv)
{
    const char *path = "/Users/bbb/Desktop/raw_photos/thumb1.jpg";

    // create our ExifTool object
    ExifTool *et = new ExifTool();
    // read metadata from the image
    TagInfo *info = et->ImageInfo(path);
    if (info) {
        // print returned information
        for (TagInfo *i=info; i; i=i->next) {
            cout << i->name << " = " << i->value << endl;
        }
        // we are responsible for deleting the information when done
        delete info;
    } else if (et->LastComplete() <= 0) {
        cerr << "Error executing exiftool!" << endl;
    }
    // print exiftool stderr messages
    char *err = et->GetError();
    if (err) cout << err;
    delete et;      // delete our ExifTool object
    return 0;
}


Image url is correct, but ImageInfo returns NULL. I think the problem is that isRunning() is always returns 0. Probably, I've missed something, but can't figure out what.
Title: Re: Fetch image metadata via C++ interface
Post by: StarGeek on July 12, 2018, 11:37:15 AM
I have no clue about how the c++ interface works, but if it keeps showing that exiftool isn't running, the first thing I would check would be to make sure that exiftool is in a path accessible by the system.

Edit:   I see you figured out the problem.  Original Stackoverflow question (https://stackoverflow.com/questions/51288144/exiftool-get-imageinfo).
Title: Re: Fetch image metadata via C++ interface
Post by: nagibator on July 16, 2018, 03:40:08 AM
Yes, thanks, I've managed to fix it :)