PSReadExif is a PowerShell module that reads EXIF metadata from image files using native Windows GDI+ classes.
PSReadExif is a PowerShell module that reads EXIF metadata from image files using native Windows GDI+ classes.
Some image file metadata can be viewed in Windows Explorer's properties dialog, however, that data is not available natively as PowerShell file object properties.
The [System.Drawing.Bitmap]
class (part of the GDI+ Win32 API) allows access to a range of 217 EXIF metadata properties as binary data arrays. The functions of this module use the class to access the EXIF metadata and then decode it into meaningful (human readable) form. PSReadExif cannot be used to modify or create EXIF metadata.
Note: While the 217 available metadata properties cover a lot of commonly used data points, many more exist (ExifTool documentation notes that it recognizes more than 25,000). If you need to read image metadata that is not exposed with PSReadExif, or write any image metadata, it's recommended to use ExifTool or another metadata editor.
The module is available through the PowerShell Gallery. Run the following command in a PowerShell console to install the module:
Install-Module -Name PSReadExif -Force
Run the following to import the module into the current session:
Import-Module -Name PSReadExif
To see the list of available commands:
Get-Command -Module PSReadExif
If you see a list of functions similar to those above, your install was successful.
To read EXIF metadata from a file:
$Path = 'C:\my\images\Canon.jpg'
Get-ExifData -Path $Path
For more examples, see the Get-ExifData function help.
To add EXIF metadata as properties of a file object:
$Path = 'C:\my\images\Canon.jpg'
Get-Item -Path $Path | Add-ExifData | Select-Object -ExpandProperty ExifData
For more examples, see the Add-ExifData function help.
Rename all jpeg images in a directory using the date the image was taken:
Get-ChildItem -Filter *.jpg | Add-ExifData | Where-Object { $_.ExifData.DateTimePS } | Rename-Item -NewName { $_.ExifData.DateTimePS.ToString('yyyyMMdd_HHmmss')+$_.Extension }
Find all images in a directory taken in horizontal format:
Get-ChildItem | Add-ExifData | Where-Object { $_.ExifData.Orientation -like 'Horizontal*' }
- Handle a divide by zero error
- Add call to Dispose() method
- Add examples in about_PSReadExif
- Initial release