C++ Newbie Simple functions

Started by Karlos, May 20, 2019, 12:40:15 PM

Previous topic - Next topic

Karlos

Hi guys ! I am new on exiftool but I need to build an important project with it so I will be pretty active.
I want to automatize some metadata magic on some jpg pictures I acquire with a camera.
Everything is done in the same cpp program (is it a problem ?)

I am having trouble with the very basics because I can't get access to any metadata.

Either if I use the ImageInfo method, ExtractInfo, GetInfo or GetOUtput, I recieve the Error executing exiftool !!!
Some outputs from ExtractInfo change like 2 with Image Info or 1 with GetInfo but I don't understand how to solve the error anyway...

Can you help ?

Here is my code :

ExifTool *et = new ExifTool();
    if (et->IsRunning()) {
      printf("ExifTool process is running\nFile is : ");
      printf(filename.c_str());
      // read metadata
      TagInfo *info1 = et->ImageInfo(filename.c_str(),NULL,10);
      int cmdNum = et->ExtractInfo(filename.c_str(),"-b");
      cout << "\ncmdNum from ExtractInfo : " << cmdNum << endl;;
      // TagInfo *info2 = et->GetInfo(cmdNum, 1);
      cout << "getOutput : " << et->GetOutput() << endl;
      if (info1) {
          // print returned information
          for (TagInfo *i=info1; i; i=i->next) {
              cout << i->name << " = " << i->value << endl;
              ...........
              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) {
          cout << "\nLastComplete : " << et->LastComplete() << endl;
          cerr << "Error executing exiftool!" << endl;
          char *err = et->GetError();
          if (err) cerr << err;
      }
    }


ExifTool process is running
File is : /home/rosuser/rapidash/Testbench/src/tools/lab/3D/files/001558369843.466532491.jpg
cmdNum from ExtractInfo : 2
getOutput : Error executing exiftool!

Phil Harvey

Before I take a look at your code to try to figure out what is wrong, did you try compiling any of the example programs in the cpp_exiftool tarball to see if they work?

- 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 ($).

Karlos

Thanks for your reply and yes I did, they work !

Karl

Phil Harvey

OK then.  It may be easier for you to start from an example and build up from there.

A quick look at your code shows that you are calling ImageInfo() which extracts the information then returns the tag values.  But then you are calling ExtractInfo() on the same file, which should be unnecessary.  However, this shouldn't cause the error you are seeing, but I don't have time right now to look at this in more detail.

- 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 ($).

Karlos

I think the problem comes from the fact that I am using a docker.

I have run the exact same  codes inside or outside the docker.

It doesn't work when it is outside.

I still don't know why but it is not an exiftool issue :p