Does anyone have any idea how to rotate images in a folder using a PowerShell script? I'm working on an OCR flow that converts PDFs to images to OCR scan for data to be used in the renaming and moving of the PDFs. The OCR does not seem to work on images rotated 90 degrees. Think of a landscape page scanned as a portrait. So any remaining images after my flow will need to be rotated. I can achieve this through UI manipulation, but I was hoping for a more efficient way.
Hi Jason,
Please refer the below PowerShell script to rotate multiple images in a specific folder:
--------------------------------------------------------------------------------
$path = "FOLDER PATH" #target directory
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
Get-ChildItem -recurse ($path) -include @("*.png", "*.jpg") |
ForEach-Object {
$image = [System.Drawing.image]::FromFile( $_ )
$image.rotateflip("Rotate90FlipNone")
$image.save($_)
}
--------------------------------------------------------------------------------
Hope this will help.
Regards
Kaif
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional