Skip to content

Instantly share code, notes, and snippets.

@ngollan
Created June 21, 2020 17:00
Show Gist options
  • Save ngollan/a97da17ee7e591f1ee214df3e864f1d8 to your computer and use it in GitHub Desktop.
Save ngollan/a97da17ee7e591f1ee214df3e864f1d8 to your computer and use it in GitHub Desktop.
Convert Elite Dangerous screenshots to PNG and set creation date as XMP metadata.
Get-ChildItem "$([Environment]::GetFolderPath("MyPictures"))\Frontier Developments\Elite Dangerous" -Filter "*.bmp" |
Foreach-Object {
$dir = $_.DirectoryName
$base = $_.BaseName
$originalDate = $_.CreationTimeUtc
$destination = "$($dir)/PNG/$($base).png"
$result = "" | select name, converted, setMetadata
$result.name = $base
$result.converted = $false
if (!(Test-Path -Path $destination)) {
# Write to PNG with an embedded sRGB profile.
D:\bin\ImageMagick\convert.exe $_.FullName -profile D:\sRGB2014.icc "$($dir)/PNG/$($base).png"
$result.converted = $true
}
# Write the original file creation date as XMP metadata. That is what Adobe Bridge seems to react to best,
# and it is not impossible to read back later. Fractional seconds appear to get dropped, but wo really cares.
$originalDateString = $originalDate | Get-Date -Format "yyyy:MM:dd HH:mm:ss.ff\Z"
D:\bin\exiftool.exe -q -if 'not defined $xmp:dateTimeOriginal' -xmp:dateTimeOriginal="$($originalDateString)Z" $destination
$result.setMetadata = $?
$result
}
@ngollan
Copy link
Author

ngollan commented Jun 21, 2020

Assumes ImageMagick executables in D:\bin\ImageMagick\ and D:\bin\exiftool.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment