I'm trying to batch convert a bunch of transparent pngs to jpgs and the below cobbled powershell works but whenever I convert all images come out black. I tried the answer here Convert Transparent PNG to JPG with Non-Black Background Color but I get "using" keyword is not supported (couldn't find it in the modules either)
$files = Get-ChildItem "C:\Pictures\test" -Filter *.png -file -Recurse |
foreach-object {
$Source = $_.FullName
$test = [System.IO.Path]::GetDirectoryName($source)
$base= $_.BaseName+".jpg"
$basedir = $test+"\"+$base
Write-Host $basedir
Add-Type -AssemblyName system.drawing
$imageFormat = "System.Drawing.Imaging.ImageFormat" -as [type]
$image = [drawing.image]::FromFile($Source)
$image.Save($basedir, $imageFormat::jpeg)
}
From what I understand you need to create a new bitmap graphic with a white background and draw this image over that but for the life of me I can't figure out how to add it in.