How can i do these CLI commands in Perl use Image::ExifTool API?

Started by refrain, March 05, 2015, 04:00:24 AM

Previous topic - Next topic

refrain

Hello,

How can i do these  CLI command below in Perl use Image::ExifTool API?

First, i want to add new tags to all my images using Exiftool_config.
exiftool -config ExifTool_config /home/intannf/try

These are EXiftool_config that i wrote:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::GPS::Main' => {
0xd000 => {
Name => 'GPSLatitude',
Writable => 'rational64s',
},
0xd001 => {
Name => 'GPSLongitude',
Writable => 'rational64s',
},
},
'Image::ExifTool::MIE::Meta' => {
AirSpeedSensor => {
Writable => 'rational64u',
Unit => [ 'm/s' ],
},
HeightSensor => {
Writable => 'rational64u',
Unit => [ 'm' ],
},
},
);
1;


and this is another CLI command that i used to import csv file to an image.
exiftool -csv=test.csv /home/intannf/IMG_3511.JPG
actually i want to import those file into all images in a directory, but i have a problem how to import csv file to those images while it needs source file in csv file.

I hope somebody will help me.

Thank you,
Intan

Phil Harvey

I answered your other post here.

Once you sort out these problems, you can proceed further.

But you would have to read the CSV file yourself if you want to use the Image::ExifTool API.  So if the C++ interface is an option, it should be easier for you.

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

refrain

Hi, Phil.

Thanks for your suggestion. Am still confused about the program that i want to use. Which one is better, perl or c++?
Because Image::ExifTool API has more exiftool object methods than c++ interface's. and also, i still know nothing about adding new tags in c++ script.

Intan

Phil Harvey

The C++ interface is an interface to the exiftool command-line application, and gives you all the features of the exiftool application.

The API gives you direct access to the Image::ExifTool API functions.  These give you much more flexibility to do complex tasks, but lack some features provided by the application.

Which you should use depends on your particular requirements.

Defining custom tags may be done the same way via the config file using both techniques.  Adding new tags to images using the C++ interface is very similar to the way it is done using the command line application.

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

refrain

Honestly, i have some requirements to do by using programming script, but i dont know wether it be perl or c++, yet.

1. First, i have to add new tags to all images in the directory automatically.
2. Then, i have to integrate metadata of those images with CSV file which is the data of ADAHRS (Air Data, Attitude and Heading Reference Systems) sensor. Actually, the content of the CSV file are:
[GPS longitude] [GPS latitude] [Air Speed] [Height] [Timestamp]
There's no source file in the CSV file, because the data will be taken by ADAHRS sensor.
In my mind, I think to integrate both of them, i have to synchronize the timestamp between images and CSV file. So, if the timestamps of them are similar, every line in the CSV file will import automatically to an image in the directory.

Do you get my explanations? I am sorry if my explanations are so complicated.  :(
I really need your suggestions.  :'(

Thank you,
Intan

Phil Harvey

Hi Intan,

This is essentially the same function as the ExifTool geotag feature.  The only differences are the input file format and that it doesn't handle airspeed and height information.  Is this a standard file format that other people may use?  If so, maybe it makes sense for me to add this to the geotag feature.  In this case, I would need a sample ADAHRS file.

- Phil

Edit:  The air speed could be written to GPSSpeed, and height to GPSAltitude.  I realize these don't quite fit, but if you don't have speed/altitude data then this is a convenient place to put them, and would avoid the necessity of creating user-defined tags and allow standard software to read this information.
...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 ($).

refrain

Something that i know about ADAHRS is that it provides attitude information for aircraft, including heading, roll pitch and yaw, and then airspeed, altitude, outside air temperature, GPS longitude , GPS latitude, and IMU. The standar file format depends on their particular requirements.

Yeah, i think i can write height to GPSAltitude, because they are similar. But i am not sure that i can write airspeed to GPSSpeed, because they are totally different.  What should i do? Can i add user-defined tags in GPS or others?

So, is it better for me to use the Exiftool geotag feature to write CSV file of ADAHRS to metadata images? But i am still confused how to use Geotime and GPStimestamp. How do i know about the GPStimestamp of every images in the directory?

When i tried to run command line below, i got some warnings.
exiftool -geotag=track.log /home/intannf/try
Warning: Error opening GPS file 'track.log' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - /home/intannf/try/IMG_5732.JPG
Warning: No writable tags set from /home/intannf/try/IMG_5732.JPG
Warning: GPS track is empty in File:Geotime (ValueConvInv) - /home/intannf/try/IMG_5731.JPG
Warning: No writable tags set from /home/intannf/try/IMG_5731.JPG
    1 directories scanned
    0 image files updated
    2 image files unchanged

What should i do to solve them?

Intan

Phil Harvey

Hi Intan,

Quote from: refrain on March 05, 2015, 12:27:57 PM
Something that i know about ADAHRS is that it provides attitude information for aircraft, including heading, roll pitch and yaw, and then airspeed, altitude, outside air temperature, GPS longitude , GPS latitude, and IMU. The standar file format depends on their particular requirements.

It may not make sense for me to add support for ADAHRS to the ExifTool geotag feature, because this feature doesn't really provide a mechanism for a flexible format file like this.

QuoteYeah, i think i can write height to GPSAltitude, because they are similar. But i am not sure that i can write airspeed to GPSSpeed, because they are totally different.  What should i do? Can i add user-defined tags in GPS or others?

You could add user-defined tags like the example user-defined GPSPitch and GPSRoll tags.

QuoteSo, is it better for me to use the Exiftool geotag feature to write CSV file of ADAHRS to metadata images?

This will only work if I add support for the ADAHRS file format.  But the advantage is that it would handle the time correlations and position interpolations.

QuoteBut i am still confused how to use Geotime and GPStimestamp. How do i know about the GPStimestamp of every images in the directory?

For this to work, the images need some sort of timestamp (even just the system file modification data/time will do) that may be used to correlate the image time with the telemetry data.

QuoteWhen i tried to run command line below, i got some warnings.

This is expected since ExifTool doesn't support ADAHRS format yet.

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

refrain

There is one thing that worrying me, each image certainly have DateTimeOriginal which represents the date and time of the picture was taken by. Does DateTimeOriginal can be used to correlate the image time with the telemetry data?

Intan

Phil Harvey

Yes.  Read the geotagging documentation I referenced for more details.

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

refrain


refrain

Quote from: Phil Harvey on March 05, 2015, 12:41:07 PM
For this to work, the images need some sort of timestamp (even just the system file modification data/time will do) that may be used to correlate the image time with the telemetry data
- Phil

Hi, Phil.
I want to ask you something.
What if the camera that i used to capture image dont have GPS information? Can i use the DateTimeOriginal of the image to synchronize with timestamp of GPS in ADAHRS (note that ADAHRS sensor is not directly connected to camera)? But, how does it work?

Note: GPS that i used in ADAHRS is GPS SKM53 which have feature like NMEA protocol

When i tried to run command line below, there is no output. Does it mean that this image has no gps data?
exiftool -gps:all -a IMG_7913.JPG

I also tried to run command line below and it gave me warning. Why?
exiftool -geosync=IMG_3511.JPG
No file specified


Intan

Hayo Baan

Quote from: refrain on March 06, 2015, 12:32:54 AM
When i tried to run command line below, there is no output. Does it mean that this image has no gps data?
exiftool -gps:all -a IMG_7913.JPG
Yes! If it has GPS data it will show you all the gps information (from the Exif:GPS group).

Quote from: refrain on March 06, 2015, 12:32:54 AM
I also tried to run command line below and it gave me warning. Why?
exiftool -geosync=IMG_3511.JPG
No file specified


The error says it all, all you have done is specify a file as the geosync, but have provided no file to have exiftool operate on (note: you probably have to specify two files for the -geosync option to work as you want, see the geotag documentation for details).

This should answer your last questions. Regarding your first question, I have no real experience with geotagging, but I guess your answer also lies in the geotag documentation.

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

refrain

Hi, all

Sorry for bringing up this topic. I want to ask you some question. Because it's urgent.
Well, I am newbie to perl and shell script, and i make a script to integrate sensor's data to metadata photo using shell script. The script i made is finished, but i have problems, that i have to write the CLI command in shell script, too. In my shell script, i used this following process:
exiftool -config ExifTool_config dir
exiftool -csv -r -SourceFile -DateTimeOriginal dir > test.csv
exiftool -csv=test.csv dir 2>&1 | grep "scanned\|updated"

What i want to ask about is: how can i do those cli commands in perl/shell script? Unfortunately, i have to write those script in perl/shell script, but i still dont understand yet how to do it. I am still trying to learn the example, but i am still blank.
What if i use those CLI command in perl use Image::ExifTool and making it one in shell script? Does it work?

Thanks in advance.

Regards,
Intan

Hayo Baan

I'm not sure I completely understand what you're after, but to run a program from within a perl script you would use the system command or the backtick (`) operator. Interfacing directly with Image::ExifTool is also possible, but will require more coding to achieve what those three ExifTool commands do.
Hayo Baan – Photography
Web: www.hayobaan.nl