[C++] Docker, GetInfo Fail ? Exiftool stops running

Started by Karlos, May 24, 2019, 05:12:21 AM

Previous topic - Next topic

Karlos

Hi Phil and co.

I still have a little issue using simple c++ functions...
I am using a docker with fedora 27, my laptop is on fedora 29. Is there a problem using exiftool with a docker ?
I am giving the image path in command parameter.

Result :

1 - ExifTool process is running
Extractinfo -- cmdNum : 1
2 - ExifTool process is running
GetInfo(1,10) .....
3 - NOT running
Error executing exiftool! LastComplete : -1
Get Error :


Here is my code, it is very simple. I just want to use the GetInfo function but Exiftool seems to crash whenever I use it.
Is my timeout = 10 ok ?
Why does GetError doesn't say nothing ?

#include <iostream>
#include "ExifTool.h"

using namespace std;

int main(int argc, char **argv)
{
    if (argc < 2) {
        cout << "Example1: Read metadata from an image." << endl;
        cout << "Please specify input file name" << endl;
        return 1;
    }

    ExifTool *et = new ExifTool();
    if (et->IsRunning()) {
        printf("1 - ExifTool process is running\n");
    }else printf("1 - NOT running\n");

    int cmdNum = et->ExtractInfo(argv[1]);
    int timeout = 10;

    cout << "Extractinfo -- cmdNum : " << cmdNum << endl;

    if (et->IsRunning()) {
        printf("2 - ExifTool process is running\n");
    }else printf("2 - NOT running\n");

    TagInfo *info = et->GetInfo(cmdNum, timeout);

    cout << "GetInfo(" << cmdNum << "," << timeout << ") ....." << endl;

    if (et->IsRunning()) {
        printf("3 - ExifTool process is running\n");
    }else printf("3 - NOT running\n");

    if (info) {
        // print returned information
        for (TagInfo *i=info; i; i=i->next) {
            cout << i->name << " = " << i->value << endl;
            cout << "  group[0] = " << (i->group[0] ? i->group[0] : "<null>") << endl;// family 0 group name
            cout << "  group[1] = " << (i->group[1] ? i->group[1] : "<null>") << endl;// family 1 group name
            cout << "  group[2] = " << (i->group[2] ? i->group[2] : "<null>") << endl;// family 2 group name
            cout << "  name = " << (i->name ? i->name : "<null>") << endl;      // tag name
            cout << "  desc = " << (i->desc ? i->desc : "<null>") << endl;      // tag description
            cout << "  id = " << (i->id ? i->id : "<null>" ) << endl;           // tag ID
            cout << "  value = " << (i->value ? i->value : "<null>") << endl;   // converted value
            cout << "  valueLen = " << i->valueLen << endl;                     // length of value in bytes (not including null terminator)
            cout << "  num = " << (i->num ? i->num :"<null>") << endl;          // "numerical" value
            cout << "  numLen = " << i->numLen << endl;                         // length of numerical value
            cout << "  copyNum = " << i->copyNum << endl;                       // copy number for this tag name
        }
        // we are responsible for deleting the information when done
        delete info;
    } else if (et->LastComplete() <= 0) {
        cerr << "Error executing exiftool! LastComplete : "<< et->LastComplete() << endl;
    }
    // print exiftool stderr messages
    char *err = et->GetError();
    cout << "Get Error : " << err << endl;
    delete et;      // delete our ExifTool object

    delete info;
    info = NULL;

    return 0;
}


What do you think ?

Phil Harvey

I don't see anything obviously wrong.

If you can confirm that your code runs outside Docker, then I think you should be seeking help in a Docker forum.  I have never heard of Docker before.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).