I'm still relatively new to PowerShell. This is a follow up to Use PowerShell to extract GPS Latitude etc. (Properties > Details) from an image file and using code like this (from @stackprotector):
# Create an ImageFile object and load an image file
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile("C:\Absolute\path\to\my.jpg")
# Read your desirered metadata
$image.Properties.Item('GpsLatitude').Value
As some images have no GPS data, this gets an error. How can I check if Properties.Item('GpsLatitude') actually exists in that file, before trying to extract it?
Thank you.
For this specific purpose, you can use the Properties.Exists method:
In general, you can always use exception handling.