Skip to main content

TrFile_GetMetaData (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetMetaData
Troi File Plug-in for FileMaker Pro

TrFile_GetMetaData

Gets metadata out of an image, movie or pdf. Metadata can be inserted by for example Photoshop and can contain a description of the image, copyright information, camera information, etc.

SyntaxFunction badge

TrFile_GetMetaData ( switches ; source )

Parameters

switches these determine the metadata that is returned
source the path to the file, or container data

Switches

Switches can be one or more of the following:

-GetIPTC get the IPTC metadata (Photoshop’s File Info)
-GetXMP get XMP metadata (Adobe’s Extensible Metadata Platform )
-GetExif get the Exif metadata (a standard for digital cameras)
-GetRawExif get the Exif metadata (a standard for digital cameras), in a more original form
-GetGPS get the GPS (Global Positioning System) metadata, with the image coordinates
-GetJPEGComment get the JPEG comment metadata of a JPEG file
-GetImageURL get the URL metadata (Photoshop’s File Info extension)
-GetImageDescription get a description like width, height and depth, resolution, codec name etc.
-GetPhotoshopIPTCDigest get the (Photoshop) IPTC Digest (a 32-bit MD5 hash) stored the image

To specify the encoding you can use:

-SourceMacCharSet the IPTC data has Mac encoded characters
-SourceWinCharSet the IPTC data has Windows encoded characters
-SourceUTF8CharSet the IPTC data will be read as UTF-8 encoded
-DontUseAutoUTF8Detection disable the automatic detection of UTF-8 encoding

For movies these switches can be used:

-IsValidMovie returns 1 (true) if this is a valid movie or 0 (false) otherwise
-GetMovieDescription get a description like width, height and depth, timecode, frames per second, codec name etc in a list.

You can add this switch in combination with the switch “-GetMovieDescription”:

-AddFrameCount the frame count of the movie is added to the result. Note that it might take a while to calculate the frame count.

For movies you can also get these single metadata values:

-GetMovieDuration get the duration in seconds of a movie
-GetTimecodeBegin get the begin Timecode of a movie
-GetTimecodeEnd get the end Timecode of a movie
-GetTimecodeCurrent get the current Timecode of a movie
-GetMovieMetadata get all embedded metadata, for example Artist or Description
-GetMovieCreationDate gets the creation date (incl. time + timezone) of the movie
-GetMovieWidth get the width of the movie
-GetMovieHeight get the height of the movie
-GetMovieRotation get the rotation in degrees of the movie
-GetMovieFrameCount get the total number of frames in the movie
-GetMovieSoftware get the name if the application that created the movie
-GetMovieYear get the year of the movie
-GetMovieGPS gets the GPS location data of the movie

With an extra -Format switch you can specify how the movie GPS location is returned:

-Format=Decimal (default) format the GPS using decimal coordinates
-Format=DegMinSecs format the GPS using latitude, longitude (in degrees, minutes and seconds) and height (in meters)
-Format=ISO6709 format the GPS using according to ISO 6709

If there is no Timecode track or GPS or creation data an empty string is returned.

You can now also use these switches to get a single metadata item of a movie

-GetMovieTitle
-GetMovDescriptionStr this gets only the description metadata of the movie. Don’t confuse this with the -GetMovieDescription switch (see above).
-GetMovieKeywords
-GetMovieAlbum
-GetMovieArtist
-GetMovieAuthor
-GetMovieComment
-GetMovieCopyright
-GetMovieInformation
-GetMovieProducer
-GetMovieDirector
-GetMovieEncodedBy

For backwards compatibility you can use this switch:

-GetMovieDescriptionOldFormat returns the original result of "-GetMovieDescription", i.e. height returned first and not reflecting the rotation of the movie.

To get ICC Profile information use these switches:

-GetIccProfileName returns the name of the embedded ICC Color Profile for example "sRGB IEC61966-2.1"
-GetLocalizedIcc ProfileName returns the localized name of the embedded ICC Color Profile in the JPEG. Based on the user language settings it will return the ICC name that best matches the user language. For example for an Italian user it can return "Profilo RGB generico".
-GetIccProfileDescription returns a text description of the embedded ICC Color Profile. The result is formatted as a list. You can also add the switch "-Format=XML" to get the result in XML format, with the XML tags colored blue.

You can also add the switch:

-DontAddStyle the result will be in plain text.

For PDFs this switch can be used:

-GetPDFDescription get metadata of a PDF file, such as the document’s title, author, and creation date

Returned Result

Data type returned

Text

Result

the requested metadata, if available.

Returned error codes can be:

$$-2026 userDataItemNotFound the requested metadata is not available
$$-43 fnfErr source file not found
$$-50 paramErr parameter error

Other errors may be returned.

Originated in

Troi File Plug-in 2.0

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

Prior to Troi File 9.0 this function was called TrFile_MetaData.
Starting with version 12.1: you can use a container (or a variable with container data) as the source.
Starting with version 9.1: you can also use -GetXMP with movies that contain XMP. Version 9.1 also added the switches -GetMovieMetadata, -GetMovieCreationDate and -GetMovieGPS.

Note that some metadata is returned in a raw form. See the example files “IPTC_XMP_Metadata” and GetEXIF” for information on how to parse this.

Exif (Exchangeable image file) metadata in an image file will contain annotation data such as the time a photo was created, aperture and shutter speed. Your digital camera needs to have put this in the file.

From v6.0: When using the switch “-GetIPTC” the plug-in can now automatically detect if the text is UTF-8 encoded (and also returns with the metadata text correctly formatted). If UTF-8 format is detected it will override the switches: “-SourceMacCharSet” and “-SourceWinCharSet”.

IPTC data in image files can also be either Mac or Windows encoded . With the switches “-SourceMacCharSet” and “-SourceWinCharSet” you can manually tell the plug-in which character encoding you expect in the image files. Alternatively you can retrieve both encodings and then see which is best. Note: If you don’t specify a CharSet switch, the plug-in uses the encoding of the platform it is running on.

Version 5.5 added getting Exif from RAW files. v4.5 added the -GetRawExif switch: this will return the Exif data in a more original form, as fractions. For example aperture will be returned as 95/32, instead of 2.96875. This makes it possible to write Exif data back in the original form, with the TrFile_SetMetaData function.

v13.0 added these switches:
-GetMovieWidth
-GetMovieHeight
-GetMovieRotation
-GetMovieFrameCount
-GetMovieSoftware
-GetMovieYear
-IsValidMovie
-AddFrameCount

v14.0 added these switches:
-GetIccProfileName
-GetLocalizedIccProfileName
-GetIccProfileDescription
-DontAddStyle

v15.0 added these switches:
-GetMovieTitle
-GetMovDescriptionStr *
-GetMovieKeywords
-GetMovieAlbum
-GetMovieArtist
-GetMovieAuthor
-GetMovieComment
-GetMovieCopyright
-GetMovieInformation
-GetMovieProducer
-GetMovieDirector
-GetMovieEncodedBy

*Note that the -GetMovDescriptionStr switch is different from the -GetMovieDescription switch, which returns a list of (all) movie properties.

v15.0 also added support for getting EXIF out of PNG images.
v16.0 added the switch -GetPhotoshopIPTCDigest

Example

Set Field [ result ; TrFile_GetMetaData ( "-GetExif " ; "C:\myData\Photo1.jpg" ) ]

This will return the raw EXIF data. The data will look like this:

##EXIF 270
OLYMPUS DIGITAL CAMERA
##END 270
##EXIF 306
2011:06:09 10:50:40
##END 306

Example 2

Set Field [ result ; TrFile_GetMetaData ( "-GetIPTC " ;  gFilePath ) ]

This will return the raw IPTC data. The data will look like this:

##IPTC 120
FOR IMMEDIATE RELEASE–FILE–Shania Twain performs at the Country Music Association Awards show in Nashville, Tenn., …
##END 120
##IPTC 122
CJC RWP MAH
##END 122
##IPTC 105
SHANIA TWAIN
##END 105
##IPTC 40
FOR IMMEDIATE RELEASE. A SEPT. 22, 1999 FILE PHOTO. DIGITAL IMAGE
##END 40

Used in example files

GetExif.fmp12
IPTC_XMP_Metadata.fmp12
SetExif.fmp12
GetMovieMetadata.fmp12
GetICC_Profile.fmp12

Related functionsFunction badge

TrFile_GetAsPlainText
TrFile_GetFileStructure
TrFile_SetMetaData

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_GetMetaData (filep4260) 2024-0604 19:14:29