How can I get programmatic access to the “Date taken” field of an image or video using powershell?

前端 未结 2 1422
清酒与你
清酒与你 2021-02-13 03:37

I\'m trying convert a bunch of pictures and videos, but when I convert it to a new format I obviously lose the properties of the original file. I\'d like to be able to read the

2条回答
  •  耶瑟儿~
    2021-02-13 04:22

    I can't test it right now (don't have any images with XIF data laying around, but I think this should work:

    [reflection.assembly]::LoadWithPartialName("System.Drawing")
    $pic = New-Object System.Drawing.Bitmap('C:\PATH\TO\SomePic.jpg')
    $bitearr = $pic.GetPropertyItem(36867).Value 
    $string = [System.Text.Encoding]::ASCII.GetString($bitearr) 
    $DateTime = [datetime]::ParseExact($string,"yyyy:MM:dd HH:mm:ss`0",$Null)
    $DateTime
    

提交回复
热议问题