GPS Longitude Tag: How to correct Negative Longitude Values

Started by Archive, May 12, 2010, 08:54:43 AM

Previous topic - Next topic

Archive

[Originally posted by riba on 2009-12-19 18:35:02-08]

Hi there !

Due to a Samsung Firmware bug I need to correct a negative GPSLongitude value into a positive one, e.g. :
 

exiftool -GPSLongitude photo.jpg

GPS Longitude                   : -61 deg 22' 4.08" W

It should be corrected to +61 deg 22' 4.08" W. How can I do this with command line options?
I've tried the "-c" option for formatting the coordinates (as shown in the exiftool Application Documentation) but it didn't help, then I also tried a unsigned option, like "%u", but this does not help either:

 

exiftool -c "%u" -GPSLongitude photo.jpg

GPS Longitude                   : 4294967235 W

Any help is highly appreciated!

Cheers

Riba

PS: The example image can be found here.  

If somebody wants to know why I have to do exactly the above mentioned transformation may read this post.

Archive

[Originally posted by exiftool on 2009-12-19 19:47:50-08]

This can't be done straight from the command line because
the storage format for this information is incorrect and must
be overridden to be read properly.  Samsung is writing as
signed rational, but the format stored in the image is
unsigned.  The following config file will force the GPS
Longitude to be read as signed, and take the absolute value
of the coordinates to fix the sign problem:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::GPS::Main' => {
        0x0004 => {
            Name => 'GPSLongitude',
            Format => 'rational64s',
            Count => 3,
            RawConv => q{
                my @vals = split ' ', $val;
                $_ = abs($_) foreach @vals;
                return "@vals";
            },
            ValueConv    => 'Image::ExifTool::GPS::ToDegrees($val)',
            ValueConvInv => 'Image::ExifTool::GPS::ToDMS($self, $val)',
            PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
            PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val)',
        },
    },
);
1; #end

See the config
file documentation
for details on how to install the config file.

- Phil

Archive

[Originally posted by exiftool on 2009-12-19 19:54:14-08]

I should have mentioned that with the above config file you can
fix the longitude in the image with the following command:

Code:
exiftool -tagsfromfile @ -gpslongitude FILE

where FILE is the name of one or more files or directories
containing images to fix.

Also, I forgot to set the "Writable" format so the tag will get written
properly as unsigned:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::GPS::Main' => {
        0x0004 => {
            Name => 'GPSLongitude',
            Format => 'rational64s',
            Writable => 'rational64u',
            Count => 3,
            RawConv => q{
                my @vals = split ' ', $val;
                $_ = abs($_) foreach @vals;
                return "@vals";
            },
            ValueConv    => 'Image::ExifTool::GPS::ToDegrees($val)',
            ValueConvInv => 'Image::ExifTool::GPS::ToDMS($self, $val)',
            PrintConv    => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
            PrintConvInv => 'Image::ExifTool::GPS::ToDegrees($val)',
        },
    },
);
1; #end

- Phil

Archive

[Originally posted by riba on 2009-12-20 13:41:35-08]

Hi Phil!
 

THANKS A LOT!! I just tried it out -- and it works nicely!

Now Batiboo Bay is really where it should be :-)

Cheers
Pascal

PS: Dominica is worth traveling to...