我有一個腳本,通過我已經拍攝的圖像負載循環讀取焦距&攝像機模型,呈現焦距和總計圖(這非常適合幫助確定下一個鏡頭購買,但除此之外)。PowerShell讀大文件的元數據
這對於10 MB以下的JPG圖像來說絕對正常,但只要它碰到一個接近20 MB的RAW文件(如Canon的CR2格式),它就會吐出「內存不足」錯誤。
有沒有辦法增加Powershell中的內存限制,或只是讀取文件的元數據而不加載整個文件..?
這是我目前使用:
# load image by statically calling a method from .NET
$image = [System.Drawing.Imaging.Metafile]::FromFile($file.FullName)
# try to get the ExIf data (silently fail if the data can't be found)
# http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
try
{
# get the Focal Length from the Metadata code 37386
$focalLength = $image.GetPropertyItem(37386).Value[0]
# get model data from the Metadata code 272
$modelByte = $image.GetPropertyItem(272)
# convert the model data to a String from a Byte Array
$imageModel = $Encode.GetString($modelByte.Value)
# unload image
$image.Dispose()
}
catch
{
#do nothing with the catch
}
我在這裏使用該解決方案的嘗試:http://goo.gl/WY7Rg但CR2文件只是返回的任何財產上的空白...
任何幫助,不勝感激!
不幸的模塊不會對.CR2文件:-( 獲取-EXIF剛剛返回空白項的負載是煩人的工作。回到繪圖板! – Alex 2012-07-15 16:24:46