# Based on answer from @stackprotector (above)
# Create an ImageFile object and load an image file
$image = New-Object -ComObject Wia.ImageFile
$image.LoadFile("D:\temp\toNAS\temp\PXL_20210830_004210948.jpg")
$image.Properties.Item('GpsLatitudeRef').Value
# S
$image.Properties.Item('GpsLatitude').Value
<#
Value Numerator Denominator
----- --------- -----------
37 37 1
51 51 1
43.92 4392 100
>#
# Can rinse and repeat for GpsLongitude
现在提取我想要的。这是一个子集;容易复制在gps经度为另一个:-)
$image.Properties.Item('GpsLatitude').Value[1].Value
# 37
$image.Properties.Item('GpsLatitude').Value[2].Value
# 51
$image.Properties.Item('GpsLatitude').Value[3].Value
# 43.92
$image.Properties.Item('GpsLatitudeRef').Value
# S
$image.Properties.Item('DateTime').Value
# 2021:08:30 10:42:10
# This is local not UTC
# So final latitude is 37 deg 51 min 43.92 sec S
# Taken on 2021:08:30 10:42:10 local time
4条答案
按热度按时间flvtvl501#
要在不使用外部工具的情况下访问Windows资源管理器中的元数据(不同于文件系统元数据),必须使用Windows Image Acquisition (WIA) Automation Layer。
请注意,与ExifTool或exiv2等外部工具相比,WIA的解析功能非常有限,但足以获取您所需的数据。
你可以阅读更多关于
ImageFile
对象的信息,以及它们在here中的作用。xdnvmnnf2#
感谢大家,尤其是@stackprotector。我学到了很多,并且设法找到了如何提取我的精确值,包括重要的N,S,E,W。
为了帮助别人,我发现了:
现在提取我想要的。这是一个子集;容易复制在gps经度为另一个:-)
相机内的值显示为**-37.8622**,拍摄于2021年8月30日当地时间10:42:10,非常满意,包括“-”代表南部
我会试试Exiftool @丹尼尔,看看是否更容易,我以前用过,非常好。
***更新(2022-02-13)。***我最终选择了Exiftool。随着我对JSON越来越有信心,这个工具集对我来说也变得越来越明显。下面是关键代码片段(见下文)。还有一点:这个exiftool选项集在运行时不给“反馈”。2只有在最后才给出一个总结:
ocebsuys3#
使用@dwids和@stackprotector的答案,我得到了下面的代码来遍历一个文件夹中的所有文件,它不是最整洁的,但它是不言自明的:
显然,如果只需要坐标列表,可以删除
Write-Host "$FileName"
(文件路径和名称),或者如果只需要文件名,可以将其更改为Write-Host "$_"
。您可以将
-Recurse
添加到Get-ChildItem $FolderPath -Filter *.* |
,这样就可以使用Get-ChildItem $FolderPath -Filter *.* -Recurse |
查看所有子文件夹中的所有文件。omjgkv6w4#
@dwids-要显示进度,您可以使用exiftool 'pod' www.example.com中记录的exiftool的"进度"功能https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature
如果后跟冒号(即-progress:),则根据指定的TITLE字符串设置控制台窗口标题。如果未给定TITLE,则假定默认TITLE字符串为"ExifTool % p %%"。在该字符串中,% f表示文件名,% p表示进度百分比,% r表示进度比率,%##b表示宽度为"##"(如果省略"##",则为20个字符)的进度条,%%表示%字符。可以与normal-progress选项结合使用,以便在控制台消息中显示进度计数。(注意:要使此功能在Mac/Linux上正常运行,必须将stderr转到控制台。)
下面的代码是从工作代码中摘录的,而不是重新编写您的示例:
进度条将出现在exiftool运行窗口的框架中。%50b将为exiftool处理的每2%的文件创建一个新标记。
这个例子还展示了exiftool命令如何包含变量,例如源目录的变量。这个例子在Linux和Windows下都可以使用。
希望这个有用。
应该是一个评论,但我没有足够的代表。