Last active
April 6, 2017 21:38
-
-
Save FooBartn/5ea2c79c305ccfd50a01b93115716536 to your computer and use it in GitHub Desktop.
Revisions
-
FooBartn revised this gist
Apr 6, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ function Get-ImageTakenDate { } catch { if ($_.Exception -like '*Property cannot be found*') { Write-Error 'Could not find date image was taken.' } else { Write-Error $_ } -
FooBartn revised this gist
Apr 6, 2017 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,9 @@ function Get-ImageTakenDate { ) try { $DrawingLibrary = [reflection.assembly]::LoadWithPartialName("System.Drawing"); $FullObjectPath = (Get-Item $Path -ErrorAction Stop).FullName $ImageBitmap = New-Object System.Drawing.Bitmap($FullObjectPath) -ErrorAction Stop [byte[]]$ByteDate = $ImageBitmap.GetPropertyItem(36867).Value [string]$DateString,[string]$TimeString = [System.Text.Encoding]::ASCII.GetString($ByteDate).Split(' ') -
FooBartn created this gist
Apr 6, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ function Get-ImageTakenDate { [CmdletBinding()] param ( # Path [Parameter(Mandatory)] [string] $Path ) try { $DrawingLibrary = [reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll") $ImageBitmap = New-Object System.Drawing.Bitmap($Path) -ErrorAction Stop [byte[]]$ByteDate = $ImageBitmap.GetPropertyItem(36867).Value [string]$DateString,[string]$TimeString = [System.Text.Encoding]::ASCII.GetString($ByteDate).Split(' ') $Year,$Month,$Day = $DateString.Split(':') $Hour,$Minute,$Second = $TimeString.Split(':') $DateTimeParams = @{ Year = $Year Month = $Month Day = $Day Hour = $Hour Minute = $Minute Second = $Second } Get-Date @DateTimeParams } catch { if ($_.Exception -like '*Property cannot be found*') { Write-Error 'Unable to get creation date from image.' } else { Write-Error $_ } } finally { $ImageBitmap.Dispose() } }