Best way to include data/functions from other parts of the source code revisited

Started by StarGeek, July 04, 2024, 09:29:56 PM

Previous topic - Next topic

StarGeek

Back in this post, I asked about including  %latConv and %longConv from the XMP.pm file. I tried the suggested
include Image::ExifTool::XMP;
But I may have been putting it in the wrong place

include Image::ExifTool::XMP;

# The %Image::ExifTool::UserDefined hash defines new tags to be added
# to existing tables.
%Image::ExifTool::UserDefined = (
# new XMP namespaces (eg. xxx) must be added to the Main XMP table:
'Image::ExifTool::XMP::Main' => {
# namespace definition for examples 8 to 11
video => { # <-- must be the same as the NAMESPACE prefix
SubDirectory => {
TagTable => 'Image::ExifTool::UserDefined::video',
# (see the definition of this table below)
},
},
},
);

%Image::ExifTool::UserDefined::video = (
GROUPS => { 0 => 'XMP', 1 => 'XMP-video', 2 => 'Image' },
NAMESPACE => { 'video' => 'http://www.video/' },
#PRIORITY => 0, # copy/pasted from XMP-exif, which says "not as reliable as actual EXIF tags"
WRITABLE => 'string', # (default to string-type tags)
GPSVersionID    => { Groups => { 2 => 'Location' } },
GPSLatitude     => { Groups => { 2 => 'Location' }, %Image::ExifTool::XMP::latConv },
GPSLongitude    => { Groups => { 2 => 'Location' }, %Image::ExifTool::XMP::longConv },
GPSMapDatum     => { Groups => { 2 => 'Location' } },
);
#------------------------------------------------------------------------------
1;  #end

But this returns an error
C:\>exiftool -config testGps.config -P -overwrite_original -XMP-video:GPSLatitude=40.6892 -XMP-video:GPSLongitude=-74.0445 y:\!temp\Test4.jpg
Can't locate object method "include" via package "Image::ExifTool::XMP" at C:\Programs\UnixUtils\ExifTool/testGps.config line 18.
Warning: Sorry, XMP-video:GPSLatitude doesn't exist or isn't writable
Warning: Sorry, XMP-video:GPSLongitude doesn't exist or isn't writable
Nothing to do.

If I change include to use, it seems to work
C:\>exiftool -config testGps.config -P -overwrite_original -XMP-video:GPSLatitude=40.6892 -XMP-video:GPSLongitude=-74.0445 y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -config testGps.config -G1 -a -s -gps* y:\!temp\Test4.jpg
[XMP-video]     GPSLatitude                     : 40 deg 41' 21.12" N
[XMP-video]     GPSLongitude                    : 74 deg 2' 40.20" W
[Composite]     GPSPosition                     : 40 deg 41' 21.12" N, 74 deg 2' 40.20" W

Would use be correct or is there a different way I should use.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

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