ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: Martin B. on October 03, 2023, 03:42:37 PM

Title: Can options be set after the call to ImageInfo?
Post by: Martin B. on October 03, 2023, 03:42:37 PM
Which options can be set after the call to ImageInfo() but before a call to GetValue()?

https://metacpan.org/pod/Image::ExifTool#GetInfo (https://metacpan.org/pod/Image::ExifTool#GetInfo) says the following options are effective, but I'm not sure when I need to set the options in order for them to be effective:
QuoteThe following options are effective in the call to "GetInfo":

Charset, CoordFormat, DateFormat, Duplicates, Escape, Exclude, Filter, Group#, GlobalTimeShift, Lang, ListItem, ListJoin, PrintConv, QuickTimeUTC (conversion to local time), Sort (if a tag list reference is given) and StrictDate.

For instance, will the following generally return two different values of CreateDate?
Or do I need to set the option and call ImageInfo() again? This takes more computing time...
$exifTool = new Image::ExifTool;
$exifTool->ImageInfo('file.mov');

$exifTool->Options(QuickTimeUTC => 0);
my $create_date = $exifTool->GetValue('CreateDate');

$exifTool->Options(QuickTimeUTC => 1);
my $create_dateUTC = $exifTool->GetValue('CreateDate');
In my tests, I'm getting inconsistent values across files coming from different cameras, but https://metacpan.org/pod/Image::ExifTool#Options (https://metacpan.org/pod/Image::ExifTool#Options) says the CR3 files always use UTC times, so it could be that, but I thought I'd ask here.

My example is specific to QuickTimeUTC, but my question is really about this bit of documentation for all options.

Thanks!
Title: Re: Can options be set after the call to ImageInfo?
Post by: StarGeek on October 03, 2023, 07:37:14 PM
Quote from: gamin on October 03, 2023, 03:42:37 PMIn my tests, I'm getting inconsistent values across files coming from different cameras, but https://metacpan.org/pod/Image::ExifTool#Options (https://metacpan.org/pod/Image::ExifTool#Options) says the CR3 files always use UTC times, so it could be that, but I thought I'd ask here.

I believe that in CR3 files the integer based Quicktime date/time tags are UTC and that the QuicktimeUTC option is automatically on.  You will get the same results on a CR3 file regardless of if QuicktimeUTC is set to 0 or 1.
Title: Re: Can options be set after the call to ImageInfo?
Post by: Martin B. on October 04, 2023, 06:25:51 AM
Thanks, I kind of expected that for CR3 files, but I don't know for MOV files (the example I provided), and certainly not for non-Canon files.

In any case, my question was more about when I can set the options: do I need to call Options() before calling ImageInfo() or can I do it before GetValue()? My question is not specific to the QuickTimeUTC option. If I'm not clear, perhaps the sample code I provided will better illustrate what I mean.

I now realize I had quoted, in my original post, the documentation for GetInfo() while I meant GetValue() (the difference isn't significant to my question):
https://metacpan.org/pod/Image::ExifTool#GetValue (https://metacpan.org/pod/Image::ExifTool#GetValue) says:
QuoteThe following options are in effect when "GetValue" is called:

Charset, CoordFormat, DateFormat, Escape, Filter, GlobalTimeShift, Lang, ListItem, ListJoin, PrintConv, QuickTimeUTC (conversion to local time), StrictDate and TimeZone.

Thanks!
Title: Re: Can options be set after the call to ImageInfo?
Post by: Phil Harvey on October 06, 2023, 08:48:19 AM
First, you don't need to be calling ImageInfo if you aren't using the return tags.  Just call ExtractInfo then GetInfo. (Which is what ImageInfo does internally.)

Looking at the documentation for ExtractInfo, it says "QuickTimeUTC (enforced 1904 time zero)".  So the 1904 epoch is enforced only if QuickTimeUTC is set before this call.  GetValue says "QuickTimeUTC (conversion to local time)", so the conversion to local time is done only if QuickTimeUTC is set for this call.

- Phil
Title: Re: Can options be set after the call to ImageInfo?
Post by: Martin B. on October 06, 2023, 09:39:34 AM
Thanks Phil for the clarification and pointers!
I wasn't looking at the right place for the answers to my questions.