8,330 questions
You need to define the format using the PixelFormat system.drawing.imaging.pixelformat
Here's an example: how-to-save-a-bitmap-object-in-16bit
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a code to batch convert a folder of jpg files to BMP.
The code i have works ok, But it gets saved as BMP 24 bits..
I need it to convert it to BMP 16 bits
function ConvertImage{
$Origen="C:\jpg" #path to files
$Destino="C:\bmp" #path to files
if (Test-Path $Origen){
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
foreach($file in (Get-ChildItem -Path "$Origen\*.jpg" -Exclude *-*)){
$convertfile = new-object System.Drawing.Bitmap($file.Fullname)
$newfilname = $Destino + '\' + $file.BaseName + '.bmp'
$convertfile.Save($newfilname, "bmp")
$file.Fullname
}
}
else{
Write-Host "Path not found."
}
};ConvertImage -path $args[0]
You need to define the format using the PixelFormat system.drawing.imaging.pixelformat
Here's an example: how-to-save-a-bitmap-object-in-16bit