Wednesday, January 20, 2016

Converting BMP Files to JPEG Format

Here is a simple PowerShell script which does the job.


$Path = "E:\Pictures\Scanned\"
$files = Get-ChildItem $Path*.bmp
Add-Type -AssemblyName system.drawing
$imageFormat = "System.Drawing.Imaging.ImageFormat" -as [type]
ForEach ($file in $files) { 
    $outputfile =  $file.fullName -replace ".bmp", ".jpg"
    write-host $outputfile
    $image = [drawing.image]::FromFile($file.fullName)
    $image.Save($outputfile, $imageFormat::jpeg)
}
 
If you find this script useful please donate generously.

No comments:

Post a Comment