Fetch image metadata via C++ interface

Started by nagibator, July 12, 2018, 04:38:43 AM

Previous topic - Next topic

nagibator

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.

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

nagibator