Main Menu

Recent posts

#31
The Image::ExifTool API / Re: Problem with tag qualifier...
Last post by Phil Harvey - July 06, 2025, 11:47:23 AM
Surprisingly reasonable code attempt.

- Phil
#32
The Image::ExifTool API / Re: Problem with tag qualifier...
Last post by Tom Cunningham - July 06, 2025, 11:17:06 AM
BTW, I am using code generated by Google API. I can't recall my original prompt, but it was something like:

using the exiftool api, write perl code to adjust all time fields in the metadata to the photo's location coordinates relative to central standard time

and this is what it came up with:

#!/usr/bin/perl

use strict;
use warnings;
use Image::ExifTool qw(:Public);
use DateTime::TimeZone; # You'll need to install this Perl module

# Define the directory containing your image files
my $image_directory = "/path/to/your/images";

# Create a new ExifTool object
my $exifTool = new Image::ExifTool;

# Get a list of image files in the directory (you can adjust this to suit your needs)
my @image_files = <$image_directory/*.jpg>;

foreach my $file (@image_files) {
    # Extract metadata including GPS coordinates and timestamps
    my $info = $exifTool->ImageInfo($file);

    # Check if GPS coordinates are available
    if ($info->{GPSLatitude} && $info->{GPSLongitude}) {
        my $latitude = $info->{GPSLatitude};
        my $longitude = $info->{GPSLongitude};

        # Attempt to get the timezone from coordinates using DateTime::TimeZone
        # You'll need a way to map coordinates to a timezone name (e.g., using a library or service)
        # This example uses a placeholder, you'll need to implement the actual logic
        my $timezone_name = get_timezone_from_coordinates($latitude, $longitude);

        if ($timezone_name) {
            # Create DateTime::TimeZone object
            my $location_timezone = DateTime::TimeZone->new(name => $timezone_name);

            # Iterate through time-related tags that might have CST timestamps
            my @time_tags = qw(DateTimeOriginal CreateDate ModifyDate); # Adjust the list of tags as needed

            foreach my $tag (@time_tags) {
                if ($info->{$tag}) {
                    # Get the original timestamp string (assuming it's in CST, you might need to adjust this)
                    my $timestamp_str = $info->{$tag};

                    # Assuming timestamp format "YYYY:MM:DD HH:MM:SS" (adjust if needed)
                    if ($timestamp_str =~ /(\d{4}):(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
                        my ($year, $month, $day, $hour, $minute, $second) = ($1, $2, $3, $4, $5, $6);

                        # Create a DateTime object in the original timezone (CST, adjust if needed)
                        my $original_dt = DateTime->new(
                            year      => $year,
                            month     => $month,
                            day       => $day,
                            hour      => $hour,
                            minute    => $minute,
                            second    => $second,
                            time_zone => 'America/Chicago' # Assuming CST is America/Chicago
                        );

                        # Convert the DateTime object to the location's timezone
                        $original_dt->set_time_zone($location_timezone);

                        # Format the adjusted timestamp for ExifTool (YYYY:MM:DD HH:MM:SS[+-]HH:MM)
                        my $adjusted_timestamp = $original_dt->ymd(':') . ' ' . $original_dt->hms(':') . $original_dt->strftime('%z');

                        # Update the timestamp tag with the adjusted value and timezone
                        $exifTool->SetNewValue($tag, $adjusted_timestamp);
                    }
                }
            }

            # Write the changes to the file
            $exifTool->WriteInfo($file);
            print "Adjusted timestamps for $file to $timezone_name\n";
        } else {
            print "Could not determine timezone for $file from GPS coordinates\n";
        }
    } else {
        print "No GPS coordinates found for $file\n";
    }
}

# Subroutine to get timezone name from latitude and longitude (placeholder)
# You'll need to implement this logic using a library or external service
sub get_timezone_from_coordinates {
    my ($latitude, $longitude) = @_;
    # Example placeholder: replace with your timezone lookup logic
    # You might use a library like Geo::Timezone or an API call to a geolocation service
    return "Europe/Berlin"; # Replace with actual timezone name based on coordinates
}

As you can see, the culprit is:

    my $timestamp_str = $info->{$tag};

which, as you point out, doesn't support fully qualified tags. Anyway, I was impressed that it could generate ExifTool API code.  8)

#33
Bug Reports / Feature Requests / Re: Geotagging with ExifTool
Last post by StarGeek - July 06, 2025, 10:31:40 AM
Quote from: antb on July 06, 2025, 05:28:04 AMwith version exiftool-10.07

It should also be pointed out that version 10.07 is nearly a decade old, having been released Dec. 22, 2015. There have been over 300 updates since then.
#34
The Image::ExifTool API / Re: Problem with tag qualifier...
Last post by Tom Cunningham - July 06, 2025, 10:26:22 AM
Oh OK, thanks, Phil.
#35
The "exiftool" Application / Re: Add thumbnail and preview ...
Last post by StarGeek - July 06, 2025, 10:22:22 AM
Fixed the link. "Kind" was mistakenly appended to the link. (Edit: Bah, removed "Kind" from the text part, but not from the actual link, properly fixed now)

C:\>exiftool -G1 -a -s --system:all -file:all Y:\!temp\x\y\20250302_144047.170_CR5m2-8486.HIF
[File]          FileType                        : HEIF
[File]          FileTypeExtension               : heif
[File]          MIMEType                        : image/heif
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 8192
[File]          ImageHeight                     : 5464
#36
The "exiftool" Application / Re: Is there a way to show tag...
Last post by Phil Harvey - July 06, 2025, 07:29:41 AM
I would suggest using the JSON output format:

exiftool -j -l -lang de FILE

This gives both the tag name and the description in German.  But you probably want to add some -G option to this command so you know what group to use for writing.

- Phil
#37
Bug Reports / Feature Requests / Re: Geotagging with ExifTool
Last post by Phil Harvey - July 06, 2025, 07:24:12 AM
Ah, I see the problem.  There is a GNRMC sentence half way through the NMEA file (at the location of the truncated GNGGA line).  From this point on ExifTool takes the date from the RMC, but the date isn't known for all earlier fixes.  If remove the RMC line then ExifTool will assume the current day, and it would be OK.  But as it stands, the fixes before the RMC have an unknown date, so they won't be used.

In general, it is best to geotag from the RMC sentence if possible since it contains both date and time.  Geotagging from time-only NMEA is problematic.

- Phil
#38
The "exiftool" Application / Is there a way to show tag and...
Last post by norbertj - July 06, 2025, 07:17:05 AM
Let me first describe the scenario, which leads to my question:
I want to see the meta data in German, so I start ExifTool with -lang de. I see an entry, which I want to change, but I do not see the tag, which is necessary for writing. When using English, in many cases the tag can be guessed from the description, but that does not work with German.
I found a workaround: using -G:1:5:7 I get something like "Nikon:JPEG-APP1-IFD0-ExifIFD-MakerNotes-VRInfo:ID-0" which probably is unique, but this is nothing which can be used for writing. So running ExifTool again with -G:1:5:7 -s and then searching for "Nikon:JPEG-APP1-IFD0-ExifIFD-MakerNotes-VRInfo:ID-0" will give me the tag for writing.

I am including ExifTool in an Windows application using ExifToolWrapper. If there is no way now to get tag and description together using the ExifTool Application: is there a way to achieve this using the Perl library directly?
#39
Bug Reports / Feature Requests / Re: Geotagging with ExifTool
Last post by Phil Harvey - July 06, 2025, 07:02:51 AM
Also, the NMEA file you uploaded is corrupted around the time of the photo (a GNGGA line is truncated), which may be causing some problems but I haven't thought through the ramifications in detail.

- Phil
#40
The Image::ExifTool API / Re: Problem with tag qualifier...
Last post by Phil Harvey - July 06, 2025, 06:51:38 AM
The "info" hash uses tag keys, not fully qualified tag names.  You have to do something like this if you want to find the XMP:ModifyDate:

my $et = Image::ExifTool->new;
$et->ImageInfo('pic.jpg');
my $date = $et->GetValue('XMP:ModifyDate');

- Phil