Having problem with executing C++ Exiftool using Geany on Ubuntu

Started by refrain, November 22, 2014, 08:47:54 AM

Previous topic - Next topic

refrain

Hi, I'm newbie and still learn how to use exiftool to read, write/rewrite photo metadata. I try to execute examples of C++ ExifTool by Phil Harvey using Geany on Ubuntu.
For example, i tried to execute example1 like the script below:
#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;
    }
    // create our ExifTool object
    ExifTool *et = new ExifTool();
    // read metadata from the image
    TagInfo *info = et->ImageInfo(argv[1],NULL,5);
    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) cerr << err;
    delete et;      // delete our ExifTool object
    return 0;
}

// end


Then the result when i executed using Geany is just like this:
Example1: Read metadata from an image.
Please specify input file name


I think that there's no script to input the file there and I'm so confused how to make script to input file in those example. Is there any possibility to execute C++ exiftool using geany? Or it should be using terminal only? Please help me to know how to solve it.
Thank you.

Regards,
Intan

Hayo Baan

Looking at your C++ code, you simply haven't provided a filename on the command-line of the C++ program you are trying to run (from within Geany).

The test argc<2 fails which means the command-line does not have a first argument (the file to use in exiftool in your later code).

Cheers,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

refrain

Quote from: Hayo Baan on November 22, 2014, 10:18:45 AM
Looking at your C++ code, you simply haven't provided a filename on the command-line of the C++ program you are trying to run (from within Geany).

The test argc<2 fails which means the command-line does not have a first argument (the file to use in exiftool in your later code).

Cheers,
Hayo

Well, i think so. But i'm still confused about the script that used to provided a filename --like the C++ script to input the filename on command line. Would you help me?

Thanks,
Intan

Hayo Baan

I would sure like to help, but the problem is that I don't have a clue about Geany so I wouldn't know how to tell it to pass a filename to your program...
Sorry. Perhaps if you run the compiled program on the command-line directly and provide it a filename?

Cheers,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

With C++ ExifTool example 1, you need to specify the file name on the command line when you run the example.  (This is argv[1] that is passed to the ImageInfo() function.)

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

refrain

Quote from: Phil Harvey on November 24, 2014, 06:51:53 AM
With C++ ExifTool example 1, you need to specify the file name on the command line when you run the example.  (This is argv[1] that is passed to the ImageInfo() function.)

- Phil

Well, i tried to run the example on the command line and had specified the file name then it works. But, what i want to know is that can i specify the file name on the script? would you me to give me the example of specifying the file name on the c++ script? I'm still confused and dont know how to fix it.

Regards,
Intan

Phil Harvey

All you do is change "argv[1]" to whatever variable name you are using for the file name.

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